Permalink
Browse files

Fixed Tests,

Fixed tag-suggest in common.css
Fixed lazy initialization of tag names in tag_suggestions
  • Loading branch information...
1 parent 7c6d6eb commit 6655b5941190dfdb9a4396ef2278d3c23c95452a @nirshub nirshub committed Jan 23, 2014
Showing with 24 additions and 13 deletions.
  1. +1 −1 agendas/tests.py
  2. +21 −10 auxiliary/tag_suggestions/__init__.py
  3. +1 −1 auxiliary/tag_suggestions/tests.py
  4. +1 −1 static/css/common.css
View
@@ -88,7 +88,7 @@ def setUp(self):
reasoning="agenda bill 1")
self.committee_1 = Committee.objects.create(name='c1')
self.committee_1 = Committee.objects.create(name='c1')
- self.meeting_1 = self.committee_1.meetings.create(date=datetime.datetime.now(),
+ self.meeting_1 = self.committee_1.meetings.create(topics='My Meeting', date=datetime.datetime.now(),
protocol_text='''jacob:
I am a perfectionist
adrian:
@@ -32,17 +32,28 @@ def sum_add_two_dictionaries(dict, dict_to_add):
dict[key] = dict_to_add[key]
-# Extract only used tags, to avoid irrelevant tags
-vote_tags = Tag.objects.usage_for_model(Vote)
-bill_tags = Tag.objects.usage_for_model(Bill)
-cm_tags = Tag.objects.usage_for_model(CommitteeMeeting)
-all_tags = list(set(vote_tags).union(bill_tags).union(cm_tags))
-
-#A list of tags that have been tagged over 10 times in the website
-all_tags_names = [tag.name for tag in all_tags]
-
+
#A list of prefix charcters to use in tag extraction
prefixes = [u'ב', u'ו', u'ה', u'מ', u'מה', u'ל', u'']
+_all_tags_names = []
+
+def all_tags_names():
+ '''Lazy intialization of tags list'''
+
+ if (_all_tags_names == []):
+ # Extract only used tags, to avoid irrelevant tags
+ vote_tags = Tag.objects.usage_for_model(Vote)
+ bill_tags = Tag.objects.usage_for_model(Bill)
+ cm_tags = Tag.objects.usage_for_model(CommitteeMeeting)
+ all_tags = list(set(vote_tags).union(bill_tags).union(cm_tags))
+
+ #A list of tags that have been tagged over 10 times in the website
+ global _all_tags_names
+ _all_tags_names = [tag.name for tag in all_tags]
+
+ return _all_tags_names
+
+
def get_tags_in_text(text):
"""Returns a dictionary, the keys are tags found in text, and the values are the number of occurrences in text"""
@@ -51,7 +62,7 @@ def get_tags_in_text(text):
words = text.split()
#look for tag in word
- for tag in all_tags_names:
+ for tag in all_tags_names():
#create tag variations according to prefixes
tag_variations = [(p + tag) for p in prefixes]
@@ -65,7 +65,7 @@ def test_form(self):
class TestSuggestions(TestCase):
def setUp(self):
- auxiliary.tag_suggestions.all_tags_names = ['tag1']
+ auxiliary.tag_suggestions._all_tags_names = ['tag1']
def test_get_tags_in_text(self):
text = "tag1 ate the cat"
View
@@ -346,7 +346,7 @@ form > p > select { width:250px; }
}
-#content-main .tag-suggested .tag {
+#content-main .tag-suggested, .tag {
background-color:#C0C0C0;
border-bottom:1px solid #251C1F;
border-right:1px solid #251C1F;

0 comments on commit 6655b59

Please sign in to comment.