summaryrefslogtreecommitdiffstats
path: root/askbot/models/question.py
diff options
context:
space:
mode:
authorAdolfo Fitoria <adolfo.fitoria@gmail.com>2013-06-05 09:06:51 -0600
committerAdolfo Fitoria <adolfo.fitoria@gmail.com>2013-06-05 09:06:51 -0600
commit7f319d67eecf2295829c3e97ce04bf29a7da437e (patch)
tree18d1ac073b35874c8c4b576ee8c1659fe5282f22 /askbot/models/question.py
parent3cbe22172952c2d43160aac6f2eeb9d2af7a6ebd (diff)
parent27772070e816f979e3d6d6d101e98c7258bfdb65 (diff)
downloadaskbot-7f319d67eecf2295829c3e97ce04bf29a7da437e.tar.gz
askbot-7f319d67eecf2295829c3e97ce04bf29a7da437e.tar.bz2
askbot-7f319d67eecf2295829c3e97ce04bf29a7da437e.zip
Merge branch 'master' of github.com:ASKBOT/askbot-devel into solrmultilang
Diffstat (limited to 'askbot/models/question.py')
-rw-r--r--askbot/models/question.py17
1 files changed, 15 insertions, 2 deletions
diff --git a/askbot/models/question.py b/askbot/models/question.py
index ed30c5f5..0f4c4a85 100644
--- a/askbot/models/question.py
+++ b/askbot/models/question.py
@@ -19,7 +19,7 @@ import askbot
from askbot.conf import settings as askbot_settings
from askbot import mail
from askbot.mail import messages
-from askbot.models.tag import Tag
+from askbot.models.tag import Tag, TagSynonym
from askbot.models.tag import get_tags_by_names
from askbot.models.tag import filter_accepted_tags, filter_suggested_tags
from askbot.models.tag import separate_unused_tags
@@ -1264,6 +1264,8 @@ class Thread(models.Model):
Tag use counts are recalculated
A signal tags updated is sent
+ TagSynonym is used to replace tag names
+
*IMPORTANT*: self._question_post() has to
exist when update_tags() is called!
"""
@@ -1273,9 +1275,20 @@ class Thread(models.Model):
previous_tags = list(self.tags.filter(status = Tag.STATUS_ACCEPTED))
ordered_updated_tagnames = [t for t in tagnames.strip().split(' ')]
+ updated_tagnames_tmp = set(ordered_updated_tagnames)
+
+ #apply TagSynonym
+ updated_tagnames = set()
+ for tag_name in updated_tagnames_tmp:
+ try:
+ tag_synonym = TagSynonym.objects.get(source_tag_name=tag_name)
+ updated_tagnames.add(tag_synonym.target_tag_name)
+ tag_synonym.auto_rename_count += 1
+ tag_synonym.save()
+ except TagSynonym.DoesNotExist:
+ updated_tagnames.add(tag_name)
previous_tagnames = set([tag.name for tag in previous_tags])
- updated_tagnames = set(ordered_updated_tagnames)
removed_tagnames = previous_tagnames - updated_tagnames
#remove tags from the question's tags many2many relation