summaryrefslogtreecommitdiffstats
path: root/askbot/models/__init__.py
diff options
context:
space:
mode:
authorEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-05-27 02:24:30 -0400
committerEvgeny Fadeev <evgeny.fadeev@gmail.com>2013-05-27 02:24:30 -0400
commite854ce21858964f5f85e4901c6fc56bd7aa4639b (patch)
treef1d93e80bd0e53f32f2408fc3b8d20f550493391 /askbot/models/__init__.py
parent45217999234bd2cbceda7c114c7526979883fa47 (diff)
downloadaskbot-e854ce21858964f5f85e4901c6fc56bd7aa4639b.tar.gz
askbot-e854ce21858964f5f85e4901c6fc56bd7aa4639b.tar.bz2
askbot-e854ce21858964f5f85e4901c6fc56bd7aa4639b.zip
merged the "subscribe" checkbox with "follow" button functionally
Diffstat (limited to 'askbot/models/__init__.py')
-rw-r--r--askbot/models/__init__.py14
1 files changed, 14 insertions, 0 deletions
diff --git a/askbot/models/__init__.py b/askbot/models/__init__.py
index 325f06d6..78a68487 100644
--- a/askbot/models/__init__.py
+++ b/askbot/models/__init__.py
@@ -2532,12 +2532,21 @@ def toggle_favorite_question(
about processing the "cancel" option
another strange thing is that this function unlike others below
returns a value
+
+ todo: the on-screen follow and email subscription is not
+ fully merged yet - see use of FavoriteQuestion and follow/unfollow question
+ btw, names of the objects/methods is quite misleading ATM
"""
try:
+ #this attempts to remove the on-screen follow
fave = FavoriteQuestion.objects.get(thread=question.thread, user=self)
fave.delete()
result = False
question.thread.update_favorite_count()
+ #this removes email subscription
+ if question.thread.is_followed_by(self):
+ self.unfollow_question(question)
+
except FavoriteQuestion.DoesNotExist:
if timestamp is None:
timestamp = datetime.datetime.now()
@@ -2547,6 +2556,11 @@ def toggle_favorite_question(
added_at = timestamp,
)
fave.save()
+
+ #this removes email subscription
+ if question.thread.is_followed_by(self) is False:
+ self.follow_question(question)
+
result = True
question.thread.update_favorite_count()
award_badges_signal.send(None,