X-Git-Url: https://git.openstreetmap.org./osqa.git/blobdiff_plain/f5fda79fa40310950e0c6f40a40619c701fd3f08..fa89c5511089b849ff9ed8bac9205b1e2abe6d03:/forum/models/user.py diff --git a/forum/models/user.py b/forum/models/user.py index 8dd5ff9..34c6b36 100644 --- a/forum/models/user.py +++ b/forum/models/user.py @@ -151,6 +151,10 @@ class User(BaseModel, DjangoUser): return self.username + @property + def last_activity(self): + return self.actions.order_by('-action_date')[0].action_date + @property def gravatar(self): return md5(self.email).hexdigest() @@ -331,13 +335,13 @@ class User(BaseModel, DjangoUser): def suspension(self): if self.__dict__.get('_suspension_dencache_', False) != None: try: - self.__dict__['_suspension_dencache_'] = self.actions.get(action_type="suspend", canceled=False) + self.__dict__['_suspension_dencache_'] = self.reputes.get(action__action_type="suspend", action__canceled=False).action except ObjectDoesNotExist: self.__dict__['_suspension_dencache_'] = None except MultipleObjectsReturned: logging.error("Multiple suspension actions found for user %s (%s)" % (self.username, self.id)) - self.__dict__['_suspension_dencache_'] = self.actions.filter(action_type="suspend", canceled=False - ).order_by('-action_date')[0] + self.__dict__['_suspension_dencache_'] = self.reputes.filter(action__action_type="suspend", action__canceled=False + ).order_by('-action__action_date')[0] return self.__dict__['_suspension_dencache_'] @@ -419,13 +423,13 @@ class UserPropertyDict(object): class SubscriptionSettings(models.Model): - user = models.OneToOneField(User, related_name='subscription_settings') + user = models.OneToOneField(User, related_name='subscription_settings', editable=False) enable_notifications = models.BooleanField(default=True) #notify if member_joins = models.CharField(max_length=1, default='n') - new_question = models.CharField(max_length=1, default='d') + new_question = models.CharField(max_length=1, default='n') new_question_watched_tags = models.CharField(max_length=1, default='i') subscribed_questions = models.CharField(max_length=1, default='i')