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): |
| 9 | name = models.CharField(max_length=256, unique=True) |
Tony Mack | cdec090 | 2013-04-15 00:38:49 -0400 | [diff] [blame] | 10 | key_id = models.CharField(max_length=256, unique=True) |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 11 | key = models.CharField(max_length=512) |
| 12 | type = models.CharField(max_length=256) |
| 13 | blacklisted = models.BooleanField(default=False) |
Siobhan Tully | 5343728 | 2013-04-26 19:30:27 -0400 | [diff] [blame] | 14 | user = models.ForeignKey(PLUser, related_name='keys') |
Siobhan Tully | 4bc09f2 | 2013-04-10 21:15:21 -0400 | [diff] [blame] | 15 | |
| 16 | def __unicode__(self): return u'%s' % (self.name) |
Tony Mack | 759b57a | 2013-04-14 21:03:31 -0400 | [diff] [blame] | 17 | |
| 18 | def save(self, *args, **kwds): |
Tony Mack | d685bfa | 2013-05-02 10:09:51 -0400 | [diff] [blame^] | 19 | self.os_manager.save_key(self) |
Tony Mack | 759b57a | 2013-04-14 21:03:31 -0400 | [diff] [blame] | 20 | super(Key, self).save(*args, **kwds) |
| 21 | |
| 22 | def delete(self, *args, **kwds): |
Tony Mack | d685bfa | 2013-05-02 10:09:51 -0400 | [diff] [blame^] | 23 | self.os_manager.delete_key(self) |
Tony Mack | 759b57a | 2013-04-14 21:03:31 -0400 | [diff] [blame] | 24 | super(Key, self).delete(*args, **kwds) |
| 25 | |