change filter to filter_c to avoid name collision with the built-in filter fuction V01.21
authorymh <ymh.work@gmail.com>
Wed, 19 Sep 2012 22:57:07 +0900
changeset 786 623bc24bee49
parent 785 a6af67d18fe8
child 787 16e420b75336
change filter to filter_c to avoid name collision with the built-in filter fuction
src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/published_projects.html
src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/workspace_base.html
src/ldt/ldt/ldt_utils/urls.py
src/ldt/ldt/ldt_utils/views/content.py
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/published_projects.html	Wed Sep 19 11:25:16 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/published_projects.html	Wed Sep 19 22:57:07 2012 +0900
@@ -11,7 +11,7 @@
 {{block.super}}
 <script type="text/javascript">
 
-var content_filter_url = "{% url ldt.ldt_utils.views.content.contents_filter filter='__FILTER__' %}";
+var content_filter_url = "{% url ldt.ldt_utils.views.content.contents_filter filter_c='__FILTER__' %}";
 var project_filter_url = "{% url ldt.ldt_utils.views.project.projects_filter filter='__FILTER__' is_owner='false' status='2' %}";
 var publish_project_url = "{% url ldt.ldt_utils.views.project.publish '__PROJECT_ID__' %}";
 var unpublish_project_url = "{% url ldt.ldt_utils.views.project.unpublish '__PROJECT_ID__' %}";
--- a/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/workspace_base.html	Wed Sep 19 11:25:16 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/templates/ldt/ldt_utils/workspace_base.html	Wed Sep 19 22:57:07 2012 +0900
@@ -12,7 +12,7 @@
 {{block.super}}
 <script type="text/javascript">
 
-var content_filter_url = "{% url ldt.ldt_utils.views.content.contents_filter filter='__FILTER__' %}";
+var content_filter_url = "{% url ldt.ldt_utils.views.content.contents_filter filter_c='__FILTER__' %}";
 var project_filter_url = "{% url ldt.ldt_utils.views.project.projects_filter filter='__FILTER__' is_owner='true' status='0' %}";
 var publish_project_url = "{% url ldt.ldt_utils.views.project.publish '__PROJECT_ID__' %}";
 var unpublish_project_url = "{% url ldt.ldt_utils.views.project.unpublish '__PROJECT_ID__' %}";
--- a/src/ldt/ldt/ldt_utils/urls.py	Wed Sep 19 11:25:16 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/urls.py	Wed Sep 19 22:57:07 2012 +0900
@@ -30,7 +30,7 @@
     url(r'^workspace/?$', "views.workspace.home", name="root-view"),
     url(r'^filterprojects/_(?P<filter>[\w\%\_\-\+]*?)/(?P<is_owner>true|false)/(?P<status>\d)$', "views.project.projects_filter",),
     url(r'^filterprojects/_(?P<filter>[\w\%\_\-\+]*?)/(?P<is_owner>true|false)/(?P<status>\d)/(?P<id_group>.*)$', "views.project.projects_filter",),
-    url(r'^filtercontents/_(?P<filter>[\w\%\_\-\+]*?)/$', "views.content.contents_filter",),
+    url(r'^filtercontents/_(?P<filter_c>[\w\%\_\-\+]*?)/$', "views.content.contents_filter",),
     url(r'^filtergroups/_(?P<filter>[\w\%\_\-\+]*?)/$', "views.group.groups_filter",),
     url(r'filtershare/_(?P<filter>[\w\%\_\-\+]*?)/(?P<use_groups>true|false)$', "views.workspace.share_filter"),
     (r'^embedpopup/?$', "views.workspace.popup_embed"),
--- a/src/ldt/ldt/ldt_utils/views/content.py	Wed Sep 19 11:25:16 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/views/content.py	Wed Sep 19 22:57:07 2012 +0900
@@ -391,9 +391,9 @@
 
     
 @login_required
-def contents_filter(request, filter): 
-    if filter and len(filter) > 0 and filter[0] == '_':
-        filter = filter[1:]
+def contents_filter(request, filter_c): 
+    if filter_c and len(filter_c) > 0 and filter_c[0] == '_':
+        filter_c = filter_c[1:]
     
     num_page = 0
     if request.GET.has_key('num_page'):
@@ -402,17 +402,17 @@
     if request.GET.has_key('tag_filter'):
         tag_filter = request.GET["tag_filter"]
     
-    # We paginate the content list, in case of filter or not
-    if filter and not tag_filter :
-        content_nb = Content.safe_objects.filter(title__icontains=filter).count()
+    # We paginate the content list, in case of filter_c or not
+    if filter_c and not tag_filter :
+        content_nb = Content.safe_objects.filter(title__icontains=filter_c).count()
         nb_ct_pages = int(math.ceil(content_nb / settings.LDT_MAX_CONTENTS_PER_PAGE)) + 1
-        content_list = Content.safe_objects.filter(title__icontains=filter)[(num_page*settings.LDT_MAX_CONTENTS_PER_PAGE):((num_page+1)*settings.LDT_MAX_CONTENTS_PER_PAGE)] #@UndefinedVariable
-    elif filter and tag_filter :
+        content_list = Content.safe_objects.filter(title__icontains=filter_c)[(num_page*settings.LDT_MAX_CONTENTS_PER_PAGE):((num_page+1)*settings.LDT_MAX_CONTENTS_PER_PAGE)] #@UndefinedVariable
+    elif filter_c and tag_filter :
         #TaggedItem.objects.get_by_model(Content.objects.all(), '"'+tag_filter+'"')
-        content_nb = TaggedItem.objects.get_by_model(Content.safe_objects.filter(title__icontains=filter), '"'+tag_filter+'"').count()
+        content_nb = TaggedItem.objects.get_by_model(Content.safe_objects.filter(title__icontains=filter_c), '"'+tag_filter+'"').count()
         nb_ct_pages = int(math.ceil(content_nb / settings.LDT_MAX_CONTENTS_PER_PAGE)) + 1
-        content_list = TaggedItem.objects.get_by_model(Content.safe_objects.filter(title__icontains=filter), '"'+tag_filter+'"')[(num_page*settings.LDT_MAX_CONTENTS_PER_PAGE):((num_page+1)*settings.LDT_MAX_CONTENTS_PER_PAGE)] #@UndefinedVariable
-    elif tag_filter and not filter:
+        content_list = TaggedItem.objects.get_by_model(Content.safe_objects.filter(title__icontains=filter_c), '"'+tag_filter+'"')[(num_page*settings.LDT_MAX_CONTENTS_PER_PAGE):((num_page+1)*settings.LDT_MAX_CONTENTS_PER_PAGE)] #@UndefinedVariable
+    elif tag_filter and not filter_c:
         content_nb = TaggedItem.objects.get_by_model(Content.safe_objects.all(), '"'+tag_filter+'"').count()
         nb_ct_pages = int(math.ceil(content_nb / settings.LDT_MAX_CONTENTS_PER_PAGE)) +1
         content_list = TaggedItem.objects.get_by_model(Content.safe_objects.all(), '"'+tag_filter+'"')[(num_page*settings.LDT_MAX_CONTENTS_PER_PAGE):((num_page+1)*settings.LDT_MAX_CONTENTS_PER_PAGE)] #@UndefinedVariable