manager: move buttons and links in sidebar (#85941)

This commit is contained in:
Lauréline Guérin 2024-01-19 16:56:37 +01:00 committed by Lauréline Guérin
parent 068e5fe467
commit a4e5721dad
25 changed files with 168 additions and 75 deletions

View File

@ -941,3 +941,14 @@ ul.objects-list.single-links li.ants-setting-not-configured a.edit {
/* used for the city-edit link */
.icon-edit::before { content: "\f044"; }
a.button.button-paragraph {
text-align: left;
box-sizing: border-box;
display: block;
max-width: 100%;
margin-bottom: 1rem;
line-height: 150%;
padding-top: 0.8em;
padding-bottom: 0.8em;
}

View File

@ -16,14 +16,8 @@
</h2>
<span class="actions">
<a class="extra-actions-menu-opener"></a>
{% block agenda-extra-management-actions %}
{% endblock %}
<ul class="extra-actions-menu">
<li><a rel="popup" href="{% url 'chrono-manager-agenda-edit' pk=object.id %}">{% trans 'Options' %}</a></li>
{% block agenda-extra-menu-actions %}{% endblock %}
{% if user.is_staff %}
<li><a rel="popup" class="action-duplicate" href="{% url 'chrono-manager-agenda-duplicate' pk=object.pk %}">{% trans 'Duplicate' %}</a></li>
{% endif %}
<li><a download href="{% url 'chrono-manager-agenda-export' pk=object.id %}">{% trans 'Export Configuration (JSON)' %}</a></li>
{% if object.kind == 'events' %}
<li><a download href="{% url 'chrono-manager-agenda-export-events' pk=object.pk %}">{% trans 'Export Events (CSV)' %}</a></li>
@ -115,3 +109,17 @@
</div>
</div>
{% endblock %}
{% block sidebar %}
<aside id="sidebar">
<h3>{% trans "Actions" %}</h3>
{% block agenda-extra-management-actions %}{% endblock %}
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-agenda-edit' pk=object.id %}">{% trans 'Options' %}</a>
{% if user.is_staff %}
<a class="button button-paragraph" rel="popup" class="action-duplicate" href="{% url 'chrono-manager-agenda-duplicate' pk=object.pk %}">{% trans 'Duplicate' %}</a>
{% endif %}
{% block agenda-extra-navigation-actions %}{% endblock %}
</aside>
{% endblock %}

View File

@ -29,3 +29,6 @@
</div>
</form>
{% endblock %}
{% block sidebar %}
{% endblock %}

View File

@ -8,9 +8,6 @@
{% block appbar %}
<h2>{% trans 'Categories' %}</h2>
<span class="actions">
<a rel="popup" href="{% url 'chrono-manager-category-add' %}">{% trans 'New' %}</a>
</span>
{% endblock %}
@ -35,3 +32,10 @@
</div>
{% endif %}
{% endblock %}
{% block sidebar %}
<aside id="sidebar">
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-category-add' %}">{% trans 'New category' %}</a>
</aside>
{% endblock %}

View File

@ -29,3 +29,6 @@
{% include "gadjo/pagination.html" %}
</div>
{% endblock %}
{% block sidebar %}
{% endblock %}

View File

@ -2,13 +2,14 @@
{% load i18n %}
{% block agenda-extra-management-actions %}
<a rel="popup" href="{% url 'chrono-manager-agenda-import-events' pk=object.id %}">{% trans 'Import Events' %}</a>
<a rel="popup" href="{% url 'chrono-manager-agenda-add-event' pk=object.id %}">{% trans 'New Event' %}</a>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-agenda-import-events' pk=object.id %}">{% trans 'Import Events' %}</a>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-agenda-add-event' pk=object.id %}">{% trans 'New Event' %}</a>
{% endblock %}
{% block agenda-extra-menu-actions %}
{% block agenda-extra-navigation-actions %}
{% with lingo_url=object.get_lingo_url %}{% if lingo_url %}
<li><a href="{{ lingo_url }}">{% trans 'Pricing' context 'pricing' %}</a></li>
<h3>{% trans "Navigation" %}</h3>
<a class="button button-paragraph" href="{{ lingo_url }}">{% trans 'Pricing' context 'pricing' %}</a>
{% endif %}{% endwith %}
{% endblock %}

View File

@ -55,3 +55,6 @@
</div>
</form>
{% endblock %}
{% block sidebar %}
{% endblock %}

View File

@ -8,9 +8,6 @@
{% block appbar %}
<h2>{% trans 'Events types' %}</h2>
<span class="actions">
<a rel="popup" href="{% url 'chrono-manager-events-type-add' %}">{% trans 'New' %}</a>
</span>
{% endblock %}
{% block content %}
@ -37,3 +34,10 @@
</div>
{% endif %}
{% endblock %}
{% block sidebar %}
<aside id="sidebar">
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-events-type-add' %}">{% trans 'New events type' %}</a>
</aside>
{% endblock %}

View File

@ -3,34 +3,6 @@
{% block appbar %}
<h2>{% trans 'Agendas' %}</h2>
<span class="actions">
{% if user.is_staff or has_access_to_unavailability_calendars %}
<a class="extra-actions-menu-opener"></a>
<ul class="extra-actions-menu">
{% if user.is_staff %}
<li><a rel="popup" href="{% url 'chrono-manager-agendas-import' %}">{% trans 'Import' %}</a></li>
<li><a rel="popup" href="{% url 'chrono-manager-agendas-export' %}" data-autoclose-dialog="true">{% trans 'Export' %}</a></li>
<li><a href="{% url 'chrono-manager-events-type-list' %}">{% trans 'Events types' %}</a></li>
{% if shared_custody_enabled %}
<li><a rel="popup" href="{% url 'chrono-manager-shared-custody-settings' %}">{% trans 'Shared custody' %}</a></li>
{% endif %}
{% endif %}
{% if has_access_to_unavailability_calendars %}
<li><a href="{% url 'chrono-manager-unavailability-calendar-list' %}">{% trans 'Unavailability calendars' %}</a></li>
{% endif %}
{% if user.is_staff %}
<li><a href="{% url 'chrono-manager-resource-list' %}">{% trans 'Resources' %}</a></li>
{% endif %}
{% if ants_hub_enabled and user.is_staff %}
<li><a href="{% url 'chrono-manager-ants-hub' %}">{% trans 'ANTS Hub' %}</a></li>
{% endif %}
</ul>
{% endif %}
{% if user.is_staff %}
<a href="{% url 'chrono-manager-category-list' %}">{% trans 'Categories' %}</a>
<a rel="popup" href="{% url 'chrono-manager-agenda-add' %}">{% trans 'New' %}</a>
{% endif %}
</span>
{% endblock %}
{% block content %}
@ -57,3 +29,37 @@
{% endif %}
{% endblock %}
{% block sidebar %}
{% if with_sidebar %}
<aside id="sidebar">
{% if user.is_staff %}
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-agenda-add' %}">{% trans 'New agenda' %}</a>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-agendas-export' %}" data-autoclose-dialog="true">{% trans 'Export site' %}</a>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-agendas-import' %}">{% trans 'Import site' %}</a>
{% endif %}
{% if user.is_staff or has_access_to_unavailability_calendars %}
<h3>{% trans "Navigation" %}</h3>
{% if user.is_staff %}
<a class="button button-paragraph" href="{% url 'chrono-manager-category-list' %}">{% trans 'Categories' %}</a>
<a class="button button-paragraph" href="{% url 'chrono-manager-events-type-list' %}">{% trans 'Events types' %}</a>
{% if shared_custody_enabled %}
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-shared-custody-settings' %}">{% trans 'Shared custody' %}</a>
{% endif %}
{% endif %}
{% if has_access_to_unavailability_calendars %}
<a class="button button-paragraph" href="{% url 'chrono-manager-unavailability-calendar-list' %}">{% trans 'Unavailability calendars' %}</a>
{% endif %}
{% if user.is_staff %}
<a class="button button-paragraph" href="{% url 'chrono-manager-resource-list' %}">{% trans 'Resources' %}</a>
{% if ants_hub_enabled %}
<a class="button button-paragraph" href="{% url 'chrono-manager-ants-hub' %}">{% trans 'ANTS Hub' %}</a>
{% endif %}
{% endif %}
{% endif %}
</aside>
{% endif %}
{% endblock %}

View File

@ -55,3 +55,6 @@
</div>
</form>
{% endblock %}
{% block sidebar %}
{% endblock %}

View File

@ -59,3 +59,6 @@
{% endfor %}
{% endblock %}
{% block sidebar %}
{% endblock %}

View File

@ -17,8 +17,10 @@
<span class="actions">
{% block appbar-extras %}
{% if request.user.is_staff %}
<a rel="popup" href="{% url 'chrono-manager-resource-edit' pk=resource.pk %}">{% trans 'Edit' %}</a>
<a rel="popup" href="{% url 'chrono-manager-resource-delete' pk=resource.pk %}">{% trans 'Delete' %}</a>
<a class="extra-actions-menu-opener"></a>
<ul class="extra-actions-menu">
<li><a rel="popup" href="{% url 'chrono-manager-resource-delete' pk=resource.pk %}">{% trans 'Delete' %}</a></li>
</ul>
{% endif %}
{% include "chrono/manager_resource_view_buttons_fragment.html" with no_today=True no_opened=True %}
{% endblock %}
@ -53,3 +55,12 @@
</div>
{% endblock %}
{% block sidebar %}
<aside id="sidebar">
{% if request.user.is_staff %}
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-resource-edit' pk=resource.pk %}">{% trans 'Edit' %}</a>
{% endif %}
</aside>
{% endblock %}

View File

@ -29,3 +29,6 @@
</div>
</form>
{% endblock %}
{% block sidebar %}
{% endblock %}

View File

@ -8,9 +8,6 @@
{% block appbar %}
<h2>{% trans 'Resources' %}</h2>
<span class="actions">
<a rel="popup" href="{% url 'chrono-manager-resource-add' %}">{% trans 'New' %}</a>
</span>
{% endblock %}
@ -34,3 +31,10 @@
</div>
{% endif %}
{% endblock %}
{% block sidebar %}
<aside id="sidebar">
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-resource-add' %}">{% trans 'New resource' %}</a>
</aside>
{% endblock %}

View File

@ -32,3 +32,6 @@
{% block content %}
{% include "chrono/manager_resource_week_timetable_fragment.html" %}
{% endblock %}
{% block sidebar %}
{% endblock %}

View File

@ -59,3 +59,6 @@
{% block content %}
{% include "chrono/manager_resource_week_timetable_fragment.html" %}
{% endblock %}
{% block sidebar %}
{% endblock %}

View File

@ -68,3 +68,6 @@
</script>
</form>
{% endblock %}
{% block sidebar %}
{% endblock %}

View File

@ -33,3 +33,6 @@
{% include "gadjo/pagination.html" %}
</div>
{% endblock %}
{% block sidebar %}
{% endblock %}

View File

@ -49,3 +49,6 @@
</div>
{% endblock %}
{% block sidebar %}
{% endblock %}

View File

@ -31,3 +31,6 @@
</div>
</form>
{% endblock %}
{% block sidebar %}
{% endblock %}

View File

@ -8,11 +8,6 @@
{% block appbar %}
<h2>{% trans 'Unavailability Calendars' %}</h2>
{% if user.is_staff %}
<span class="actions">
<a rel="popup" href="{% url 'chrono-manager-unavailability-calendar-add' %}">{% trans 'New' %}</a>
</span>
{% endif %}
{% endblock %}
@ -36,3 +31,12 @@
</div>
{% endif %}
{% endblock %}
{% block sidebar %}
<aside id="sidebar">
{% if user.is_staff %}
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-unavailability-calendar-add' %}">{% trans 'New unavailability calendar' %}</a>
{% endif %}
</aside>
{% endblock %}

View File

@ -11,16 +11,8 @@
</h2>
<span class="actions">
<a class="extra-actions-menu-opener"></a>
{% block agenda-extra-management-actions %}
<a rel="popup" href="{% url 'chrono-manager-unavailability-calendar-import-unavailabilities' pk=unavailability_calendar.id %}">{% trans 'Manage unavailabilities from ICS' %}</a>
<a rel="popup" href="{% url 'chrono-manager-unavailability-calendar-add-unavailability' pk=unavailability_calendar.id %}">{% trans 'Add Unavailability' %}</a>
{% endblock %}
<ul class="extra-actions-menu">
<li><a rel="popup" href="{% url 'chrono-manager-unavailability-calendar-edit' pk=unavailability_calendar.id %}">{% trans 'Options' %}</a></li>
<li><a download href="{% url 'chrono-manager-unavailability-calendar-export' pk=unavailability_calendar.id %}">{% trans 'Export Configuration (JSON)' %}</a></li>
{% if user.is_staff %}
<li><a rel="popup" href="{% url 'chrono-manager-unavailability-calendar-delete' pk=unavailability_calendar.id %}">{% trans 'Delete' %}</a></li>
{% endif %}
</ul>
</span>
{% endblock %}
@ -50,5 +42,16 @@
</div>
{% endblock %}
{% endblock %}
{% block sidebar %}
<aside id="sidebar">
<h3>{% trans "Actions" %}</h3>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-unavailability-calendar-import-unavailabilities' pk=unavailability_calendar.id %}">{% trans 'Manage unavailabilities from ICS' %}</a>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-unavailability-calendar-add-unavailability' pk=unavailability_calendar.id %}">{% trans 'Add Unavailability' %}</a>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-unavailability-calendar-edit' pk=unavailability_calendar.id %}">{% trans 'Options' %}</a>
{% if user.is_staff %}
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-unavailability-calendar-delete' pk=unavailability_calendar.id %}">{% trans 'Delete' %}</a>
{% endif %}
</aside>
{% endblock %}

View File

@ -2,8 +2,8 @@
{% load i18n %}
{% block agenda-extra-management-actions %}
<a rel="popup" href="{% url 'chrono-manager-virtual-agenda-add-time-period' pk=object.id %}">{% trans 'Add Excluded Period' %}</a>
<a rel="popup" href="{% url 'chrono-manager-agenda-add-virtual-member' pk=object.id %}">{% trans 'Include Agenda' %}</a>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-virtual-agenda-add-time-period' pk=object.id %}">{% trans 'Add Excluded Period' %}</a>
<a class="button button-paragraph" rel="popup" href="{% url 'chrono-manager-agenda-add-virtual-member' pk=object.id %}">{% trans 'Include Agenda' %}</a>
{% endblock %}
{% block agenda-settings-extra-tab-buttons %}

View File

@ -180,6 +180,7 @@ class HomepageView(ListView):
context['has_access_to_unavailability_calendars'] = self.has_access_to_unavailability_calendars()
context['shared_custody_enabled'] = settings.SHARED_CUSTODY_ENABLED
context['ants_hub_enabled'] = bool(settings.CHRONO_ANTS_HUB_URL)
context['with_sidebar'] = True
return context
def get(self, request, *args, **kwargs):

View File

@ -25,7 +25,7 @@ pytestmark = pytest.mark.django_db
def test_export_site(app, admin_user):
login(app)
resp = app.get('/manage/')
resp = resp.click('Export')
resp = resp.click('Export site')
with freezegun.freeze_time('2020-06-15'):
resp = resp.form.submit()
@ -94,21 +94,21 @@ def test_import_agenda(app, admin_user):
# invalid json
resp = app.get('/manage/', status=200)
resp = resp.click('Import')
resp = resp.click('Import site')
resp.form['agendas_json'] = Upload('export.json', b'garbage', 'application/json')
resp = resp.form.submit()
assert 'File is not in the expected JSON format.' in resp.text
# empty json
resp = app.get('/manage/', status=200)
resp = resp.click('Import')
resp = resp.click('Import site')
resp.form['agendas_json'] = Upload('export.json', b'{}', 'application/json')
resp = resp.form.submit().follow()
assert 'No data found.' in resp.text
# existing agenda
resp = app.get('/manage/', status=200)
resp = resp.click('Import')
resp = resp.click('Import site')
resp.form['agendas_json'] = Upload('export.json', agenda_export.encode('utf-8'), 'application/json')
resp = resp.form.submit()
assert resp.location.endswith('/manage/agendas/%s/settings' % agenda.pk)
@ -119,7 +119,7 @@ def test_import_agenda(app, admin_user):
# new agenda
Agenda.objects.all().delete()
resp = app.get('/manage/', status=200)
resp = resp.click('Import')
resp = resp.click('Import site')
resp.form['agendas_json'] = Upload('export.json', agenda_export.encode('utf-8'), 'application/json')
resp = resp.form.submit()
agenda = Agenda.objects.latest('pk')
@ -138,7 +138,7 @@ def test_import_agenda(app, admin_user):
agendas['agendas'][2]['slug'] = 'foo-bar-3'
resp = app.get('/manage/', status=200)
resp = resp.click('Import')
resp = resp.click('Import site')
resp.form['agendas_json'] = Upload('export.json', json.dumps(agendas).encode('utf-8'), 'application/json')
resp = resp.form.submit()
assert resp.location.endswith('/manage/')
@ -148,7 +148,7 @@ def test_import_agenda(app, admin_user):
Agenda.objects.all().delete()
resp = app.get('/manage/', status=200)
resp = resp.click('Import')
resp = resp.click('Import site')
resp.form['agendas_json'] = Upload('export.json', json.dumps(agendas).encode('utf-8'), 'application/json')
resp = resp.form.submit().follow()
assert '3 agendas have been created. No agenda updated.' in resp.text
@ -160,7 +160,7 @@ def test_import_agenda(app, admin_user):
agenda_export = json.dumps(agenda_export_dict).encode('utf-8')
Agenda.objects.all().delete()
resp = app.get('/manage/', status=200)
resp = resp.click('Import')
resp = resp.click('Import site')
resp.form['agendas_json'] = Upload('export.json', agenda_export, 'application/json')
resp = resp.form.submit()
assert 'Missing roles: &quot;gé1&quot;' in resp.text
@ -170,7 +170,7 @@ def test_import_agenda(app, admin_user):
del agenda_export_dict['agendas'][0]['kind']
agenda_export = json.dumps(agenda_export_dict).encode('utf-8')
resp = app.get('/manage/', status=200)
resp = resp.click('Import')
resp = resp.click('Import site')
resp.form['agendas_json'] = Upload('export.json', agenda_export, 'application/json')
resp = resp.form.submit()
assert resp.context['form'].errors['agendas_json'] == ['Key "kind" is missing.']
@ -194,7 +194,7 @@ def test_import_does_not_delete_bookings(app, admin_user):
# existing agenda
resp = app.get('/manage/', status=200)
resp = resp.click('Import')
resp = resp.click('Import site')
resp.form['agendas_json'] = Upload('export.json', agenda_export.encode('utf-8'), 'application/json')
resp = resp.form.submit().follow()
assert Agenda.objects.count() == 1