update translation
[redakcja.git] / apps / fileupload / templatetags / upload_tags.py
1 # -*- coding: utf-8 -*-
2 #
3 # This file is part of MIL/PEER, licensed under GNU Affero GPLv3 or later.
4 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 #
6 from django import template
7
8 register = template.Library()
9
10
11 @register.simple_tag
12 def upload_js():
13     return """
14 <!-- The template to display files available for upload -->
15 <script id="template-upload" type="text/x-tmpl">
16 {% for (var i=0, file; file=o.files[i]; i++) { %}
17     <tr class="template-upload fade">
18         <td class="preview"><span class="fade"></span></td>
19         <td class="name"><span>{%=file.name%}</span></td>
20         <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
21         {% if (file.error) { %}
22             <td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span>
23             {%=locale.fileupload.errors[file.error] || file.error%}</td>
24         {% } else if (o.files.valid && !i) { %}
25             <td>
26                 <div class="progress progress-success progress-striped active">
27                     <div class="bar" style="width:0%;"></div>
28                 </div>
29             </td>
30             <td class="start">{% if (!o.options.autoUpload) { %}
31                 <button class="btn btn-success">
32                     <i class="icon-upload icon-white"></i>
33                     <span>{%=locale.fileupload.start%}</span>
34                 </button>
35             {% } %}</td>
36         {% } else { %}
37             <td colspan="2"></td>
38         {% } %}
39         <td class="cancel">{% if (!i) { %}
40             <button class="btn btn-warning">
41                 <i class="icon-ban-circle icon-white"></i>
42                 <span>{%=locale.fileupload.cancel%}</span>
43             </button>
44         {% } %}</td>
45     </tr>
46 {% } %}
47 </script>
48 <!-- The template to display files available for download -->
49 <script id="template-download" type="text/x-tmpl">
50 {% for (var i=0, file; file=o.files[i]; i++) { %}
51     <tr class="template-download fade">
52         {% if (file.error) { %}
53             <td></td>
54             <td class="name"><span>{%=file.name%}</span></td>
55             <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
56             <td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span>
57             {%=locale.fileupload.errors[file.error] || file.error%}</td>
58         {% } else { %}
59             <td class="preview">{% if (file.thumbnail_url) { %}
60                 <a href="{%=file.url%}" title="{%=file.name%}" rel="gallery"
61                     download="{%=file.name%}"><img src="{%=file.thumbnail_url%}"></a>
62             {% } %}</td>
63             <td class="name">
64                 <a href="{%=file.url%}" title="{%=file.name%}" rel="{%=file.thumbnail_url&&'gallery'%}"
65                     download="{%=file.name%}">{%=file.name%}</a>
66             </td>
67             <td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
68             <td colspan="2"></td>
69         {% } %}
70         <td class="delete">
71             <button class="btn btn-danger" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
72                 <i class="icon-trash icon-white"></i>
73                 <span>{%=locale.fileupload.destroy%}</span>
74             </button>
75             <input type="checkbox" name="delete" value="1">
76         </td>
77     </tr>
78 {% } %}
79 </script>
80 """