]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/models/user.py
updated to a new base template and new replacements for easy styling
[osqa.git] / forum / models / user.py
index 6f7613a31cc4239bb00e99f7b56016e862819b7b..339c02d727f64fd6ecb8878bca8211eb313d5cf1 100644 (file)
@@ -61,6 +61,9 @@ class AnonymousUser(DjangoAnonymousUser):
     def can_accept_answer(self, answer):\r
         return False\r
 \r
+    def can_create_tags(self):\r
+        return False\r
+\r
     def can_edit_post(self, post):\r
         return False\r
 \r
@@ -155,7 +158,7 @@ class User(BaseModel, DjangoUser):
     def get_vote_count_today(self):\r
         today = datetime.date.today()\r
         return self.actions.filter(canceled=False, action_type__in=("voteup", "votedown"),\r
-                action_date__range=(today - datetime.timedelta(days=1), today)).count()\r
+                action_date__gte=(today - datetime.timedelta(days=1))).count()\r
 \r
     def get_reputation_by_upvoted_today(self):\r
         today = datetime.datetime.now()\r
@@ -167,7 +170,7 @@ class User(BaseModel, DjangoUser):
     def get_flagged_items_count_today(self):\r
         today = datetime.date.today()\r
         return self.actions.filter(canceled=False, action_type="flag",\r
-                action_date__range=(today - datetime.timedelta(days=1), today)).count()\r
+                action_date__gte=(today - datetime.timedelta(days=1))).count()\r
 \r
     @true_if_is_super_or_staff\r
     def can_view_deleted_post(self, post):\r
@@ -217,6 +220,10 @@ class User(BaseModel, DjangoUser):
     def can_accept_answer(self, answer):\r
         return self == answer.question.author\r
 \r
+    @true_if_is_super_or_staff\r
+    def can_create_tags(self):\r
+        return self.reputation >= int(settings.REP_TO_CREATE_TAGS)\r
+\r
     @true_if_is_super_or_staff\r
     def can_edit_post(self, post):\r
         return self == post.author or self.reputation >= int(settings.REP_TO_EDIT_OTHERS\r
@@ -255,6 +262,11 @@ class User(BaseModel, DjangoUser):
     def can_upload_files(self):\r
         return self.reputation >= int(settings.REP_TO_UPLOAD)\r
 \r
+    def check_password(self, old_passwd):\r
+        self.__dict__.update(self.__class__.objects.filter(id=self.id).values('password')[0])\r
+        return DjangoUser.check_password(self, old_passwd)\r
+\r
+\r
     class Meta:\r
         app_label = 'forum'\r
 \r