Mercurial > public > sg101
comparison bio/models.py @ 1206:02181fa5ac9d modernize tip
Update to Django 1.9.
author | Brian Neal <bgneal@gmail.com> |
---|---|
date | Wed, 22 Jan 2025 17:58:16 -0600 |
parents | eeaf387803c6 |
children |
comparison
equal
deleted
inserted
replaced
1205:510ef3cbf3e6 | 1206:02181fa5ac9d |
---|---|
78 | 78 |
79 | 79 |
80 class UserProfile(models.Model): | 80 class UserProfile(models.Model): |
81 """model to represent additional information about users""" | 81 """model to represent additional information about users""" |
82 | 82 |
83 user = models.OneToOneField(User, related_name='profile') | 83 user = models.OneToOneField(User, related_name='profile', |
84 on_delete=models.CASCADE) | |
84 location = models.CharField(max_length=128, blank=True) | 85 location = models.CharField(max_length=128, blank=True) |
85 country = models.CharField(max_length=2, blank=True, default='', | 86 country = models.CharField(max_length=2, blank=True, default='', |
86 choices=bio.flags.FLAG_CHOICES, | 87 choices=bio.flags.FLAG_CHOICES, |
87 help_text='Optional') | 88 help_text='Optional') |
88 birthday = models.DateField(blank=True, null=True, | 89 birthday = models.DateField(blank=True, null=True, |
182 return text | 183 return text |
183 | 184 |
184 | 185 |
185 class UserProfileFlag(models.Model): | 186 class UserProfileFlag(models.Model): |
186 """This model represents a user flagging a profile as inappropriate.""" | 187 """This model represents a user flagging a profile as inappropriate.""" |
187 user = models.ForeignKey(User) | 188 user = models.ForeignKey(User, on_delete=models.CASCADE) |
188 profile = models.ForeignKey(UserProfile) | 189 profile = models.ForeignKey(UserProfile, on_delete=models.CASCADE) |
189 flag_date = models.DateTimeField(auto_now_add=True) | 190 flag_date = models.DateTimeField(auto_now_add=True) |
190 | 191 |
191 def __unicode__(self): | 192 def __unicode__(self): |
192 return u"%s's profile flagged by %s" % (self.profile.user.username, | 193 return u"%s's profile flagged by %s" % (self.profile.user.username, |
193 self.user.username) | 194 self.user.username) |
200 get_profile_url.allow_tags = True | 201 get_profile_url.allow_tags = True |
201 | 202 |
202 | 203 |
203 class BadgeOwnership(models.Model): | 204 class BadgeOwnership(models.Model): |
204 """This model represents the ownership of badges by users.""" | 205 """This model represents the ownership of badges by users.""" |
205 profile = models.ForeignKey(UserProfile) | 206 profile = models.ForeignKey(UserProfile, on_delete=models.CASCADE) |
206 badge = models.ForeignKey(Badge) | 207 badge = models.ForeignKey(Badge, on_delete=models.CASCADE) |
207 count = models.IntegerField(default=1) | 208 count = models.IntegerField(default=1) |
208 | 209 |
209 class Meta: | 210 class Meta: |
210 verbose_name_plural = "badge ownership" | 211 verbose_name_plural = "badge ownership" |
211 ordering = ('badge__order', ) | 212 ordering = ('badge__order', ) |