blob: afbebff5b818c8dabe21c1c696019c1cb3a347fe [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):
9 name = models.CharField(max_length=256, unique=True)
Tony Mackcdec0902013-04-15 00:38:49 -040010 key_id = models.CharField(max_length=256, unique=True)
Siobhan Tully4bc09f22013-04-10 21:15:21 -040011 key = models.CharField(max_length=512)
12 type = models.CharField(max_length=256)
13 blacklisted = models.BooleanField(default=False)
Siobhan Tully53437282013-04-26 19:30:27 -040014 user = models.ForeignKey(PLUser, related_name='keys')
Siobhan Tully4bc09f22013-04-10 21:15:21 -040015
16 def __unicode__(self): return u'%s' % (self.name)
Tony Mack759b57a2013-04-14 21:03:31 -040017
18 def save(self, *args, **kwds):
Tony Mackd685bfa2013-05-02 10:09:51 -040019 self.os_manager.save_key(self)
Tony Mack759b57a2013-04-14 21:03:31 -040020 super(Key, self).save(*args, **kwds)
21
22 def delete(self, *args, **kwds):
Tony Mackd685bfa2013-05-02 10:09:51 -040023 self.os_manager.delete_key(self)
Tony Mack759b57a2013-04-14 21:03:31 -040024 super(Key, self).delete(*args, **kwds)
25