]> git.openstreetmap.org Git - osqa.git/commitdiff
fixes osqa-152: interesting and ignored tags work again. also fixed potential perfor...
authorqw3rty <qw3rty@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Tue, 27 Apr 2010 21:58:24 +0000 (21:58 +0000)
committerqw3rty <qw3rty@0cfe37f9-358a-4d5e-be75-b63607b5c754>
Tue, 27 Apr 2010 21:58:24 +0000 (21:58 +0000)
git-svn-id: http://svn.osqa.net/svnroot/osqa/trunk@80 0cfe37f9-358a-4d5e-be75-b63607b5c754

forum/skins/default/media/js/osqa.main.js
forum/skins/default/templates/ask.html
forum/skins/default/templates/question_retag.html
forum/urls.py
forum/views/commands.py
forum/views/readers.py
forum/views/writers.py

index e3726389178511360a33b8ba66cb93f815fb09ec..6264fb42ee6e4a4aca8b63de7bd2a0fa3056ea54 100644 (file)
@@ -400,17 +400,19 @@ function pickedTags(){
         init: function(){\r
             collectPickedTags();\r
             setupHideIgnoredQuestionsControl();\r
-            $("#interestingTagInput, #ignoredTagInput").autocomplete(tags, {\r
+            $("#interestingTagInput, #ignoredTagInput").autocomplete("/matching_tags", {\r
                 minChars: 1,\r
                 matchContains: true,\r
                 max: 20,\r
-                multiple: true,\r
-                multipleSeparator: " ",\r
-                formatItem: function(row, i, max) {\r
-                    return row.n + " ("+ row.c +")";\r
+                /*multiple: false, - the favorite tags and ignore tags don't let you do multiple tags\r
+                multipleSeparator: " "*/\r
+\r
+                formatItem: function(row, i, max, value) {\r
+                    return row[1].split(".")[0] + " (" + row[1].split(".")[1] + ")";\r
                 },\r
-                formatResult: function(row, i, max){\r
-                    return row.n;\r
+\r
+                formatResult: function(row, i, max, value){\r
+                    return row[0];\r
                 }\r
 \r
             });\r
@@ -421,7 +423,7 @@ function pickedTags(){
 }\r
 \r
 $(document).ready( function(){\r
-    if (window.tags != undefined)\r
+    //if (window.tags != undefined)\r
         pickedTags().init();\r
 });\r
 \r
index e681f4f32291edfc8e4ff05f147c11ea11254ab9..1f7d6c64626435bb534c8419a6631b38c80bd856 100644 (file)
                 $('#pre-collapse').text(txt);
             });
 
-            //Tags autocomplete action
-            var tags = {{ tags|safe }};
-               $("#id_tags").autocomplete(tags, {
+            // Tags autocomplete action
+               $("#id_tags").autocomplete("/matching_tags", {
                 minChars: 1,
                        matchContains: true,
                 max: 20,
                 multiple: true,
                 multipleSeparator: " ",
-                       formatItem: function(row, i, max) {
+                       /*formatItem: function(row, i, max) {
                                return row.n + " ("+ row.c +")";
                        },
                 formatResult: function(row, i, max){
                     return row.n;
+                }*/
+                formatItem: function(row, i, max, value) {
+                    return row[1].split(".")[0] + " (" + row[1].split(".")[1] + ")";
+                },
+
+                formatResult: function(row, i, max, value){
+                    return row[0];
                 }
 
             });
index 3e073e836e704be0a208011906958686bb62b4ef..04d96f347ec526bd48b56b1b25a201b3f597e5ab 100644 (file)
@@ -9,18 +9,24 @@
         $().ready(function(){
             $("#nav_questions").attr('className',"on");
             //Tags autocomplete action
-            var tags = {{ tags|safe }};
-               $("#id_tags").autocomplete(tags, {
+               $("#id_tags").autocomplete("/matching_tags", {
                 minChars: 1,
                        matchContains: true,
                 max: 20,
                 multiple: true,
                 multipleSeparator: " ",
-                       formatItem: function(row, i, max) {
+                       /*formatItem: function(row, i, max) {
                                return row.n + " ("+ row.c +")";
                        },
                 formatResult: function(row, i, max){
                     return row.n;
+                } */
+                formatItem: function(row, i, max, value) {
+                    return row[1].split(".")[0] + " (" + row[1].split(".")[1] + ")";
+                },
+
+                formatResult: function(row, i, max, value){
+                    return row[0];
                 }
                 
             });
index cb97329453c2bb0a869630dbfc9703ff86d72b74..e6a0eb8aa71b2646049def91c3c7819501348689 100644 (file)
@@ -68,7 +68,8 @@ urlpatterns += patterns('',
     url(r'^%s(?P<id>\d+)/' % _('flag/'), app.commands.flag_post, name='flag_post'),
     url(r'^%s(?P<id>\d+)/' % _('delete/'), app.commands.delete_post, name='delete_post'),
     url(r'^%s(?P<id>\d+)/$' % _('subscribe/'), app.commands.subscribe, name="subscribe"),
-
+    url(r'^%s' % _('matching_tags/'), app.commands.matching_tags, name='matching_tags'),
+    
     url(r'^%s(?P<id>\d+)/%s$' % (_('questions/'), _('revisions/')), app.readers.revisions, name='question_revisions'),
     url(r'^%s$' % _('command/'), app.commands.ajax_command, name='call_ajax'),
 
index ee62af4c6859f2acb5ffd8171bbe29e8d2ded383..5a76d06c2bcf00159cdde1190fe885287dc52b1c 100644 (file)
@@ -346,6 +346,17 @@ def mark_tag(request, tag=None, **kwargs):#tagging system
             ts.update(reason=reason)
     return HttpResponse(simplejson.dumps(''), mimetype="application/json")
 
+def matching_tags(request):
+    if len(request.GET['q']) == 0:
+       raise Exception(_("Invalid request"))
+
+    possible_tags = Tag.objects.filter(name__istartswith = request.GET['q'])
+    tag_output = ''
+    for tag in possible_tags:
+        tag_output += (tag.name + "|" + tag.name + "." + tag.used_count.__str__() + "\n")
+        
+    return HttpResponse(tag_output, mimetype="text/plain")
+
 @ajax_login_required
 def ajax_toggle_ignored_questions(request):#ajax tagging and tag-filtering system
     if request.user.hide_ignored_questions:
index 31efdcef52fb9be453de1f32592e612f3cb8ce64..385a4bee2c7e15b4aa0bedafceb7a80c50ae953e 100644 (file)
@@ -96,7 +96,7 @@ def question_list(request, initial, list_description=_('questions'), sort=None,
     return {
         "questions" : questions,
         "questions_count" : questions.count(),
-        "tags_autocomplete" : _get_tags_cache_json(),
+        #"tags_autocomplete" : _get_tags_cache_json(),
         "list_description": list_description,
         "base_path" : base_path,
         }
index 70be5eee420ae33f8a78aa034516a15da3e60516..e2143a8847de4bda214dd8d5bfdcaac875d8f9f3 100644 (file)
@@ -112,10 +112,10 @@ def ask(request):
     else:
         form = AskForm()
 
-    tags = _get_tags_cache_json()
+    #tags = _get_tags_cache_json()
     return render_to_response('ask.html', {
         'form' : form,
-        'tags' : tags,
+        #'tags' : tags,
         'email_validation_faq_url':reverse('faq') + '#validate',
         }, context_instance=RequestContext(request))
 
@@ -152,7 +152,7 @@ def _retag_question(request, question):
     return render_to_response('question_retag.html', {
         'question': question,
         'form' : form,
-        'tags' : _get_tags_cache_json(),
+        #'tags' : _get_tags_cache_json(),
     }, context_instance=RequestContext(request))
 
 def _edit_question(request, question):
@@ -192,7 +192,7 @@ def _edit_question(request, question):
         'question': question,
         'revision_form': revision_form,
         'form' : form,
-        'tags' : _get_tags_cache_json()
+        #'tags' : _get_tags_cache_json()
     }, context_instance=RequestContext(request))
 
 @login_required