summaryrefslogtreecommitdiff
path: root/service/pixelated
diff options
context:
space:
mode:
authorFolker Bernitt <fbernitt@thoughtworks.com>2014-10-09 10:49:40 +0200
committerFolker Bernitt <fbernitt@thoughtworks.com>2014-10-09 10:49:40 +0200
commitba8024b667a4ca16305e3b8c6fe566ba328a488d (patch)
tree508cf331572ddfd75d3e4c40808a031e492c99e4 /service/pixelated
parentc77b5aeb93fb61c2ec67d89f7a1266418fff5a9a (diff)
Skip default tags for tag suggestions.
- Fixup for issue #52
Diffstat (limited to 'service/pixelated')
-rw-r--r--service/pixelated/adapter/tag_service.py3
-rw-r--r--service/pixelated/user_agent.py9
2 files changed, 10 insertions, 2 deletions
diff --git a/service/pixelated/adapter/tag_service.py b/service/pixelated/adapter/tag_service.py
index 874a9a58..f128f1bb 100644
--- a/service/pixelated/adapter/tag_service.py
+++ b/service/pixelated/adapter/tag_service.py
@@ -59,3 +59,6 @@ class TagService:
def all_tags(self):
return self.tag_index.values().union(self.SPECIAL_TAGS)
+
+ def all_custom_tags(self):
+ return self.tag_index.values().difference(self.SPECIAL_TAGS)
diff --git a/service/pixelated/user_agent.py b/service/pixelated/user_agent.py
index 12b9a97a..03372f23 100644
--- a/service/pixelated/user_agent.py
+++ b/service/pixelated/user_agent.py
@@ -124,12 +124,17 @@ def delete_mails():
@app.route('/tags')
def tags():
+ tag_service = mail_service.tag_service
+
query = request.args.get('q')
+ skipDefaultTags = request.args.get('skipDefaultTags')
+
+ all_tags = tag_service.all_custom_tags() if skipDefaultTags else tag_service.all_tags()
if query:
- tags = [tag for tag in mail_service.all_tags() if bool(re.match(query, tag.name, re.IGNORECASE))]
+ tags = [tag for tag in all_tags if bool(re.match(query, tag.name, re.IGNORECASE))]
else:
- tags = mail_service.all_tags()
+ tags = all_tags
return respond_json([tag.as_dict() for tag in tags])