Commit a14a3504 by Paul Kilgo

add ContentType fkey to Key

parent b56c4574
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
from django.db import models from django.db import models
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.db.models.signals import pre_save, post_delete from django.db.models.signals import pre_save, post_delete
from django.dispatch import receiver from django.dispatch import receiver
...@@ -43,6 +44,7 @@ class Key(models.Model): ...@@ -43,6 +44,7 @@ class Key(models.Model):
key = models.TextField(max_length=2000) key = models.TextField(max_length=2000)
fingerprint = models.CharField(max_length=47, blank=True, db_index=True) fingerprint = models.CharField(max_length=47, blank=True, db_index=True)
created = models.DateTimeField(auto_now_add=True, null=True) created = models.DateTimeField(auto_now_add=True, null=True)
content_type = models.ForeignKey(ContentType)
last_modified = models.DateTimeField(null=True) last_modified = models.DateTimeField(null=True)
last_used = models.DateTimeField(null=True) last_used = models.DateTimeField(null=True)
...@@ -109,6 +111,12 @@ class ApplicationKey(models.Model): ...@@ -109,6 +111,12 @@ class ApplicationKey(models.Model):
class Meta: class Meta:
abstract = True abstract = True
@classmethod
def base(cls, **kw):
if not 'content_type' in kw:
kw['content_type'] = ContentType.objects.get_for_model(cls)
return Key(**kw)
def __unicode__(self): def __unicode__(self):
try: try:
return unicode(self.basekey) return unicode(self.basekey)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment