]> git.openstreetmap.org Git - osqa.git/blobdiff - forum/models/user.py
ALteration of the schema to a single content model. As a bonus there is a complete...
[osqa.git] / forum / models / user.py
index 655e17e864a51377f62fda4c6a64369b24e45760..536663143a8851bd5f716c0d7701558a7f8d8cb1 100644 (file)
@@ -216,7 +216,7 @@ class User(BaseModel, DjangoUser):
     class Meta:\r
         app_label = 'forum'\r
 \r
-class Activity(MetaContent):\r
+class Activity(GenericContent):\r
     """\r
     We keep some history data for user activities\r
     """\r
@@ -238,20 +238,16 @@ class Activity(MetaContent):
             activity_record.send(sender=self.activity_type, instance=self)\r
 \r
     @property\r
-    def question(self):\r
-        if self.activity_type == const.TYPE_ACTIVITY_ASK_QUESTION:\r
-            return self.content_object\r
-        elif self.activity_type in (const.TYPE_ACTIVITY_ANSWER,\r
+    def node(self):\r
+        if self.activity_type in (const.TYPE_ACTIVITY_ANSWER, const.TYPE_ACTIVITY_ASK_QUESTION,\r
                 const.TYPE_ACTIVITY_MARK_ANSWER, const.TYPE_ACTIVITY_UPDATE_QUESTION):\r
-            return self.content_object.question\r
-        elif self.activity_type == const.TYPE_ACTIVITY_COMMENT_QUESTION:\r
-            return self.content_object.content_object\r
-        elif self.activity_type == const.TYPE_ACTIVITY_COMMENT_ANSWER:\r
-            return self.content_object.content_object.question\r
-        elif self.activity_type == const.TYPE_ACTIVITY_UPDATE_ANSWER:\r
-            return self.content_object.content_object.answer.question\r
-        else:\r
-            raise NotImplementedError()\r
+            return self.content_object\r
+\r
+        if self.activity_type in (const.TYPE_ACTIVITY_COMMENT_QUESTION,\r
+                const.TYPE_ACTIVITY_COMMENT_ANSWER, const.TYPE_ACTIVITY_UPDATE_ANSWER):\r
+            return self.content_object.node.leaf\r
+            \r
+        raise NotImplementedError()\r
 \r
     @property\r
     def type_as_string(self):\r
@@ -262,13 +258,15 @@ class Activity(MetaContent):
         elif self.activity_type  == const.TYPE_ACTIVITY_MARK_ANSWER:\r
             return _("marked an answer")\r
         elif self.activity_type  == const.TYPE_ACTIVITY_UPDATE_QUESTION:\r
-            return _("edited")\r
+            return _("edited a question")\r
         elif self.activity_type == const.TYPE_ACTIVITY_COMMENT_QUESTION:\r
-            return _("commented")\r
+            return _("commented a question")\r
         elif self.activity_type == const.TYPE_ACTIVITY_COMMENT_ANSWER:\r
             return _("commented an answer")\r
         elif self.activity_type == const.TYPE_ACTIVITY_UPDATE_ANSWER:\r
             return _("edited an answer")\r
+        elif self.activity_type == const.TYPE_ACTIVITY_PRIZE:\r
+            return _("received badge")\r
         else:\r
             raise NotImplementedError()\r
 \r