summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--askbot/search/state_manager.py8
-rw-r--r--askbot/tests/search_state_tests.py16
2 files changed, 23 insertions, 1 deletions
diff --git a/askbot/search/state_manager.py b/askbot/search/state_manager.py
index 232d64e9..ee46501e 100644
--- a/askbot/search/state_manager.py
+++ b/askbot/search/state_manager.py
@@ -117,7 +117,13 @@ class SearchState(object):
else:
self.sort = sort
- self.tags = [t.strip() for t in tags.split(const.TAG_SEP)] if tags else []
+ self.tags = []
+ if tags:
+ for t in tags.split(const.TAG_SEP):
+ tag = t.strip()
+ if tag not in self.tags:
+ self.tags.append(tag)
+
self.author = int(author) if author else None
self.page = int(page) if page else 1
if self.page == 0: # in case someone likes jokes :)
diff --git a/askbot/tests/search_state_tests.py b/askbot/tests/search_state_tests.py
index aca989fc..18f5eb36 100644
--- a/askbot/tests/search_state_tests.py
+++ b/askbot/tests/search_state_tests.py
@@ -275,3 +275,19 @@ class SearchStateTests(AskbotTestCase):
ss = SearchState.get_empty().add_tag('double').add_tag('double')
self.assertListEqual(['double'], ss.tags)
+ def test_prevent_dupped_tags(self):
+ ss = SearchState(
+ scope=None,
+ sort=None,
+ query=None,
+ tags='valid1,dupped,valid2,dupped',
+ author=None,
+ page=None,
+ user_logged_in=False
+ )
+ self.assertEqual(
+ 'scope:all/sort:activity-desc/tags:valid1,dupped,valid2/page:1/',
+ ss.query_string()
+ )
+
+