summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--forum/const.py8
-rw-r--r--forum/forms.py1
-rw-r--r--forum/management/commands/send_email_alerts.py1
-rwxr-xr-xforum/models/__init__.py42
-rwxr-xr-xforum/models/repute.py4
-rwxr-xr-xforum/models/user.py2
-rw-r--r--forum/skins/default/templates/questions.html2
-rw-r--r--forum/utils/cache.py2
-rw-r--r--locale/en/LC_MESSAGES/django.mobin26986 -> 27289 bytes
-rw-r--r--locale/en/LC_MESSAGES/django.po22
10 files changed, 71 insertions, 13 deletions
diff --git a/forum/const.py b/forum/const.py
index 76fd4a24..ce81acb2 100644
--- a/forum/const.py
+++ b/forum/const.py
@@ -75,10 +75,10 @@ TYPE_ACTIVITY = (
)
TYPE_RESPONSE = {
- 'QUESTION_ANSWERED' : 'question_answered',
- 'QUESTION_COMMENTED': 'question_commented',
- 'ANSWER_COMMENTED' : 'answer_commented',
- 'ANSWER_ACCEPTED' : 'answer_accepted',
+ 'QUESTION_ANSWERED' : _('question_answered'),
+ 'QUESTION_COMMENTED': _('question_commented'),
+ 'ANSWER_COMMENTED' : _('answer_commented'),
+ 'ANSWER_ACCEPTED' : _('answer_accepted'),
}
CONST = {
diff --git a/forum/forms.py b/forum/forms.py
index f22763f7..08ce8738 100644
--- a/forum/forms.py
+++ b/forum/forms.py
@@ -8,6 +8,7 @@ from django.contrib.auth.models import User
from forum.utils.forms import NextUrlField, UserNameField
from recaptcha_django import ReCaptchaField
from django.conf import settings
+from django.contrib.contenttypes.models import ContentType
import logging
class TitleField(forms.CharField):
diff --git a/forum/management/commands/send_email_alerts.py b/forum/management/commands/send_email_alerts.py
index ab318e50..c476e9c9 100644
--- a/forum/management/commands/send_email_alerts.py
+++ b/forum/management/commands/send_email_alerts.py
@@ -10,6 +10,7 @@ import datetime
from django.conf import settings
import logging
from forum.utils.odict import OrderedDict
+from django.contrib.contenttypes.models import ContentType
class Command(NoArgsCommand):
def handle_noargs(self,**options):
diff --git a/forum/models/__init__.py b/forum/models/__init__.py
index 9b504103..56d5a4e5 100755
--- a/forum/models/__init__.py
+++ b/forum/models/__init__.py
@@ -4,6 +4,7 @@ from tag import Tag, MarkedTag
from meta import Vote, Comment, FlaggedItem
from user import Activity, AnonymousEmail, EmailFeedSetting
from repute import Badge, Award, Repute
+import re
from base import *
@@ -111,9 +112,39 @@ def record_ask_event(instance, created, **kwargs):
activity = Activity(user=instance.author, active_at=instance.added_at, content_object=instance, activity_type=TYPE_ACTIVITY_ASK_QUESTION)
activity.save()
+#todo: translate this
+record_answer_event_re = re.compile("You have received (a|\d+) .*new response.*")
def record_answer_event(instance, created, **kwargs):
if created:
- activity = Activity(user=instance.author, active_at=instance.added_at, content_object=instance, activity_type=TYPE_ACTIVITY_ANSWER)
+ q_author = instance.question.author
+ found_match = False
+ print 'going through %d messages' % q_author.message_set.all().count()
+ for m in q_author.message_set.all():
+ print m.message
+ match = record_answer_event_re.search(m.message)
+ if match:
+ found_match = True
+ try:
+ cnt = int(match.group(1))
+ except:
+ cnt = 1
+ m.message = u"You have received %d <a href=\"%s?sort=responses\">new responses</a>."\
+ % (cnt+1, q_author.get_profile_url())
+ print 'updated message'
+ print m.message
+ m.save()
+ break
+ if not found_match:
+ msg = u"You have received a <a href=\"%s?sort=responses\">new response</a>."\
+ % q_author.get_profile_url()
+ print 'new message'
+ print msg
+ q_author.message_set.create(message=msg)
+
+ activity = Activity(user=instance.author, \
+ active_at=instance.added_at,\
+ content_object=instance, \
+ activity_type=TYPE_ACTIVITY_ANSWER)
activity.save()
def record_comment_event(instance, created, **kwargs):
@@ -165,7 +196,12 @@ def notify_award_message(instance, created, **kwargs):
"""
if created:
user = instance.user
- user.message_set.create(message=u"Congratulations, you have received a badge '%s'" % instance.badge.name)
+
+ msg = (u"Congratulations, you have received a badge '%s'. " \
+ + u"Check out <a href=\"%s\">your profile</a>.") \
+ % (instance.badge.name, user.get_profile_url())
+
+ user.message_set.create(message=message)
def record_answer_accepted(instance, created, **kwargs):
"""
@@ -338,4 +374,4 @@ from forum.modules import get_modules_script_classes
for k, v in get_modules_script_classes('models', models.Model).items():
if not k in __all__:
__all__.append(k)
- exec "%s = v" % k \ No newline at end of file
+ exec "%s = v" % k
diff --git a/forum/models/repute.py b/forum/models/repute.py
index 91ba0375..149f656f 100755
--- a/forum/models/repute.py
+++ b/forum/models/repute.py
@@ -1,4 +1,6 @@
from base import *
+from django.contrib.contenttypes.models import ContentType
+from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
@@ -106,4 +108,4 @@ class Repute(models.Model):
class Meta:
app_label = 'forum'
- db_table = u'repute' \ No newline at end of file
+ db_table = u'repute'
diff --git a/forum/models/user.py b/forum/models/user.py
index ac6cbc0d..fde1bbb0 100755
--- a/forum/models/user.py
+++ b/forum/models/user.py
@@ -1,4 +1,6 @@
from base import *
+from django.contrib.contenttypes.models import ContentType
+from django.contrib.auth.models import User
from django.utils.translation import ugettext as _
diff --git a/forum/skins/default/templates/questions.html b/forum/skins/default/templates/questions.html
index 4c3b96d2..c2d74eca 100644
--- a/forum/skins/default/templates/questions.html
+++ b/forum/skins/default/templates/questions.html
@@ -189,7 +189,7 @@
{% endblocktrans %}
{% else %}
{% blocktrans count questions as cnt with questions_count|intcomma as q_num %}
- have total {{q_num}} questions
+ have total {{q_num}} question
{% plural %}
have total {{q_num}} questions
{% endblocktrans %}
diff --git a/forum/utils/cache.py b/forum/utils/cache.py
index 410c0662..6341392e 100644
--- a/forum/utils/cache.py
+++ b/forum/utils/cache.py
@@ -3,7 +3,7 @@ import itertools
from django.contrib.contenttypes.models import ContentType
-from lanai.utils.lists import flatten
+from forum.utils.lists import flatten
def fetch_model_dict(model, ids, fields=None):
"""
diff --git a/locale/en/LC_MESSAGES/django.mo b/locale/en/LC_MESSAGES/django.mo
index 20813cb3..385fe3c8 100644
--- a/locale/en/LC_MESSAGES/django.mo
+++ b/locale/en/LC_MESSAGES/django.mo
Binary files differ
diff --git a/locale/en/LC_MESSAGES/django.po b/locale/en/LC_MESSAGES/django.po
index 3f53e36d..50dbc597 100644
--- a/locale/en/LC_MESSAGES/django.po
+++ b/locale/en/LC_MESSAGES/django.po
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2010-02-22 22:59-0500\n"
+"POT-Creation-Date: 2010-02-28 21:53-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -362,6 +362,22 @@ msgstr ""
msgid "email update sent to user"
msgstr ""
+#: forum/const.py:78
+msgid "question_answered"
+msgstr "answer"
+
+#: forum/const.py:79
+msgid "question_commented"
+msgstr "question comment"
+
+#: forum/const.py:80
+msgid "answer_commented"
+msgstr "answer comment"
+
+#: forum/const.py:81
+msgid "answer_accepted"
+msgstr "answer accepted"
+
#: forum/const.py:85
msgid "[closed]"
msgstr ""
@@ -749,7 +765,7 @@ msgstr ""
#: forum/middleware/anon_user.py:33
#, python-format
msgid "first time greeting with %(url)s"
-msgstr ""
+msgstr "Hello and welcome to OSQA - <a href='%(url)s'>please join us</a>!"
#: forum/models/question.py:247
#, python-format
@@ -2401,7 +2417,7 @@ msgstr[1] ""
#, python-format
msgid ""
"\n"
-" have total %(q_num)s questions\n"
+" have total %(q_num)s question\n"
" "
msgid_plural ""
"\n"