This repository has been archived by the owner on Aug 26, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 681
/
attachment_list.html
128 lines (120 loc) · 5.19 KB
/
attachment_list.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
{% set show_attach_button = allow_add_attachment_by(request.user) %}
{% set document_attachments = document.attached_files.all() %}
{% set attachments_given = document_attachments.count() > 0 %}
<section id="page-attachments" class="wiki-block">
<h3><i aria-hidden="true" class="icon-paperclip"></i>{{ _('Attachments') }} <a href="{{ wiki_url('Project:MDN/Contributing/Editor_guide/Editing#The_attachments_box') }}"><i aria-hidden="true" title="{{ _('Learn how to use Attachments') }}" class="icon-question-sign editor-help-icon"></i></a></h3>
{% if show_attach_button and attachment_form and attachments_given %}
<p class="add">
<button type="button" id="page-attachments-button" class="neutral">{{ _('Upload Files') }}<i aria-hidden="true" class="icon-paperclip"></i></button>
</p>
{% endif %}
<p class="{% if attachments_given %}hidden{% endif %}">
{{ _('This document has no attachments.') }}
{% if show_attach_button and attachment_form %}
{{ _('Images can be attached, and then linked in the article.') }}
{% if not attachments_given %}
<button id="page-attachments-button" class="neutral">{{ _('Upload Files') }}<i aria-hidden="true" class="icon-paperclip"></i></button>
{% endif %}
{% endif %}
</p>
<script>
mdn.wiki.attachments = [
{% for attachment in document_attachments -%}
{
"title": "{{ attachment.file.title | escapejs }}",
"description": "{{ attachment.file.current_revision.description | escapejs }}",
"mime": "{{ attachment.file.current_revision.mime_type | escapejs }}",
"url": "{{ attachment.file.get_file_url() | escapejs }}"
}{% if not loop.last %},{% endif %}
{%- endfor %}
];
mdn.wiki.attachments_enabled = {{ show_attach_button|jsonencode }};
</script>
{% if show_attach_button and attachment_form %}
<form method="post" action="{{ url('attachments.edit_attachment', document_path=document.slug, locale=document.locale) }}" id="page-attachments-form" enctype="multipart/form-data">
{% csrf_token %}
<table cellpadding="0" cellspacing="0" id="page-attachments-new-table" class="hidden">
<thead>
<th>{{ _('File') }}</th>
<th>{{ _('Title') }}</th>
<th>{{ _('Description') }}</th>
<th>{{ _('Comments') }}</th>
</thead>
<tbody>
<tr>
<td class="page-attachment-actions-file-cell">{{ attachment_form.file }}</td>
<td>{{ attachment_form.title }}</td>
<td>{{ attachment_form.description }}</td>
<td>{{ attachment_form.comment }}</td>
</tr>
<tr>
<td colspan="4">
<input type="submit" name="submit" value="Upload" />
</td>
</tr>
</tbody>
</table>
</form>
{% endif %}
{% for is_original, attachments in document_attachments|groupby('is_original')|reverse %}
<table cellpadding="0" cellspacing="0" class="page-attachments-table {% if not attachments_given %}hidden{% endif %}">
<caption>
{% if is_original %}
{{ _('Attached to this article') }}
{% else %}
{{ _('Attached to another article') }}
{% endif %}
</caption>
<thead>
<th>{{ _('File') }}</th>
<th>{{ _('Size') }}</th>
<th>{{ _('Last modified') }}</th>
<th>{{ _('Uploaded by') }}</th>
<th>
{% if is_original %}
{{ _('Linked in article') }}
{% else %}
{{ _('Article attached to') }}
{% endif %}
</th>
</thead>
<tbody>
{% for attachment in attachments %}
<tr data-revision-id="{{ attachment.file.current_revision.pk }}">
<td class="attachment-name-cell">
<a href="{{ attachment.file.get_file_url() }}" target="_blank">{{ attachment.file.title }}</a>
<div class="attachment-description">{{ attachment.file.current_revision.description }}</div>
</td>
<td>
{% if attachment.file.current_file_size %}
{{ attachment.file.current_file_size|filesizeformat }} ({{ _('%(bytes)s bytes', bytes=attachment.file.current_file_size) }})
{% else %}
{{ _('n/a') }}
{% endif %}
</td>
<td>{{ datetimeformat(attachment.file.modified, format='datetime') }}</td>
<td>
<a href="{{ attachment.file.current_revision.creator.get_absolute_url() }}">
{{ user_display(attachment.file.current_revision.creator) }}
</a>
</td>
<td>
{% if is_original %}
{{ attachment.is_linked|yesno }}
{% else %}
{% set other_document_attachments = attachment.file.document_attachments.exclude(document=attachment.document).distinct() %}
{% for document_attachment in other_document_attachments %}
<a href="{{ document_attachment.document.get_absolute_url() }}">
{{ document_attachment.document.title }} ({{ document_attachment.document.locale}})
</a>{% if not loop.last %}, {% endif %}
{% else %}
{{ _('n/a') }}
{% endfor %}
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endfor %}
</section>