From 8d976fd73bc43d75b4e0fc72cd0916ec3e3ec8bb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Laur=C3=A9line=20Gu=C3=A9rin?= <zebuline@entrouvert.com>
Date: Thu, 27 Oct 2022 15:30:59 +0200
Subject: [PATCH 2/2] manager: always display Month/Week/Day buttons (#33404)

---
 .../manager_events_agenda_day_view.html       |  5 ++-
 .../manager_events_agenda_month_view.html     |  5 ++-
 .../manager_events_agenda_week_view.html      |  5 ++-
 .../manager_meetings_agenda_day_view.html     |  5 ++-
 .../manager_meetings_agenda_month_view.html   |  5 ++-
 .../manager_meetings_agenda_week_view.html    |  5 ++-
 .../chrono/manager_resource_day_view.html     |  5 ++-
 .../chrono/manager_resource_month_view.html   |  5 ++-
 .../chrono/manager_resource_week_view.html    |  5 ++-
 tests/manager/test_all.py                     | 45 ++++++++++---------
 tests/manager/test_resource.py                |  5 ++-
 11 files changed, 55 insertions(+), 40 deletions(-)

diff --git a/chrono/manager/templates/chrono/manager_events_agenda_day_view.html b/chrono/manager/templates/chrono/manager_events_agenda_day_view.html
index eb1d1709..e2be339e 100644
--- a/chrono/manager/templates/chrono/manager_events_agenda_day_view.html
+++ b/chrono/manager/templates/chrono/manager_events_agenda_day_view.html
@@ -10,8 +10,9 @@
   {% endif %}
   {{ block.super }}
   <a href="{% url 'chrono-manager-agenda-open-events-view' pk=agenda.pk %}">{% trans 'Open events' %}</a>
-  <a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month view' %}</a>
-  <a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.pk year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week view' %}</a>
+  <a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month' %}</a>
+  <a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.pk year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
+  <a class="disabled">{% trans 'Day' %}</a>
 {% endblock %}
 
 {% block content %}
diff --git a/chrono/manager/templates/chrono/manager_events_agenda_month_view.html b/chrono/manager/templates/chrono/manager_events_agenda_month_view.html
index c386992f..de2780de 100644
--- a/chrono/manager/templates/chrono/manager_events_agenda_month_view.html
+++ b/chrono/manager/templates/chrono/manager_events_agenda_month_view.html
@@ -11,8 +11,9 @@
   </ul>
   {{ block.super }}
   <a href="{% url 'chrono-manager-agenda-open-events-view' pk=agenda.pk %}">{% trans 'Open events' %}</a>
-  <a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.pk year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week view' %}</a>
-  <a href="{% url 'chrono-manager-agenda-day-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day view' %}</a>
+  <a class="disabled">{% trans 'Month' %}</a>
+  <a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.pk year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
+  <a href="{% url 'chrono-manager-agenda-day-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
 {% endblock %}
 
 {% block content %}
diff --git a/chrono/manager/templates/chrono/manager_events_agenda_week_view.html b/chrono/manager/templates/chrono/manager_events_agenda_week_view.html
index 51faa780..fc372825 100644
--- a/chrono/manager/templates/chrono/manager_events_agenda_week_view.html
+++ b/chrono/manager/templates/chrono/manager_events_agenda_week_view.html
@@ -11,8 +11,9 @@
   </ul>
   {{ block.super }}
   <a href="{% url 'chrono-manager-agenda-open-events-view' pk=agenda.pk %}">{% trans 'Open events' %}</a>
-  <a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" %}">{% trans 'Month view' %}</a>
-  <a href="{% url 'chrono-manager-agenda-day-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day view' %}</a>
+  <a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" %}">{% trans 'Month' %}</a>
+  <a class="disabled">{% trans 'Week' %}</a>
+  <a href="{% url 'chrono-manager-agenda-day-view' pk=agenda.pk year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
 {% endblock %}
 
 {% block content %}
diff --git a/chrono/manager/templates/chrono/manager_meetings_agenda_day_view.html b/chrono/manager/templates/chrono/manager_meetings_agenda_day_view.html
index 848b28d2..2506ceec 100644
--- a/chrono/manager/templates/chrono/manager_meetings_agenda_day_view.html
+++ b/chrono/manager/templates/chrono/manager_meetings_agenda_day_view.html
@@ -3,8 +3,9 @@
 
 {% block actions %}
   {{ block.super }}
-  <a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month view' %}</a>
-  <a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.id year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week view' %}</a>
+  <a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month' %}</a>
+  <a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.id year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
+  <a class="disabled">{% trans 'Day' %}</a>
 {% endblock %}
 
 {% block content %}
diff --git a/chrono/manager/templates/chrono/manager_meetings_agenda_month_view.html b/chrono/manager/templates/chrono/manager_meetings_agenda_month_view.html
index c73f15ca..e1acc239 100644
--- a/chrono/manager/templates/chrono/manager_meetings_agenda_month_view.html
+++ b/chrono/manager/templates/chrono/manager_meetings_agenda_month_view.html
@@ -3,8 +3,9 @@
 
 {% block actions %}
   {{ block.super }}
-  <a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.id year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week view' %}</a>
-  <a href="{% url 'chrono-manager-agenda-day-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day view' %}</a>
+  <a class="disabled">{% trans 'Month' %}</a>
+  <a href="{% url 'chrono-manager-agenda-week-view' pk=agenda.id year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
+  <a href="{% url 'chrono-manager-agenda-day-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
 {% endblock %}
 
 {% block content %}
diff --git a/chrono/manager/templates/chrono/manager_meetings_agenda_week_view.html b/chrono/manager/templates/chrono/manager_meetings_agenda_week_view.html
index 78d47a7e..72c1c5ae 100644
--- a/chrono/manager/templates/chrono/manager_meetings_agenda_week_view.html
+++ b/chrono/manager/templates/chrono/manager_meetings_agenda_week_view.html
@@ -3,8 +3,9 @@
 
 {% block actions %}
   {{ block.super }}
-  <a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" %}">{% trans 'Month view' %}</a>
-  <a href="{% url 'chrono-manager-agenda-day-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day view' %}</a>
+  <a href="{% url 'chrono-manager-agenda-month-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" %}">{% trans 'Month' %}</a>
+  <a class="disabled">{% trans 'Week' %}</a>
+  <a href="{% url 'chrono-manager-agenda-day-view' pk=agenda.id year=view.date|date:"Y" month=view.date|date:"m" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
 {% endblock %}
 
 {% block content %}
diff --git a/chrono/manager/templates/chrono/manager_resource_day_view.html b/chrono/manager/templates/chrono/manager_resource_day_view.html
index f0c3f9d0..95726658 100644
--- a/chrono/manager/templates/chrono/manager_resource_day_view.html
+++ b/chrono/manager/templates/chrono/manager_resource_day_view.html
@@ -22,8 +22,9 @@
   </h2>
 {% endblock %}
 {% block appbar-extras %}
-  <a href="{% url 'chrono-manager-resource-month-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month view' %}</a>
-  <a href="{% url 'chrono-manager-resource-week-view' pk=resource.pk year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week view' %}</a>
+  <a href="{% url 'chrono-manager-resource-month-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month' %}</a>
+  <a href="{% url 'chrono-manager-resource-week-view' pk=resource.pk year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
+  <a class="disabled">{% trans 'Day' %}</a>
 {% endblock %}
 
 {% block content %}
diff --git a/chrono/manager/templates/chrono/manager_resource_month_view.html b/chrono/manager/templates/chrono/manager_resource_month_view.html
index 13387efb..3ae1b43e 100644
--- a/chrono/manager/templates/chrono/manager_resource_month_view.html
+++ b/chrono/manager/templates/chrono/manager_resource_month_view.html
@@ -23,8 +23,9 @@
   </h2>
 {% endblock %}
 {% block appbar-extras %}
-  <a href="{% url 'chrono-manager-resource-week-view' pk=resource.pk year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week view' %}</a>
-  <a href="{% url 'chrono-manager-resource-day-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"n" day=view.date|date:"d" %}">{% trans 'Day view' %}</a>
+  <a class="disabled">{% trans 'Month' %}</a>
+  <a href="{% url 'chrono-manager-resource-week-view' pk=resource.pk year=view.date|date:"Y" week=view.date|date:"W" %}">{% trans 'Week' %}</a>
+  <a href="{% url 'chrono-manager-resource-day-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"n" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
 {% endblock %}
 
 {% block content %}
diff --git a/chrono/manager/templates/chrono/manager_resource_week_view.html b/chrono/manager/templates/chrono/manager_resource_week_view.html
index 91d239a5..6ef09e41 100644
--- a/chrono/manager/templates/chrono/manager_resource_week_view.html
+++ b/chrono/manager/templates/chrono/manager_resource_week_view.html
@@ -23,8 +23,9 @@
   </h2>
 {% endblock %}
 {% block appbar-extras %}
-  <a href="{% url 'chrono-manager-resource-month-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month view' %}</a>
-  <a href="{% url 'chrono-manager-resource-day-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"n" day=view.date|date:"d" %}">{% trans 'Day view' %}</a>
+  <a href="{% url 'chrono-manager-resource-month-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"n" %}">{% trans 'Month' %}</a>
+  <a class="disabled">{% trans 'Week' %}</a>
+  <a href="{% url 'chrono-manager-resource-day-view' pk=resource.pk year=view.date|date:"Y" month=view.date|date:"n" day=view.date|date:"d" %}">{% trans 'Day' %}</a>
 {% endblock %}
 
 {% block content %}
diff --git a/tests/manager/test_all.py b/tests/manager/test_all.py
index 3d29c922..181de4a5 100644
--- a/tests/manager/test_all.py
+++ b/tests/manager/test_all.py
@@ -1160,7 +1160,9 @@ def test_agenda_events_day_view(app, admin_user):
 
     login(app)
     resp = app.get('/manage/agendas/%s/%s/%s/%s/' % (agenda.pk, today.year, today.month, today.day))
-    assert 'Month view' in resp.text
+    assert '>Month<' in resp.text
+    assert '>Week<' in resp.text
+    assert '>Day<' in resp.text
     assert "This day doesn't have any event configured." in resp.text
 
     # event
@@ -1224,7 +1226,9 @@ def test_agenda_events_week_view(app, admin_user):
 
     login(app)
     resp = app.get('/manage/agendas/%s/%s/week/%s/' % (agenda.pk, today.year, today.strftime('%W')))
-    assert 'Day view' in resp.text
+    assert '>Month<' in resp.text
+    assert '>Week<' in resp.text
+    assert '>Day<' in resp.text
     assert "This week doesn't have any event configured." in resp.text
 
     # add event in a future month, a wednesday
@@ -1315,7 +1319,9 @@ def test_agenda_events_month_view(app, admin_user):
 
     login(app)
     resp = app.get('/manage/agendas/%s/%s/%s/' % (agenda.pk, today.year, today.month))
-    assert 'Day view' in resp.text
+    assert '>Month<' in resp.text
+    assert '>Week<' in resp.text
+    assert '>Day<' in resp.text
     assert "This month doesn't have any event configured." in resp.text
 
     # add event in a future month, a wednesday
@@ -1508,7 +1514,6 @@ def test_agenda_open_events_view(app, admin_user, manager_user):
     agenda.view_role = manager_user.groups.all()[0]
     agenda.save()
     resp = app.get('/manage/agendas/%s/events/open/' % agenda.pk)
-    assert 'Month view' in resp.text
 
     # wrong kind
     agenda.kind = 'meetings'
@@ -1529,12 +1534,12 @@ def test_agenda_month_view(app, admin_user, manager_user, api_user, get_proper_h
 
     login(app)
     resp = app.get('/manage/agendas/%s/%d/%d/%d/' % (agenda.pk, today.year, today.month, today.day))
-    assert 'Month view' in resp.text
-    resp = resp.click('Month view')
+    resp = resp.click('Month')
     assert resp.request.url.endswith('%s/%s/' % (today.year, today.month))
 
-    assert 'Day view' in resp.text  # day view link should be present
-    assert 'Week view' in resp.text  # week view link should be present
+    assert '>Month<' in resp.text
+    assert '>Week<' in resp.text
+    assert '>Day<' in resp.text
     assert 'No opening hours this month.' in resp.text
 
     today = datetime.date(2018, 11, 10)  # fixed day
@@ -1923,12 +1928,12 @@ def test_agenda_week_view(app, admin_user, manager_user, api_user, get_proper_ht
 
     login(app)
     resp = app.get('/manage/agendas/%s/%d/%d/%d/' % (agenda.pk, today.year, today.month, today.day))
-    assert 'Week view' in resp.text
-    resp = resp.click('Week view')
+    resp = resp.click('Week')
     assert resp.request.url.endswith('%s/week/%s/' % (today.year, today.strftime('%W')))
 
-    assert 'Day view' in resp.text  # day view link should be present
-    assert 'Month view' in resp.text  # month view link should be present
+    assert '>Month<' in resp.text
+    assert '>Week<' in resp.text
+    assert '>Day<' in resp.text
     assert 'No opening hours this week.' in resp.text
 
     today = datetime.date(2018, 11, 10)  # fixed day
@@ -2559,12 +2564,12 @@ def test_virtual_agenda_week_view(app, admin_user, get_proper_html_str):
 
     login(app)
     resp = app.get('/manage/agendas/%s/%d/%d/%d/' % (agenda.pk, today.year, today.month, today.day))
-    assert 'Week view' in resp.text
-    resp = resp.click('Week view')
+    resp = resp.click('Week')
     assert resp.request.url.endswith('%s/week/%s/' % (today.year, today.strftime('%W')))
 
-    assert 'Day view' in resp.text  # day view link should be present
-    assert 'Month view' in resp.text  # month view link should be present
+    assert '>Month<' in resp.text
+    assert '>Week<' in resp.text
+    assert '>Day<' in resp.text
     assert 'No opening hours this week.' in resp.text
 
     today = datetime.date(2018, 11, 10)  # fixed day
@@ -2682,12 +2687,12 @@ def test_virtual_agenda_month_view(app, admin_user, get_proper_html_str):
 
     login(app)
     resp = app.get('/manage/agendas/%s/%d/%d/%d/' % (agenda.pk, today.year, today.month, today.day))
-    assert 'Month view' in resp.text
-    resp = resp.click('Month view')
+    resp = resp.click('Month')
     assert resp.request.url.endswith('%s/%s/' % (today.year, today.month))
 
-    assert 'Day view' in resp.text  # day view link should be present
-    assert 'Week view' in resp.text  # week view link should be present
+    assert '>Month<' in resp.text
+    assert '>Week<' in resp.text
+    assert '>Day<' in resp.text
     assert 'No opening hours this month.' in resp.text
 
     today = datetime.date(2018, 11, 10)  # fixed day
diff --git a/tests/manager/test_resource.py b/tests/manager/test_resource.py
index 9d92c3fd..f029dc7b 100644
--- a/tests/manager/test_resource.py
+++ b/tests/manager/test_resource.py
@@ -935,7 +935,8 @@ def test_resource_access_permission(app, manager_user):
     assert 'Edit' not in resp.text
     assert 'Delete' not in resp.text
 
-    assert resp.click('Month view')
-    assert resp.click('Day view')
+    assert resp.click('Month')
+    assert resp.click('Week')
+    assert resp.click('Day')
 
     assert app.get('/manage/resource/%s/' % resource2.pk, status=403)
-- 
2.35.1

