Commits

Akash Sinha committed 110dd32

small change in contenttype filter (now items with unknown mime types have a different filter, as earlier it was shown regardless of the filter selected)

  • Participants
  • Parent commits 373f2e9

Comments (0)

Files changed (3)

File MoinMoin/apps/frontend/views.py

     audio_items = Boolean.using(label=L_('audio'), optional=True, default=1)
     video_items = Boolean.using(label=L_('video'), optional=True, default=1)
     other_items = Boolean.using(label=L_('other'), optional=True, default=1)
+    unknown_items = Boolean.using(label=L_('unknown'), optional=True, default=1)
     submit = String.using(default=L_('Filter'), optional=True)
 
 

File MoinMoin/items/__init__.py

         else:
             selected_contenttypes = all_contenttypes
 
+        unknown_item_group = "unknown items"
         if startswith:
             startswith = (u'%s' % startswith, u'%s' % startswith.swapcase())
-            index = [(fullname, relname, contenttype)
-                     for fullname, relname, contenttype in index
-                     if u'/' not in relname
-                     and relname.startswith(startswith)
-                     and (contenttype not in all_contenttypes or contenttype in selected_contenttypes)]
-                     # If an item's contenttype not present in the default contenttype list,
-                     # then it will be shown without going through any filter.
+            if not selected_groups or  unknown_item_group in selected_groups:
+                index = [(fullname, relname, contenttype)
+                         for fullname, relname, contenttype in index
+                         if u'/' not in relname
+                         and relname.startswith(startswith)
+                         and (contenttype not in all_contenttypes or contenttype in selected_contenttypes)]
+                         # If an item's contenttype not present in the default contenttype list,
+                         # then it will be shown without going through any filter.
+            else:
+                index = [(fullname, relname, contenttype)
+                         for fullname, relname, contenttype in index
+                         if u'/' not in relname
+                         and relname.startswith(startswith)
+                         and (contenttype in selected_contenttypes)]
+
         else:
-            index = [(fullname, relname, contenttype)
-                     for fullname, relname, contenttype in index
-                     if u'/' not in relname
-                     and (contenttype not in all_contenttypes or contenttype in selected_contenttypes)]
+            if not selected_groups or unknown_item_group in selected_groups:
+                index = [(fullname, relname, contenttype)
+                         for fullname, relname, contenttype in index
+                         if u'/' not in relname
+                         and (contenttype not in all_contenttypes or contenttype in selected_contenttypes)]
+            else:
+                index = [(fullname, relname, contenttype)
+                         for fullname, relname, contenttype in index
+                         if u'/' not in relname
+                         and contenttype in selected_contenttypes]
 
         return index
 

File MoinMoin/templates/index.html

     <div class="moin-select-contenttypes">
         <div class="moin-contenttypes-wrapper">
             <div class="ct-hide">{{ _("Filter by content type") }}</div>
+            {% set unknown_items_label = _("items having unknown mime types") %}
             {{ gen.form.open(form, method="post", action=url_for('frontend.index', item_name=item_name)) }}
             <ul>
                 {{ forms.render_filter_field(gen, form['markup_text_items'], 'checkbox', contenttype_groups['markup text items']) }}
                 {{ forms.render_filter_field(gen, form['audio_items'], 'checkbox', contenttype_groups['audio items']) }}
                 {{ forms.render_filter_field(gen, form['video_items'], 'checkbox', contenttype_groups['video items']) }}
                 {{ forms.render_filter_field(gen, form['other_items'], 'checkbox', contenttype_groups['other items']) }}
+                {{ forms.render_filter_field(gen, form['unknown_items'], 'checkbox', unknown_items_label) }}
                 {{ gen.input(form['submit'], type='submit') }}
             </ul>
             {{ gen.form.close() }}