manager: clearer semantics and interface for export (#45082)
CSV export is not called "export" anymore, and button is not in the same place as real JSON export.
This commit is contained in:
parent
0570842003
commit
621a5e978f
|
@ -34,7 +34,6 @@ class OrganizationalUnitView(views.BaseTableView):
|
|||
search_form_class = forms.NameSearchForm
|
||||
permissions = ['a2_rbac.search_organizationalunit']
|
||||
title = _('Organizational units')
|
||||
formats = ['json']
|
||||
|
||||
listing = OrganizationalUnitView.as_view()
|
||||
|
||||
|
|
|
@ -66,7 +66,6 @@ class RolesView(views.HideOUColumnMixin, RolesMixin, views.BaseTableView):
|
|||
search_form_class = forms.RoleSearchForm
|
||||
permissions = ['a2_rbac.search_role']
|
||||
title = _('Roles')
|
||||
formats = ['csv', 'json']
|
||||
|
||||
def get_queryset(self):
|
||||
qs = super(RolesView, self).get_queryset()
|
||||
|
|
|
@ -1,10 +1,2 @@
|
|||
{% load i18n %}
|
||||
<p id="export-formats">{% trans "Export" %} :
|
||||
{% for format in formats %}
|
||||
{% if object %}
|
||||
<a class="export-format" href="{% url export_view_name pk=object.pk format=format %}?{{ request.GET.urlencode }}">{{ format|upper }}</a>
|
||||
{% else %}
|
||||
<a class="export-format" href="{% url export_view_name format=format %}?{{ request.GET.urlencode }}">{{ format|upper }}</a>
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
</p>
|
||||
<p><a class="export-format" href="{% if object %}{% url export_view_name pk=object.pk format="csv" %}{% else %}{% url export_view_name format="csv" %}{% endif %}?{{ request.GET.urlencode }}">{% trans "Download list as CSV" %}</a></p>
|
||||
|
|
|
@ -10,9 +10,14 @@
|
|||
{% block appbar %}
|
||||
{{ block.super }}
|
||||
<span class="actions">
|
||||
<a class="extra-actions-menu-opener"></a>
|
||||
{% if view.can_add %}
|
||||
<a href="{% url "a2-manager-ou-add" %}" rel="popup">{% trans "Add organizational unit" %}</a>
|
||||
{% endif %}
|
||||
<ul class="extra-actions-menu">
|
||||
<li><a download href="{% url 'a2-manager-ou-export' format="json" %}?{{ request.GET.urlencode }}">{% trans 'Export' %}</a></li>
|
||||
</ul>
|
||||
</span>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
|
@ -26,5 +31,4 @@
|
|||
{% with row_link=1 %}
|
||||
{% render_table table "authentic2/manager/table.html" %}
|
||||
{% endwith %}
|
||||
{% include "authentic2/manager/export_include.html" with export_view_name="a2-manager-ou-export" %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -6,11 +6,15 @@
|
|||
{% block appbar %}
|
||||
{{ block.super }}
|
||||
<span class="actions">
|
||||
<a class="extra-actions-menu-opener"></a>
|
||||
{% if view.can_add %}
|
||||
<a href="{% url "a2-manager-role-add" %}" rel="popup">{% trans "Add role" %}</a>
|
||||
{% else %}
|
||||
<a href="#" class="disabled" rel="popup">{% trans "Add role" %}</a>
|
||||
{% endif %}
|
||||
<ul class="extra-actions-menu">
|
||||
<li><a download href="{% url 'a2-manager-roles-export' format="json" %}?{{ request.GET.urlencode }}">{% trans 'Export' %}</a></li>
|
||||
</ul>
|
||||
</span>
|
||||
{% endblock %}
|
||||
|
||||
|
|
|
@ -386,7 +386,7 @@ class ExportMixin(object):
|
|||
|
||||
def export_response(self, content, content_type, export_format):
|
||||
response = HttpResponse(content, content_type=content_type)
|
||||
filename = '%s%s.%s' % (self.get_export_prefix(), now().isoformat(),
|
||||
filename = '%s%s.%s' % (self.get_export_prefix(), now().strftime('%Y%m%d_%H%M%S'),
|
||||
export_format)
|
||||
response['Content-Disposition'] = 'attachment; filename="%s"' \
|
||||
% filename
|
||||
|
|
|
@ -19,7 +19,7 @@ from .utils import login
|
|||
def test_manager_ou_export(app, admin, ou1, role_ou1, ou2, role_ou2):
|
||||
response = login(app, admin, 'a2-manager-ous')
|
||||
|
||||
export_response = response.click('JSON')
|
||||
export_response = response.click('Export')
|
||||
export = export_response.json
|
||||
|
||||
assert list(export.keys()) == ['ous']
|
||||
|
@ -29,7 +29,7 @@ def test_manager_ou_export(app, admin, ou1, role_ou1, ou2, role_ou2):
|
|||
response.form.set('search-text', 'ou1')
|
||||
search_response = response.form.submit()
|
||||
|
||||
export_response = search_response.click('JSON')
|
||||
export_response = search_response.click('Export')
|
||||
export = export_response.json
|
||||
|
||||
assert len(export['ous']) == 1
|
||||
|
|
|
@ -27,7 +27,7 @@ def test_manager_role_export(app, admin, ou1, role_ou1, ou2, role_ou2):
|
|||
|
||||
response = login(app, admin, 'a2-manager-roles')
|
||||
|
||||
export_response = response.click('JSON')
|
||||
export_response = response.click('Export')
|
||||
export = export_response.json
|
||||
|
||||
assert list(export.keys()) == ['roles']
|
||||
|
@ -45,7 +45,7 @@ def test_manager_role_export(app, admin, ou1, role_ou1, ou2, role_ou2):
|
|||
response.form.set('search-text', 'role_ou1')
|
||||
search_response = response.form.submit()
|
||||
|
||||
export_response = search_response.click('JSON')
|
||||
export_response = search_response.click('Export')
|
||||
export = export_response.json
|
||||
|
||||
assert list(export.keys()) == ['roles']
|
||||
|
|
Loading…
Reference in New Issue