##// END OF EJS Templates
Show attachment alias if it has one
neko259 -
r1912:6d13074b default
parent child Browse files
Show More
@@ -120,7 +120,8 b' class Attachment(models.Model):'
120 if file_viewer is None:
120 if file_viewer is None:
121 file_viewer = AbstractViewer
121 file_viewer = AbstractViewer
122
122
123 return file_viewer(self.file, self.mimetype, self.hash, self.url).get_view()
123 return file_viewer(self.file, self.mimetype, self.hash, self.url,
124 self.alias).get_view()
124
125
125 def __str__(self):
126 def __str__(self):
126 return self.url or self.file.url
127 return self.url or self.file.url
@@ -56,7 +56,7 b" CSS_CLASS_THUMB = 'thumb'"
56
56
57 ABSTRACT_VIEW = '<div class="image">'\
57 ABSTRACT_VIEW = '<div class="image">'\
58 '{}'\
58 '{}'\
59 '<div class="image-metadata"><a href="{}" download >{}, {}</a>'\
59 '<div class="image-metadata">{}<a href="{}" download >{}, {}</a>'\
60 ' <a class="file-menu" href="#" data-type="{}" data-search-url="{}" data-filename="{}">πŸ” </a></div>'\
60 ' <a class="file-menu" href="#" data-type="{}" data-search-url="{}" data-filename="{}">πŸ” </a></div>'\
61 '</div>'
61 '</div>'
62 URL_VIEW = '<div class="image">' \
62 URL_VIEW = '<div class="image">' \
@@ -100,12 +100,13 b' def file_exists(filename):'
100
100
101
101
102 class AbstractViewer:
102 class AbstractViewer:
103 def __init__(self, file, file_type, hash, url):
103 def __init__(self, file, file_type, hash, url, alias):
104 self.file = file
104 self.file = file
105 self.file_type = file_type
105 self.file_type = file_type
106 self.hash = hash
106 self.hash = hash
107 self.url = url
107 self.url = url
108 self.extension = get_extension(self.file.name)
108 self.extension = get_extension(self.file.name)
109 self.alias = alias
109
110
110 @staticmethod
111 @staticmethod
111 def supports(file_type):
112 def supports(file_type):
@@ -120,7 +121,9 b' class AbstractViewer:'
120 else:
121 else:
121 search_url = ''
122 search_url = ''
122
123
123 return ABSTRACT_VIEW.format(self.get_format_view(), self.file.url,
124 alias = self.alias + '<br />' if self.alias else ''
125
126 return ABSTRACT_VIEW.format(self.get_format_view(), alias, self.file.url,
124 self.file_type, filesizeformat(self.file.size),
127 self.file_type, filesizeformat(self.file.size),
125 self.file_type, search_url, self.file.name)
128 self.file_type, search_url, self.file.name)
126
129
General Comments 0
You need to be logged in to leave comments. Login now