diff options
author | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2013-01-14 15:57:03 -0300 |
---|---|---|
committer | Evgeny Fadeev <evgeny.fadeev@gmail.com> | 2013-01-14 15:57:03 -0300 |
commit | 4cda312624af2d4d8465a64299aa6ba3a852c973 (patch) | |
tree | 584f5b4ecbd90fcd109f9a358b6072bbdb7b9417 /askbot/models | |
parent | fc29ed609c9ee996673f8f0f92e9cc35a18e317f (diff) | |
download | askbot-4cda312624af2d4d8465a64299aa6ba3a852c973.tar.gz askbot-4cda312624af2d4d8465a64299aa6ba3a852c973.tar.bz2 askbot-4cda312624af2d4d8465a64299aa6ba3a852c973.zip |
added language selector to the user profiles and to the ask question for
Diffstat (limited to 'askbot/models')
-rw-r--r-- | askbot/models/__init__.py | 31 | ||||
-rw-r--r-- | askbot/models/post.py | 14 | ||||
-rw-r--r-- | askbot/models/question.py | 17 |
3 files changed, 42 insertions, 20 deletions
diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py index acc59568..1193ffbd 100644 --- a/askbot/models/__init__.py +++ b/askbot/models/__init__.py @@ -232,6 +232,11 @@ User.add_to_class( User.add_to_class('new_response_count', models.IntegerField(default=0)) User.add_to_class('seen_response_count', models.IntegerField(default=0)) User.add_to_class('consecutive_days_visit_count', models.IntegerField(default = 0)) +#list of languages for which user should receive email alerts +User.add_to_class( + 'languages', + models.CharField(max_length=128, default=django_settings.LANGUAGE_CODE) +) GRAVATAR_TEMPLATE = "//www.gravatar.com/avatar/%(gravatar)s?" + \ "s=%(size)d&d=%(type)s&r=PG" @@ -1624,7 +1629,8 @@ def user_post_question( group_id = None, timestamp = None, by_email = False, - email_address = None + email_address = None, + language = None ): """makes an assertion whether user can post the question then posts it and returns the question object""" @@ -1644,17 +1650,18 @@ def user_post_question( #todo: split this into "create thread" + "add question", if text exists #or maybe just add a blank question post anyway thread = Thread.objects.create_new( - author = self, - title = title, - text = body_text, - tagnames = tags, - added_at = timestamp, - wiki = wiki, - is_anonymous = is_anonymous, - is_private = is_private, - group_id = group_id, - by_email = by_email, - email_address = email_address + author=self, + title=title, + text=body_text, + tagnames=tags, + added_at=timestamp, + wiki=wiki, + is_anonymous=is_anonymous, + is_private=is_private, + group_id=group_id, + by_email=by_email, + email_address=email_address, + language=language ) question = thread._question_post() if question.author != self: diff --git a/askbot/models/post.py b/askbot/models/post.py index 041d1770..64b409d8 100644 --- a/askbot/models/post.py +++ b/askbot/models/post.py @@ -1267,7 +1267,19 @@ class Post(models.Model): #if askbot_settings.GROUPS_ENABLED and self.is_effectively_private(): # for subscriber in subscribers: - return self.filter_authorized_users(subscribers) + subscribers = self.filter_authorized_users(subscribers) + + #filter subscribers by language + if settings.ASKBOT_MULTILINGUAL: + language = self.thread.language_code + filtered_subscribers = list() + for subscriber in subscribers: + subscriber_languages = subscriber.languages.split() + if language in subscriber_languages: + filtered_subscribers.append(subscriber) + return filtered_subscribers + else: + return subscribers def get_notify_sets(self, mentioned_users=None, exclude_list=None): """returns three lists of users in a dictionary with keys: diff --git a/askbot/models/question.py b/askbot/models/question.py index e0521f69..d43ebf4c 100644 --- a/askbot/models/question.py +++ b/askbot/models/question.py @@ -113,16 +113,19 @@ class ThreadManager(BaseQuerySetManager): added_at, wiki, text, - tagnames = None, - is_anonymous = False, - is_private = False, - group_id = None, - by_email = False, - email_address = None + tagnames=None, + is_anonymous=False, + is_private=False, + group_id=None, + by_email=False, + email_address=None, + language=None, ): """creates new thread""" # TODO: Some of this code will go to Post.objects.create_new + language = language or get_language() + thread = super( ThreadManager, self @@ -131,7 +134,7 @@ class ThreadManager(BaseQuerySetManager): tagnames=tagnames, last_activity_at=added_at, last_activity_by=author, - language_code=get_language() + language_code=language ) #todo: code below looks like ``Post.objects.create_new()`` |