blob: 661b9015b242c65f159f90d3c534e1eb1c203b8c [file] [log] [blame]
Siobhan Tully4bc09f22013-04-10 21:15:21 -04001import os
2from django.db import models
3from plstackapi.core.models import PlCoreBase
Siobhan Tully53437282013-04-26 19:30:27 -04004from plstackapi.core.models import PLUser
Siobhan Tully4bc09f22013-04-10 21:15:21 -04005
6# Create your models here.
7
8class Key(PlCoreBase):
Tony Mack85d18832013-05-09 17:02:31 -04009 key_id = models.CharField(null=True, blank=True, max_length=256, unique=True)
Siobhan Tully4bc09f22013-04-10 21:15:21 -040010 key = models.CharField(max_length=512)
11 type = models.CharField(max_length=256)
12 blacklisted = models.BooleanField(default=False)
Siobhan Tully53437282013-04-26 19:30:27 -040013 user = models.ForeignKey(PLUser, related_name='keys')
Siobhan Tully4bc09f22013-04-10 21:15:21 -040014
Tony Mackb6a29b12013-05-09 17:31:33 -040015 def __unicode__(self): return u'%s' % (self.user.email[:self.user.email.find('@')])
Tony Mack759b57a2013-04-14 21:03:31 -040016
17 def save(self, *args, **kwds):
Tony Mackd685bfa2013-05-02 10:09:51 -040018 self.os_manager.save_key(self)
Tony Mack759b57a2013-04-14 21:03:31 -040019 super(Key, self).save(*args, **kwds)
20
21 def delete(self, *args, **kwds):
Tony Mackd685bfa2013-05-02 10:09:51 -040022 self.os_manager.delete_key(self)
Tony Mack759b57a2013-04-14 21:03:31 -040023 super(Key, self).delete(*args, **kwds)
24