##// END OF EJS Templates
Updates to the user model
neko259 -
r624:e21a263d default
parent child Browse files
Show More
@@ -56,8 +56,8 b' class User(models.Model):'
56 tags = self.fav_tags.annotate(Count('threads')) \
56 tags = self.fav_tags.annotate(Count('threads')) \
57 .filter(threads__count__gt=0).order_by('name')
57 .filter(threads__count__gt=0).order_by('name')
58
58
59 if tags.exists():
59 if tags:
60 cache.set(cache_key, tags, settings.CACHE_TIMEOUT)
60 cache.set(cache_key, tags)
61
61
62 return tags
62 return tags
63
63
@@ -68,8 +68,12 b' class User(models.Model):'
68 return self.user_id + '(' + str(self.rank) + ')'
68 return self.user_id + '(' + str(self.rank) + ')'
69
69
70 def get_last_access_time(self):
70 def get_last_access_time(self):
71 """
72 Gets user's last post time.
73 """
74
71 posts = Post.objects.filter(user=self)
75 posts = Post.objects.filter(user=self)
72 if posts.count() > 0:
76 if posts.exists() > 0:
73 return posts.latest('pub_time').pub_time
77 return posts.latest('pub_time').pub_time
74
78
75 def add_tag(self, tag):
79 def add_tag(self, tag):
General Comments 0
You need to be logged in to leave comments. Login now