diff options
| author | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-04-21 02:22:44 -0400 | 
|---|---|---|
| committer | Luke Shumaker <LukeShu@sbcglobal.net> | 2013-04-21 02:22:44 -0400 | 
| commit | 03fa7e4f27bdb39a8f8f5ed91a87d18bf8357b47 (patch) | |
| tree | c67eafcbda55706f18400b3115a2b8a5be318394 /devel/models.py | |
| parent | 91c451821ce7000cbc268cec8427d208a6cedd7e (diff) | |
| parent | b8ee7b1ee281b45b245fb454228b8ad847c56200 (diff) | |
Merge branch 'archweb' into archweb-generic2
Conflicts:
	devel/views.py
	feeds.py
	public/views.py
	settings.py
	sitestatic/archweb.js
	templates/base.html
	templates/devel/profile.html
	templates/mirrors/status.html
	templates/news/view.html
	templates/packages/flaghelp.html
	templates/packages/opensearch.xml
	templates/public/download.html
	templates/public/feeds.html
	templates/public/index.html
	templates/registration/login.html
	templates/releng/results.html
	templates/todolists/public_list.html
Diffstat (limited to 'devel/models.py')
| -rw-r--r-- | devel/models.py | 32 | 
1 files changed, 28 insertions, 4 deletions
| diff --git a/devel/models.py b/devel/models.py index fd5a0347..67de40a6 100644 --- a/devel/models.py +++ b/devel/models.py @@ -2,11 +2,13 @@  import pytz  from django.db import models +from django.db.models.signals import pre_save  from django.contrib.auth.models import User +from django.utils.timezone import now  from django_countries import CountryField  from .fields import PGPKeyField -from main.utils import make_choice +from main.utils import make_choice, set_created_field  class UserProfile(models.Model): @@ -44,11 +46,13 @@ class UserProfile(models.Model):      allowed_repos = models.ManyToManyField('main.Repo', blank=True)      latin_name = models.CharField(max_length=255, null=True, blank=True,          help_text="Latin-form name; used only for non-Latin full names") +    last_modified = models.DateTimeField(editable=False)      class Meta:          db_table = 'user_profiles' -        verbose_name = 'Additional Profile Data' -        verbose_name_plural = 'Additional Profile Data' +        get_latest_by = 'last_modified' +        verbose_name = 'additional profile data' +        verbose_name_plural = 'additional profile data'      def get_absolute_url(self):          # TODO: this is disgusting. find a way to consolidate this logic with @@ -64,7 +68,6 @@ class UserProfile(models.Model):          return '/%s/#%s' % (prefix, self.user.username) -  class MasterKey(models.Model):      owner = models.ForeignKey(User, related_name='masterkey_owner',          help_text="The developer holding this master key") @@ -77,12 +80,27 @@ class MasterKey(models.Model):      class Meta:          ordering = ('created',) +        get_latest_by = 'created'      def __unicode__(self):          return u'%s, created %s' % (                  self.owner.get_full_name(), self.created) +class DeveloperKey(models.Model): +    owner = models.ForeignKey(User, related_name='all_keys', null=True, +        help_text="The developer this key belongs to") +    key = PGPKeyField(max_length=40, verbose_name="PGP key fingerprint", +			unique=True) +    created = models.DateTimeField() +    expires = models.DateTimeField(null=True, blank=True) +    revoked = models.DateTimeField(null=True, blank=True) +    parent = models.ForeignKey('self', null=True, on_delete=models.SET_NULL) + +    def __unicode__(self): +        return self.key + +  class PGPSignature(models.Model):      signer = PGPKeyField(max_length=40, verbose_name="Signer key fingerprint")      signee = PGPKeyField(max_length=40, verbose_name="Signee key fingerprint") @@ -91,9 +109,15 @@ class PGPSignature(models.Model):      valid = models.BooleanField(default=True)      class Meta: +        ordering = ('signer', 'signee') +        get_latest_by = 'created'          verbose_name = 'PGP signature'      def __unicode__(self):          return u'%s → %s' % (self.signer, self.signee) + +pre_save.connect(set_created_field, sender=UserProfile, +        dispatch_uid="devel.models") +  # vim: set ts=4 sw=4 et: | 
