summaryrefslogtreecommitdiff
path: root/devel/models.py
diff options
context:
space:
mode:
authorLuke Shumaker <LukeShu@sbcglobal.net>2012-12-12 20:24:30 -0500
committerLuke Shumaker <LukeShu@sbcglobal.net>2012-12-12 20:24:30 -0500
commitf9ae4f860ccf57e84032d7be9426331a9e06e979 (patch)
treec9d837d7e2750d22ba9049abc7cf3c4125f0c9e4 /devel/models.py
parent6c5c3355a97d35afb7f1eee284966ad0bf8cee3b (diff)
parent206000df736fde75a49c3178a8522d17f30a955e (diff)
Merge tag 'release_2012-04-21'
Migrations, moving code around, random small improvements
Diffstat (limited to 'devel/models.py')
-rw-r--r--devel/models.py60
1 files changed, 59 insertions, 1 deletions
diff --git a/devel/models.py b/devel/models.py
index 2fc61060..79c56f2a 100644
--- a/devel/models.py
+++ b/devel/models.py
@@ -1,8 +1,66 @@
# -*- coding: utf-8 -*-
+import pytz
+
from django.db import models
from django.contrib.auth.models import User
-from main.fields import PGPKeyField
+from .fields import PGPKeyField
+from main.utils import make_choice
+
+
+class UserProfile(models.Model):
+ notify = models.BooleanField(
+ "Send notifications",
+ default=True,
+ help_text="When enabled, send user 'flag out-of-date' notifications")
+ time_zone = models.CharField(
+ max_length=100,
+ choices=make_choice(pytz.common_timezones),
+ default="UTC",
+ help_text="Used for developer clock page")
+ alias = models.CharField(
+ max_length=50,
+ help_text="Required field")
+ public_email = models.CharField(
+ max_length=50,
+ help_text="Required field")
+ other_contact = models.CharField(max_length=100, null=True, blank=True)
+ pgp_key = PGPKeyField(max_length=40, null=True, blank=True,
+ verbose_name="PGP key fingerprint",
+ help_text="consists of 40 hex digits; use `gpg --fingerprint`")
+ website = models.CharField(max_length=200, null=True, blank=True)
+ yob = models.IntegerField("Year of birth", null=True, blank=True)
+ location = models.CharField(max_length=50, null=True, blank=True)
+ languages = models.CharField(max_length=50, null=True, blank=True)
+ interests = models.CharField(max_length=255, null=True, blank=True)
+ occupation = models.CharField(max_length=50, null=True, blank=True)
+ roles = models.CharField(max_length=255, null=True, blank=True)
+ favorite_distros = models.CharField(max_length=255, null=True, blank=True)
+ picture = models.FileField(upload_to='devs', default='devs/silhouette.png',
+ help_text="Ideally 125px by 125px")
+ user = models.OneToOneField(User, related_name='userprofile')
+ 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")
+
+ class Meta:
+ db_table = 'user_profiles'
+ 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
+ # public.views.userlist among other places, and make some constants or
+ # something so we aren't using copies of string names everywhere.
+ group_names = self.user.groups.values_list('name', flat=True)
+ if "Developers" in group_names:
+ prefix = "developers"
+ elif "Trusted Users" in group_names:
+ prefix = "trustedusers"
+ else:
+ prefix = "fellows"
+ return '/%s/#%s' % (prefix, self.user.username)
+
class MasterKey(models.Model):