Skip to content

Commit 956f6bf

Browse files
committed
Only use new template for django >= 5.2
1 parent b7f0919 commit 956f6bf

File tree

3 files changed

+271
-2
lines changed

3 files changed

+271
-2
lines changed

filer/admin/folderadmin.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ class FolderAdmin(PrimitivePermissionAwareModelAdmin):
7171
actions = ['delete_files_or_folders', 'move_files_and_folders',
7272
'copy_files_and_folders', 'resize_images', 'rename_files']
7373

74-
directory_listing_template = 'admin/filer/folder/directory_listing.html'
74+
if DJANGO_VERSION >= (5, 2):
75+
directory_listing_template = 'admin/filer/folder/directory_listing.html'
76+
else: # Remove this when Django 5.2 is the minimum version
77+
directory_listing_template = 'admin/filer/folder/legacy_listing.html'
78+
7579
order_by_file_fields = ['_file_size', 'original_filename', 'name', 'owner',
7680
'uploaded_at', 'modified_at']
7781

Lines changed: 265 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,265 @@
1+
{% extends "admin/filer/base_site.html" %}
2+
{# Used for django < 5.2 with lagacy object-tools blocks #}
3+
{# Customized templates will need to be updated for django >= 5.2 #}
4+
{# The object-tools block has been renamed filer-tools for django >= 5.2 #}
5+
6+
{% load i18n static filer_admin_tags %}
7+
8+
{% block coltype %}{% endblock %}
9+
{% block bodyclass %}{{ block.super }} change-list filebrowser{% endblock %}
10+
11+
{% block extrastyle %}
12+
{{ block.super }}
13+
14+
{{ media.css }}
15+
{% if action_form %}
16+
{% url 'admin:jsi18n' as jsi18nurl %}
17+
<script type="text/javascript" src="{{ jsi18nurl|default:'../../jsi18n/' }}"></script>
18+
{% endif %}
19+
{% if query.pop %}
20+
<style type="text/css">
21+
#header {
22+
display: none;
23+
}
24+
</style>
25+
{% endif %}
26+
{% endblock %}
27+
28+
{% block breadcrumbs %}
29+
{% if not is_popup %}
30+
<div class="breadcrumbs">
31+
<a href="{% url 'admin:index' %}" title="{% trans 'Go back to admin homepage' %}">
32+
{% trans "Home" %}
33+
</a>
34+
&rsaquo;
35+
<a href="{% url 'admin:app_list' app_label='filer' %}" title="{% trans 'Go back to Filer app' %}">
36+
{% trans "Filer" %}
37+
</a>
38+
&rsaquo; <a href="{% url 'admin:filer-directory_listing-root' %}{% filer_admin_context_url_params %}" title="{% translate 'Go back to root folder' %}">{% translate "Folder" %}</a>
39+
{% for ancestor_folder in folder.logical_path %}
40+
&rsaquo;
41+
<a href="{{ ancestor_folder.get_admin_directory_listing_url_path }}{% filer_admin_context_url_params %}"
42+
title="{% blocktrans with ancestor_folder.name as folder_name %}Go back to '{{ folder_name }}' folder{% endblocktrans %}">
43+
{% if ancestor_folder.label %}{{ ancestor_folder.label }}{% else %}{{ ancestor_folder.name }}{% endif %}
44+
</a>
45+
{% endfor %}
46+
&rsaquo; {% if folder.label %}{{ folder.label }}{% else %}{{ folder.name }}{% endif %}
47+
{% if breadcrumbs_action %}
48+
&rsaquo;
49+
<a href="{{ folder.get_admin_directory_listing_url_path }}"
50+
title="{% blocktrans with folder.name as folder_name %}Go back to '{{ folder_name }}' folder{% endblocktrans %}">
51+
{% if folder.label %}
52+
{{ folder.label }}
53+
{% else %}
54+
{{ folder.name }}
55+
{% endif %}
56+
</a>
57+
&rsaquo;
58+
{{ breadcrumbs_action }}
59+
{% else %}
60+
{% if not instance.is_root and instance.is_smart_folder %}
61+
&rsaquo;
62+
{% endif %}
63+
{% if instance.label %}
64+
{{ instance.label }}
65+
{% else %}
66+
{{ instance.name }}
67+
{% endif %}
68+
{% endif %}
69+
</div>
70+
{% endif %}
71+
{% endblock %}
72+
73+
{% block sidebar %}{% endblock %}
74+
75+
{% block content_title %}
76+
<h2>&nbsp;</h2>
77+
{% endblock %}
78+
79+
{% block content %}
80+
<div class="navigator-top-nav clearfix">
81+
<div class="breadcrumbs-container-wrapper">
82+
<div class="breadcrumbs-container">
83+
<div class="breadcrumbs-container-inner">
84+
{% for ancestor_folder in instance.logical_path %}
85+
{{ ancestor_folder }}
86+
{% endfor %}
87+
88+
<div class="navigator-breadcrumbs">
89+
<div class="filer-navigator-breadcrumbs-dropdown-container filer-dropdown-container">
90+
<a href="#" data-toggle="filer-dropdown" aria-expanded="false">
91+
<img src="{% static 'filer/icons/folder-dropdown.svg' %}" alt="" width="28" height="28">
92+
</a>
93+
<ul class="filer-dropdown-menu navigator-breadcrumbs-dropdown">
94+
{% for folder in folder.logical_path reversed %}
95+
<li>
96+
<a href="{% url 'admin:filer-directory_listing' folder.id %}{% filer_admin_context_url_params %}"
97+
title="{% trans 'Go back to the parent folder' %}">
98+
<img src="{% static 'filer/icons/folder.svg' %}" alt="{% trans 'Folder Icon' %}" width="28" height="28">
99+
{{ folder.name }}
100+
</a>
101+
</li>
102+
{% endfor %}
103+
<li>
104+
<a href="{% url 'admin:filer-directory_listing-root' %}{% filer_admin_context_url_params %}"
105+
title="{% trans 'Go back to' %} {% trans 'root'|title %} {% trans 'folder' %}">
106+
<img src="{% static 'filer/icons/folder-root.svg' %}" alt="{% trans 'Folder Icon' %}" width="28" height="28">
107+
Root
108+
</a>
109+
</li>
110+
</ul>
111+
</div>
112+
{% if not folder.is_root or folder.is_smart_folder %}
113+
<span class="icon filer-icon filer-icon-chevron-right fa fa-chevron-right"></span>
114+
{% endif %}
115+
</div>
116+
<div class="navigator-breadcrumbs-name-dropdown-wrapper">
117+
{% if not folder.is_root or folder.is_smart_folder %}
118+
119+
<div class="navigator-breadcrumbs-folder-name-wrapper">
120+
<span class="navigator-breadcrumbs-folder-name">
121+
<span class="navigator-breadcrumbs-folder-name-inner">
122+
{{ folder.name }}
123+
</span>
124+
</span>
125+
</div>
126+
127+
<div class="filer-dropdown-container filer-dropdown-container-down">
128+
{% if not is_popup and folder.file_type == 'Folder' and permissions.has_edit_permission %}
129+
<a href="#" data-toggle="filer-dropdown" aria-expanded="false">
130+
<span class="filer-icon filer-icon-caret-down fa fa-caret-down"></span>
131+
</a>
132+
<ul class="filer-dropdown-menu">
133+
<li>
134+
<a href="{% url 'admin:filer_folder_change' folder.id %}{% filer_admin_context_url_params %}" title="{% trans 'Change current folder details' %}">{% trans "Change" %}</a>
135+
</li>
136+
</ul>
137+
{% endif %}
138+
</div>
139+
{% endif %}
140+
<div class="empty-filer-header-cell"></div>
141+
</div>
142+
<form class="filter-files-container js-filter-files-container" action="." method="get" class="js-filer-search-form">
143+
<div class="filter-filers-container-inner">
144+
<button class="navigator-button filter-files-button" title="{% trans 'Click here to run search for entered phrase' %}"><span class="icon fa fa-search cms-icon cms-icon-search"></span></button>
145+
<div class="filter-search-wrapper">
146+
{% filer_admin_context_hidden_formfields %}
147+
<input type="text" placeholder="{% trans 'Search' %}" class="filter-files-field js-filter-files" value="{{ search_string }}" name="q">
148+
<div class="filer-dropdown-container filer-dropdown-container-down">
149+
<a href="#" data-toggle="filer-dropdown" aria-expanded="false">
150+
<span class="filer-icon filer-icon-caret-down fa fa-caret-down"></span>
151+
</a>
152+
</div>
153+
<ul class="filer-dropdown-menu filer-dropdown-menu-checkboxes">
154+
<span class="fa fa-close cms-icon cms-icon-close js-close-dropdown-menu-checkboxes"><span class="sr-only">{% trans "Close" %}</span></span>
155+
<li>
156+
<p>{% trans "Limit" %}</p>
157+
<label>
158+
<input type="checkbox" id="limit_search_to_folder"
159+
name="limit_search_to_folder"
160+
{% if limit_search_to_folder %}checked="checked"{% endif %}
161+
title="{% trans 'Check it to limit the search to current folder' %}">
162+
{% trans "Limit the search to current folder" %}
163+
</label>
164+
</li>
165+
</ul>
166+
</div>
167+
</div>
168+
</form>
169+
</div>
170+
</div>
171+
<div class="tools-container">
172+
{% block object-tools %}
173+
<div class="navigator-tools">
174+
{% if not is_popup %}
175+
<div class="actions-wrapper">
176+
<ul class="actions-separated-list">
177+
<li>
178+
<a href="#" class="js-action-delete" title="{% trans 'Delete' %}"><span class="fa fa-trash cms-icon cms-icon-bin"></span></a>
179+
</li>
180+
<li>
181+
<a href="#" class="js-action-copy" title="{% trans 'Copy' %}"><span class="fa fa-copy cms-icon cms-icon-copy fa fa-copy"></span></a>
182+
</li>
183+
<li>
184+
<a href="#" class="js-action-move" title="{% trans 'Move' %}"><span class="fa fa-folder filer-icon filer-icon-move-to-folder fa fa-cut"></span></a>
185+
</li>
186+
</ul>
187+
<div class="filer-dropdown-container js-actions-menu">
188+
<a href="#" data-toggle="filer-dropdown" aria-expanded="false" class="nav-button nav-button-dots">
189+
<span class="fa fa-ellipsis-h cms-icon cms-icon-menu"></span>
190+
</a>
191+
<ul class="create-menu-dropdown filer-dropdown-menu">
192+
{# This list is populated in javascript #}
193+
</ul>
194+
</div>
195+
</div>
196+
{% endif %}
197+
<div class="filer-list-type-switcher-wrapper">
198+
<ul class="actions-separated-list">
199+
<li>{% filer_folder_list_type_switcher %}</li>
200+
</ul>
201+
</div>
202+
{% block object-tools-items %}
203+
<div class="navigator-button-wrapper">
204+
{% if folder.can_have_subfolders and can_make_folder %}
205+
<a href="{% url 'admin:filer-directory_listing-make_root_folder' %}?parent_id={{ folder.pk|safe }}{% if is_popup %}&amp;_popup=1{% endif %}"
206+
title="{% trans 'Adds a new Folder' %}"
207+
class="navigator-button"
208+
onclick="return showAddAnotherPopup(this);">
209+
{% trans "New Folder" %}
210+
</a>
211+
{% endif %}
212+
213+
{% if permissions.has_add_children_permission and not folder.is_root %}
214+
<a href="#" id="id_upload_button" title="{% trans 'Upload Files' %}"
215+
class="navigator-button navigator-button-upload js-upload-button"
216+
data-url="{% url 'admin:filer-ajax_upload' folder_id=folder.id %}"
217+
data-max-uploader-connections="{{ uploader_connections }}"
218+
data-max-files="{{ max_files|safe }}"
219+
{% if max_filesize %}data-max-filesize="{{ max_filesize|safe }}"{% endif %}
220+
>
221+
{% trans "Upload Files" %}
222+
</a>
223+
{% elif folder.is_unsorted_uploads %}
224+
<a href="#" id="id_upload_button" title="{% trans 'Upload Files' %}"
225+
class="navigator-button navigator-button-upload js-upload-button"
226+
data-url="{% url 'admin:filer-ajax_upload' %}"
227+
data-max-uploader-connections="{{ uploader_connections }}"
228+
data-max-files="{{ max_files|safe }}"
229+
{% if max_filesize %}data-max-filesize="{{ max_filesize|safe }}"{% endif %}
230+
>
231+
{% trans "Upload Files" %}
232+
</a>
233+
{% endif %}
234+
{% if folder.is_root and not folder.is_unsorted_uploads %}
235+
<span class="js-upload-button-disabled upload-button-disabled js-filer-tooltip filer-tooltip-wrapper"
236+
title="{% trans 'You have to select a folder first' %}">
237+
<a href="#" class="navigator-button navigator-button-upload" disabled>
238+
{% trans "Upload Files" %}
239+
</a>
240+
</span>
241+
{% endif %}
242+
</div>
243+
{% endblock %}
244+
</div>
245+
{% endblock %}
246+
</div>
247+
</div>
248+
</div>
249+
<div id="content-main">
250+
{% include "admin/filer/tools/search_form.html" %}
251+
<div class="js-navigator navigator{% if not actions_on_top and not actions_on_bottom %}navigator-no-actions{% endif %}">
252+
<form class="js-navigator-form" method="post" id="changelist-form">
253+
{% csrf_token %}
254+
{% filer_admin_context_hidden_formfields %}
255+
{% if action_form and actions_on_top and paginator.count and not is_popup %}
256+
{% filer_actions %}
257+
{% endif %}
258+
{% include list_type_template %}
259+
{% if action_form and actions_on_bottom and paginator.count and not is_popup %}
260+
{% filer_actions %}
261+
{% endif %}
262+
</form>
263+
</div>
264+
</div>
265+
{% endblock %}

tests/requirements/django-5.2.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
-r base.txt
22

3-
django>=5.2a1,<5.3
3+
django>=5.2,<5.3
44
django_polymorphic>=3.1

0 commit comments

Comments
 (0)