# HG changeset patch # User grandjoncl # Date 1348046716 -7200 # Node ID a6af67d18fe80cd33a6bcecb49a334afd1920b69 # Parent 18dfa62b411a4162867aa8bafe421ee3e4f8fd63 Commit Louise-Thibaut : Correction _filter en filter dans content.py diff -r 18dfa62b411a -r a6af67d18fe8 src/ldt/ldt/ldt_utils/views/content.py --- a/src/ldt/ldt/ldt_utils/views/content.py Wed Sep 19 15:03:51 2012 +0900 +++ b/src/ldt/ldt/ldt_utils/views/content.py Wed Sep 19 11:25:16 2012 +0200 @@ -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): + if filter and len(filter) > 0 and filter[0] == '_': + filter = filter[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 or not + if filter and not tag_filter : + content_nb = Content.safe_objects.filter(title__icontains=filter).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)[(num_page*settings.LDT_MAX_CONTENTS_PER_PAGE):((num_page+1)*settings.LDT_MAX_CONTENTS_PER_PAGE)] #@UndefinedVariable + elif filter 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), '"'+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), '"'+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_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