Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 1 | import os |
| 2 | from django.db import models |
| 3 | from plstackapi.core.models import PlCoreBase |
Siobhan Tully | 5343728 | 2013-04-26 19:30:27 -0400 | [diff] [blame] | 4 | from plstackapi.core.models import PLUser |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 5 | |
| 6 | # Create your models here. |
| 7 | |
| 8 | class Key(PlCoreBase): |
Tony Mack | 85d1883 | 2013-05-09 17:02:31 -0400 | [diff] [blame] | 9 | key_id = models.CharField(null=True, blank=True, max_length=256, unique=True) |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 10 | key = models.CharField(max_length=512) |
| 11 | type = models.CharField(max_length=256) |
| 12 | blacklisted = models.BooleanField(default=False) |
Siobhan Tully | 5343728 | 2013-04-26 19:30:27 -0400 | [diff] [blame] | 13 | user = models.ForeignKey(PLUser, related_name='keys') |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 14 | |
Tony Mack | b6a29b1 | 2013-05-09 17:31:33 -0400 | [diff] [blame] | 15 | def __unicode__(self): return u'%s' % (self.user.email[:self.user.email.find('@')]) |
Tony Mack | 759b57a | 2013-04-14 21:03:31 -0400 | [diff] [blame] | 16 | |
| 17 | def save(self, *args, **kwds): |
Tony Mack | d685bfa | 2013-05-02 10:09:51 -0400 | [diff] [blame] | 18 | self.os_manager.save_key(self) |
Tony Mack | 759b57a | 2013-04-14 21:03:31 -0400 | [diff] [blame] | 19 | super(Key, self).save(*args, **kwds) |
| 20 | |
| 21 | def delete(self, *args, **kwds): |
Tony Mack | d685bfa | 2013-05-02 10:09:51 -0400 | [diff] [blame] | 22 | self.os_manager.delete_key(self) |
Tony Mack | 759b57a | 2013-04-14 21:03:31 -0400 | [diff] [blame] | 23 | super(Key, self).delete(*args, **kwds) |
| 24 | |