changeset 2657:080673c3e60a

Now nameless items can also be downloaded and removed unnecessary blank spaces in items/content.py
author Saurabh Kathpalia <saurabh.kathpalia95@gmail.com>
date Sun, 06 Jul 2014 09:25:31 +0530
parents c05ad337ac22
children a22b4979caa2
files MoinMoin/items/content.py MoinMoin/templates/ticket/base.html MoinMoin/util/interwiki.py
diffstat 3 files changed, 14 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/items/content.py	Fri Jul 04 16:20:40 2014 +0530
+++ b/MoinMoin/items/content.py	Sun Jul 06 09:25:31 2014 +0530
@@ -64,6 +64,7 @@
 from MoinMoin.util.diff_html import diff as html_diff
 from MoinMoin.util.crypto import cache_key
 from MoinMoin.util.clock import timed
+from MoinMoin.util.interwiki import get_download_file_name
 from MoinMoin.forms import File
 from MoinMoin.constants.contenttypes import (
     GROUP_MARKUP_TEXT, GROUP_OTHER_TEXT, GROUP_IMAGE, GROUP_AUDIO, GROUP_VIDEO,
@@ -384,7 +385,7 @@
             force_attachment = True
         else:  # content = item revision
             rev = self.rev
-            filename = rev.item.name
+            filename = get_download_file_name(rev.item.fqname)
             try:
                 mimestr = rev.meta[CONTENTTYPE]
             except KeyError:
--- a/MoinMoin/templates/ticket/base.html	Fri Jul 04 16:20:40 2014 +0530
+++ b/MoinMoin/templates/ticket/base.html	Sun Jul 06 09:25:31 2014 +0530
@@ -49,7 +49,7 @@
             </div>
             <div id="user-actions" class="hidden">
                 <a href="{{ url_for('frontend.quicklink_item', item_name=item.fqname) }}" class="list-group-item" rel="nofollow" title="Create or remove a navigation link to this item">
-                    <i class="icon-star-empty icon-fixed-width"> </i>
+                    <i class="icon-star-empty icon-fixed-width"></i>
                     {%- if user.is_quicklinked_to([item.fqname]) %}
                         {{ _('Remove Link') }}
                     {%- else %}
@@ -57,7 +57,7 @@
                     {%- endif %}
                 </a>
                 <a href="{{ url_for('frontend.subscribe_item', item_name=item.fqname) }}" class="list-group-item" rel="nofollow" title="witch notifications about item changes on or off">
-                    <i class="icon-envelope icon-fixed-width"> </i>
+                    <i class="icon-envelope icon-fixed-width"></i>
                     {%- if user.is_subscribed_to(item) %}
                         {{ _('Unsubscribe') }}
                     {%- else %}
--- a/MoinMoin/util/interwiki.py	Fri Jul 04 16:20:40 2014 +0530
+++ b/MoinMoin/util/interwiki.py	Sun Jul 06 09:25:31 2014 +0530
@@ -107,6 +107,16 @@
     return url
 
 
+def get_download_file_name(fqname):
+    """
+    returns the filename that is used for downloading items
+    """
+    if fqname.field == NAME_EXACT:
+        return fqname.value
+    else:
+        return '{0}-{1}'.format(fqname.field, fqname.value)
+
+
 def _split_namespace(namespaces, url):
     """
     Find the longest namespace in the set.