from django.contrib.contenttypes.models import ContentType\r
from django.contrib.auth.models import User as DjangoUser, AnonymousUser as DjangoAnonymousUser\r
from django.db.models import Q\r
-from hashlib import md5\r
+try:\r
+ from hashlib import md5\r
+except:\r
+ import md5\r
import string\r
from random import Random\r
\r
\r
@property\r
def gravatar(self):\r
- return hashlib.md5(self.email).hexdigest()\r
+ return md5(self.email).hexdigest()\r
\r
def save(self, *args, **kwargs):\r
if self.reputation < 0:\r
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
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
- 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
+ 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_COMMENT_QUESTION, const.TYPE_ACTIVITY_COMMENT_ANSWER):\r
+ return self.content_object.leaf\r
+\r
+ if self.activity_type in (const.TYPE_ACTIVITY_UPDATE_ANSWER, const.TYPE_ACTIVITY_UPDATE_QUESTION):\r
+ return self.content_object.node.leaf \r
+ \r
+ raise NotImplementedError()\r
\r
@property\r
def type_as_string(self):\r
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