From a36b3cf7d4feca2dae35dcc4295f9196e29cd4bc Mon Sep 17 00:00:00 2001 From: vincent porte Date: Mon, 2 Oct 2023 11:56:38 +0200 Subject: [PATCH 1/8] [EVENT] add messages in locales --- locale/fr/LC_MESSAGES/django.mo | Bin 14330 -> 14747 bytes locale/fr/LC_MESSAGES/django.po | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/locale/fr/LC_MESSAGES/django.mo b/locale/fr/LC_MESSAGES/django.mo index 55194dbdc95ff774efd344662257b9f5eb1ea8f5..5fede7c98d47e2941d96401aae52ef5a173c1135 100644 GIT binary patch delta 4673 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 Date: Mon, 2 Oct 2023 11:35:58 +0200 Subject: [PATCH 2/8] [EVENT] add detail view --- lacommunaute/event/tests/tests_views.py | 7 ++ lacommunaute/event/urls.py | 2 + lacommunaute/event/views.py | 6 ++ .../templates/event/event_detail.html | 78 +++++++++++++++++++ 4 files changed, 93 insertions(+) create mode 100644 lacommunaute/templates/event/event_detail.html diff --git a/lacommunaute/event/tests/tests_views.py b/lacommunaute/event/tests/tests_views.py index 6f9f926a8..a44fefcc8 100644 --- a/lacommunaute/event/tests/tests_views.py +++ b/lacommunaute/event/tests/tests_views.py @@ -207,6 +207,13 @@ def test_list_my_events(self): self.assertNotIn(not_myevent, response.context_data["object_list"]) +class EventDetailViewTest(TestCase): + def test_detail_view(self): + event = EventFactory() + response = self.client.get(reverse("event:detail", kwargs={"pk": event.pk})) + self.assertContains(response, event.name, status_code=200) + + class calendar_data_test(TestCase): def test_json_response(self): event = EventFactory() diff --git a/lacommunaute/event/urls.py b/lacommunaute/event/urls.py index ac3b34d43..b0ae143bd 100644 --- a/lacommunaute/event/urls.py +++ b/lacommunaute/event/urls.py @@ -3,6 +3,7 @@ from lacommunaute.event.views import ( EventCreateView, EventDeleteView, + EventDetailView, EventListView, EventUpdateView, calendar, @@ -16,6 +17,7 @@ urlpatterns = [ path("", calendar, name="calendar"), path("create/", EventCreateView.as_view(), name="create"), + path("/", EventDetailView.as_view(), name="detail"), path("/update/", EventUpdateView.as_view(), name="update"), path("/delete/", EventDeleteView.as_view(), name="delete"), path("myevents/", EventListView.as_view(), name="myevents"), diff --git a/lacommunaute/event/views.py b/lacommunaute/event/views.py index b40703323..685362fd3 100644 --- a/lacommunaute/event/views.py +++ b/lacommunaute/event/views.py @@ -7,6 +7,7 @@ from django.http import JsonResponse from django.template.response import TemplateResponse from django.urls import reverse +from django.views.generic.detail import DetailView from django.views.generic.edit import CreateView, DeleteView, UpdateView from django.views.generic.list import ListView @@ -65,6 +66,11 @@ def get_queryset(self): return Event.objects.filter(poster=self.request.user) +class EventDetailView(DetailView): + model = Event + template_name = "event/event_detail.html" + + # TODO vincentporte : factoriser les EventXXXView diff --git a/lacommunaute/templates/event/event_detail.html b/lacommunaute/templates/event/event_detail.html new file mode 100644 index 000000000..92d0f0ebc --- /dev/null +++ b/lacommunaute/templates/event/event_detail.html @@ -0,0 +1,78 @@ +{% extends "layouts/base.html" %} +{% load i18n %} + +{% block sub_title %}{{ event.name }}{% endblock sub_title %} + +{% block content %} +
+
+
+
+

{% trans "Public event" %}

+
+
+
+
+ +
+
+
+
+
+
+
+
+

+ {{ event.name }} +

+

+ {% if event.date == event.end_date%} + {% blocktrans trimmed with date=event.date time=event.time end_time=event.end_time %} + On {{ date }} from {{ time }} to {{ end_time }} + {% endblocktrans %} + {% else %} + {% blocktrans trimmed with date=event.date end_date=event.end_date time=event.time end_time=event.end_time %} + From {{date }} {{ time }} to {{ end_date }} {{ end_time }} + {% endblocktrans %} + {% endif %} +

+
+
+
+
+
+
+ {{ event.description }} +
+
+ + {% if event.location %} + + + + {% endif %} +
+
+
+
+
+ +
+ +
+ +
+{% endblock content %} + From 8144c2b2e7b2b038f8ea0155b5e24f8d5cef4fa9 Mon Sep 17 00:00:00 2001 From: vincent porte Date: Mon, 2 Oct 2023 11:38:57 +0200 Subject: [PATCH 3/8] [EVENT] add archive month view --- lacommunaute/event/tests/tests_views.py | 35 ++++++++++ lacommunaute/event/urls.py | 2 + lacommunaute/event/views.py | 9 +++ .../templates/event/event_archive_month.html | 70 +++++++++++++++++++ 4 files changed, 116 insertions(+) create mode 100644 lacommunaute/templates/event/event_archive_month.html diff --git a/lacommunaute/event/tests/tests_views.py b/lacommunaute/event/tests/tests_views.py index a44fefcc8..f9e7f55dc 100644 --- a/lacommunaute/event/tests/tests_views.py +++ b/lacommunaute/event/tests/tests_views.py @@ -214,6 +214,41 @@ def test_detail_view(self): self.assertContains(response, event.name, status_code=200) +class EventMonthArchiveViewTest(TestCase): + def test_view_with_args(self): + event = EventFactory(date=timezone.now() + relativedelta(months=1)) + response = self.client.get(reverse("event:month", kwargs={"year": event.date.year, "month": event.date.month})) + self.assertContains(response, event.name, status_code=200) + + def test_navbar(self): + event = EventFactory(date=timezone.now()) + event_in_the_future = EventFactory(date=event.date + relativedelta(months=1)) + event_in_the_past = EventFactory(date=event.date - relativedelta(months=1)) + response = self.client.get(reverse("event:current")) + self.assertContains( + response, + reverse( + "event:month", + kwargs={ + "year": event_in_the_past.date.year, + "month": f"{event_in_the_past.date.month:02d}", + }, + ), + status_code=200, + ) + self.assertContains( + response, + reverse( + "event:month", + kwargs={ + "year": event_in_the_future.date.year, + "month": f"{event_in_the_future.date.month:02d}", + }, + ), + status_code=200, + ) + + class calendar_data_test(TestCase): def test_json_response(self): event = EventFactory() diff --git a/lacommunaute/event/urls.py b/lacommunaute/event/urls.py index b0ae143bd..5f629c75c 100644 --- a/lacommunaute/event/urls.py +++ b/lacommunaute/event/urls.py @@ -5,6 +5,7 @@ EventDeleteView, EventDetailView, EventListView, + EventMonthArchiveView, EventUpdateView, calendar, calendar_data, @@ -22,4 +23,5 @@ path("/delete/", EventDeleteView.as_view(), name="delete"), path("myevents/", EventListView.as_view(), name="myevents"), path("events/events.json", calendar_data, name="data_source"), + path("events///", EventMonthArchiveView.as_view(), name="month"), ] diff --git a/lacommunaute/event/views.py b/lacommunaute/event/views.py index 685362fd3..29782f9f5 100644 --- a/lacommunaute/event/views.py +++ b/lacommunaute/event/views.py @@ -7,6 +7,7 @@ from django.http import JsonResponse from django.template.response import TemplateResponse from django.urls import reverse +from django.views.generic.dates import MonthArchiveView from django.views.generic.detail import DetailView from django.views.generic.edit import CreateView, DeleteView, UpdateView from django.views.generic.list import ListView @@ -71,6 +72,14 @@ class EventDetailView(DetailView): template_name = "event/event_detail.html" +class EventMonthArchiveView(MonthArchiveView): + allow_future = True + date_field = "date" + queryset = Event.objects.all() + month_format = "%m" + year_format = "%Y" + + # TODO vincentporte : factoriser les EventXXXView diff --git a/lacommunaute/templates/event/event_archive_month.html b/lacommunaute/templates/event/event_archive_month.html new file mode 100644 index 000000000..94eb24e8a --- /dev/null +++ b/lacommunaute/templates/event/event_archive_month.html @@ -0,0 +1,70 @@ +{% extends "layouts/base.html" %} +{% load i18n %} + +{% block sub_title %}{% trans "Events" %} {{ month }}{% endblock sub_title %} + +{% block content %} +
+
+
+
+

{% trans "Month Events" %}

+
+
+
+
+ +
+
+
+
+ {% if previous_month %} + + + + {% endif %} + {{ month|date:"F Y" }} + {% if next_month %} + + + + {% endif %} +
+
+
+
+ +
+
+
+
+
    + {% for event in object_list %} +
  • + {{ event.date }} - {{ event.time }} : + {{event.name|truncatechars:100}} +
  • + {% empty %} +
  • {% trans "No event yet" %}
  • + {% endfor %} +
+
+
+
+
+ +
+ +
+ +{% endblock content %} + From 531ee6a2dd94882279b65f99a258763145eb16cb Mon Sep 17 00:00:00 2001 From: vincent porte Date: Mon, 2 Oct 2023 11:41:36 +0200 Subject: [PATCH 4/8] [EVENT] make archive month view wo args able to access current month http404 montharchiveview --- lacommunaute/event/tests/tests_views.py | 7 +++++++ lacommunaute/event/urls.py | 1 + lacommunaute/event/views.py | 20 ++++++++++++++++---- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lacommunaute/event/tests/tests_views.py b/lacommunaute/event/tests/tests_views.py index f9e7f55dc..71ef1e5a1 100644 --- a/lacommunaute/event/tests/tests_views.py +++ b/lacommunaute/event/tests/tests_views.py @@ -215,6 +215,13 @@ def test_detail_view(self): class EventMonthArchiveViewTest(TestCase): + def test_view_wo_args(self): + event = EventFactory(date=timezone.now()) + response = self.client.get(reverse("event:current")) + self.assertContains(response, event.name, status_code=200) + self.assertContains(response, reverse("event:detail", kwargs={"pk": event.pk})) + self.assertContains(response, reverse("event:create")) + def test_view_with_args(self): event = EventFactory(date=timezone.now() + relativedelta(months=1)) response = self.client.get(reverse("event:month", kwargs={"year": event.date.year, "month": event.date.month})) diff --git a/lacommunaute/event/urls.py b/lacommunaute/event/urls.py index 5f629c75c..b1f2007a9 100644 --- a/lacommunaute/event/urls.py +++ b/lacommunaute/event/urls.py @@ -24,4 +24,5 @@ path("myevents/", EventListView.as_view(), name="myevents"), path("events/events.json", calendar_data, name="data_source"), path("events///", EventMonthArchiveView.as_view(), name="month"), + path("events/", EventMonthArchiveView.as_view(), name="current"), ] diff --git a/lacommunaute/event/views.py b/lacommunaute/event/views.py index 29782f9f5..3e46ef8e9 100644 --- a/lacommunaute/event/views.py +++ b/lacommunaute/event/views.py @@ -1,11 +1,9 @@ import logging +from datetime import datetime from django.contrib.auth.mixins import LoginRequiredMixin from django.core.exceptions import PermissionDenied -from django.db.models import F -from django.db.models.functions import ExtractDay, ExtractMonth, ExtractYear -from django.http import JsonResponse -from django.template.response import TemplateResponse +from django.http import Http404 from django.urls import reverse from django.views.generic.dates import MonthArchiveView from django.views.generic.detail import DetailView @@ -79,6 +77,20 @@ class EventMonthArchiveView(MonthArchiveView): month_format = "%m" year_format = "%Y" + def get_month(self): + try: + month = super().get_month() + except Http404: + month = datetime.now().strftime(self.get_month_format()) + return month + + def get_year(self): + try: + year = super().get_year() + except Http404: + year = datetime.now().strftime(self.get_year_format()) + return year + # TODO vincentporte : factoriser les EventXXXView From 4ab5797cfb470cb0d1bce707278a6d41e99f12a7 Mon Sep 17 00:00:00 2001 From: vincent porte Date: Mon, 2 Oct 2023 11:44:38 +0200 Subject: [PATCH 5/8] [EVENT] replace 'calendar' url to 'current' url --- lacommunaute/templates/event/event_list.html | 2 +- lacommunaute/templates/partials/footer.html | 2 +- lacommunaute/templates/partials/header_nav_secondary_items.html | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lacommunaute/templates/event/event_list.html b/lacommunaute/templates/event/event_list.html index 34fa0e112..feee3f203 100644 --- a/lacommunaute/templates/event/event_list.html +++ b/lacommunaute/templates/event/event_list.html @@ -19,7 +19,7 @@

{% trans "Manage My Events" %} diff --git a/lacommunaute/templates/partials/footer.html b/lacommunaute/templates/partials/footer.html index b676228af..c112e91ad 100644 --- a/lacommunaute/templates/partials/footer.html +++ b/lacommunaute/templates/partials/footer.html @@ -27,7 +27,7 @@
  • - + {% trans "Events" %}
  • diff --git a/lacommunaute/templates/partials/header_nav_secondary_items.html b/lacommunaute/templates/partials/header_nav_secondary_items.html index 37a698791..e4be1e956 100644 --- a/lacommunaute/templates/partials/header_nav_secondary_items.html +++ b/lacommunaute/templates/partials/header_nav_secondary_items.html @@ -7,7 +7,7 @@ {% url 'forum_conversation_extension:topics' as publicforum_url %} {% url 'forum_conversation_extension:newsfeed' as newsfeed_url %} {% url 'forum_extension:documentation' as documentation_url %} -{% url 'event:calendar' as calendar_url %} +{% url 'event:current' as calendar_url %} {% url 'forum_search_extension:search' as search_url %}
      From 87e9104334e1eda480ad3af0ad159dba2c320c53 Mon Sep 17 00:00:00 2001 From: vincent porte Date: Mon, 2 Oct 2023 11:45:40 +0200 Subject: [PATCH 6/8] [EVENT] del tiva-calendar stuffs --- lacommunaute/event/tests/tests_views.py | 30 - lacommunaute/event/urls.py | 4 - lacommunaute/event/views.py | 37 - .../vendor/tiva-calendar/css/calendar.css | 161 ---- .../tiva-calendar/css/calendar_compact.css | 202 ---- .../tiva-calendar/css/calendar_full.css | 287 ------ .../static/vendor/tiva-calendar/css/style.css | 53 -- .../vendor/tiva-calendar/js/calendar.js | 890 ------------------ .../static/vendor/tiva-calendar/js/config.js | 3 - .../vendor/tiva-calendar/languages/en.js | 20 - .../templates/event/event_calendar.html | 55 -- 11 files changed, 1742 deletions(-) delete mode 100644 lacommunaute/static/vendor/tiva-calendar/css/calendar.css delete mode 100644 lacommunaute/static/vendor/tiva-calendar/css/calendar_compact.css delete mode 100644 lacommunaute/static/vendor/tiva-calendar/css/calendar_full.css delete mode 100644 lacommunaute/static/vendor/tiva-calendar/css/style.css delete mode 100644 lacommunaute/static/vendor/tiva-calendar/js/calendar.js delete mode 100644 lacommunaute/static/vendor/tiva-calendar/js/config.js delete mode 100644 lacommunaute/static/vendor/tiva-calendar/languages/en.js delete mode 100644 lacommunaute/templates/event/event_calendar.html diff --git a/lacommunaute/event/tests/tests_views.py b/lacommunaute/event/tests/tests_views.py index 71ef1e5a1..eff6dc04b 100644 --- a/lacommunaute/event/tests/tests_views.py +++ b/lacommunaute/event/tests/tests_views.py @@ -1,4 +1,3 @@ -import json from datetime import datetime, timedelta from dateutil.relativedelta import relativedelta @@ -254,32 +253,3 @@ def test_navbar(self): ), status_code=200, ) - - -class calendar_data_test(TestCase): - def test_json_response(self): - event = EventFactory() - items = [ - { - "id": event.id, - "name": event.name, - "color": 1, - "location": event.location, - "description": event.description, - "poster_id": event.poster.id, - "time": event.time.strftime("%H:%M:%S"), - "year": event.date.year, - "month": event.date.month, - "day": event.date.day, - "duration": 1, - } - ] - response = self.client.get(reverse("event:data_source")) - self.assertEqual(json.loads(response.content)["items"], items) - - -class calendar_test(TestCase): - def test_template(self): - response = self.client.get(reverse("event:calendar")) - self.assertTemplateUsed(response, "event/event_calendar.html") - self.assertContains(response, reverse("event:create")) diff --git a/lacommunaute/event/urls.py b/lacommunaute/event/urls.py index b1f2007a9..b64218145 100644 --- a/lacommunaute/event/urls.py +++ b/lacommunaute/event/urls.py @@ -7,8 +7,6 @@ EventListView, EventMonthArchiveView, EventUpdateView, - calendar, - calendar_data, ) @@ -16,13 +14,11 @@ urlpatterns = [ - path("", calendar, name="calendar"), path("create/", EventCreateView.as_view(), name="create"), path("/", EventDetailView.as_view(), name="detail"), path("/update/", EventUpdateView.as_view(), name="update"), path("/delete/", EventDeleteView.as_view(), name="delete"), path("myevents/", EventListView.as_view(), name="myevents"), - path("events/events.json", calendar_data, name="data_source"), path("events///", EventMonthArchiveView.as_view(), name="month"), path("events/", EventMonthArchiveView.as_view(), name="current"), ] diff --git a/lacommunaute/event/views.py b/lacommunaute/event/views.py index 3e46ef8e9..ab4d948ed 100644 --- a/lacommunaute/event/views.py +++ b/lacommunaute/event/views.py @@ -90,40 +90,3 @@ def get_year(self): except Http404: year = datetime.now().strftime(self.get_year_format()) return year - - -# TODO vincentporte : factoriser les EventXXXView - - -def calendar_data(request): - data = { - "items": list( - Event.current_and_upcomings.annotate( - year=ExtractYear("date"), - month=ExtractMonth("date"), - day=ExtractDay("date"), - duration=ExtractDay(F("end_date") - F("date")) + 1, - ).values( - "id", - "name", - "color", - "location", - "description", - "poster_id", - "year", - "month", - "day", - "time", - "duration", - ) - ) - } - return JsonResponse(data) - - -# TODO vincentporte : supprimer ce pseudo endpoint au profit du passage en context des données -# dans la méthode calendar (refactor js) - - -def calendar(request): - return TemplateResponse(request, "event/event_calendar.html") diff --git a/lacommunaute/static/vendor/tiva-calendar/css/calendar.css b/lacommunaute/static/vendor/tiva-calendar/css/calendar.css deleted file mode 100644 index a9f402dae..000000000 --- a/lacommunaute/static/vendor/tiva-calendar/css/calendar.css +++ /dev/null @@ -1,161 +0,0 @@ -/* Common */ -.hidden-fields { - display: none; -} -.cleardiv { - clear: both; -} -.loading { - text-align: center; - margin: 130px 0; -} -.tiva-events-calendar { - font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; -} - -/* Bar */ -.events-calendar-bar { - margin-top: 20px; -} -.events-calendar-bar .bar-btn.active { - background: #5AA4A3; -} -.events-calendar-bar .bar-btn { - color: #fff; - background: #757575; - padding: 3px 10px 3px 28px; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; - font-size: 14px; - border: 0; - margin-right: 10px; - line-height: 26px; - cursor: pointer; - display: inline-block; - position: relative; -} -.events-calendar-bar .bar-btn:hover { - background: #5AA4A3; -} -.events-calendar-bar .back-calendar { - padding: 3px 10px 3px 22px; - margin-right: 0; - float: right !important; -} -.events-calendar-bar .bar-btn i { - position: absolute; - left: 10px; -} -.events-calendar-bar .calendar-view i { - top: 7px; -} -.events-calendar-bar .list-view i { - top: 9px; -} -.events-calendar-bar .back-calendar i { - top: 9px; -} - -/* Calendar */ -.tiva-calendar .calendar-table { - table-layout: auto; - box-sizing: content-box; - border-right: 0; -} -.tiva-calendar .calendar-table th, .tiva-calendar .calendar-table td { - border-bottom: none; - border-right: none; - padding: 8px; -} -.tiva-calendar .calendar-btn span { - font-size: 14px; - color: #fff; -} - -/* Tooltip */ -.calendar-day-event { - position: relative; -} -.calendar-day-event .tiva-event-tooltip { - position: absolute; - z-index: 9999; - width: 180px; - left: 50%; - margin: 0 0 0 -100px; - bottom: 35px; - background: #f5f5f5; - opacity: 0; - border: 1px solid #cccccc; - box-shadow: 0 0 5px 2px rgba(145,145,145,.35); - border-radius: 6px; - pointer-events: none; - padding: 10px; - text-align: left; - -webkit-transform: translate3d(0,-10px,0); - transform: translate3d(0,-10px,0); - -webkit-transition: opacity 0.3s, -webkit-transform 0.3s; - transition: opacity 0.3s, transform 0.3s; -} -.calendar-day-event .tiva-event-tooltip::before, .calendar-day-event .tiva-event-tooltip::after { - top: 100%; - left: 50%; - border: solid transparent; - content: " "; - height: 0; - width: 0; - position: absolute; - pointer-events: none; -} -.calendar-day-event .tiva-event-tooltip::after { - border-color: rgba(245, 245, 245, 0); - border-top-color: #f5f5f5; - border-width: 8px; - margin-left: -8px; -} -.calendar-day-event .tiva-event-tooltip::before { - border-color: rgba(204, 204, 204, 0); - border-top-color: #cccccc; - border-width: 9px; - margin-left: -9px; -} -.calendar-day-event .tiva-event-tooltip .event-tooltip-item { - border-bottom: 1px dotted #666; - margin-bottom: 10px; - padding-bottom: 10px; -} -.calendar-day-event .tiva-event-tooltip .event-tooltip-item:last-child { - border-bottom: none; - margin-bottom: 0; - padding-bottom: 0; -} -.calendar-day-event .tiva-event-tooltip .event-time { - display: inline-block; - font-size: 12px; - color: #fff; - background: #757575; - padding: 0 5px; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; - border: 0; - margin-bottom: 5px; - line-height: 22px; -} -.calendar-day-event .tiva-event-tooltip .event-time i { - margin-right: 5px; -} -.calendar-day-event .tiva-event-tooltip .event-name { - font-size: 15px; - line-height: 20px; - margin-bottom: 6px; - color: #5AA4A3; -} -.calendar-day-event .tiva-event-tooltip .event-image img { - width: 100%; - margin-bottom: 6px; - border: 1px solid #EEE; -} -.calendar-day-event .tiva-event-tooltip .event-intro { - font-size: 14px; -} \ No newline at end of file diff --git a/lacommunaute/static/vendor/tiva-calendar/css/calendar_compact.css b/lacommunaute/static/vendor/tiva-calendar/css/calendar_compact.css deleted file mode 100644 index 4af318266..000000000 --- a/lacommunaute/static/vendor/tiva-calendar/css/calendar_compact.css +++ /dev/null @@ -1,202 +0,0 @@ -/* Events Calendar contain */ -.tiva-events-calendar.compact .tiva-events-calendar-wrap { - margin: 25px 0 30px 0; - border: 1px solid #dedade; - box-shadow: 0 0 5px 2px rgba(145,145,145,.35); - -moz-border-radius-bottomleft: 4px; - -webkit-border-bottom-left-radius: 4px; - border-bottom-left-radius: 4px; - -moz-border-radius-bottomright: 4px; - -webkit-border-bottom-right-radius: 4px; - border-bottom-right-radius: 4px; - -moz-border-radius-topright: 4px; - -webkit-border-top-right-radius: 4px; - border-top-right-radius: 4px; - -moz-border-radius-topleft: 4px; - -webkit-border-top-left-radius: 4px; - border-top-left-radius: 4px; - border-collapse: collapse; - border-spacing: 0; -} - -/* Calendar */ -.tiva-calendar-compact .calendar-table { - margin-bottom: 0 !important; -} -.tiva-calendar-compact .calendar-title , .tiva-calendar-compact .calendar-btn { - text-align: center !important; - background: #5AA4A3; - color: #ffffff; - height: 30px; - vertical-align: middle !important; -} -.tiva-calendar-compact .calendar-btn span { - cursor: pointer; -} -.tiva-calendar-compact .calendar-title { - font-size: 13px; - font-weight: bold; - padding: 4px 0 0 0 !important; -} -.tiva-calendar-compact .calendar-table tr th { - text-align: center; - color: #5AA4A3; - background: #eeeeee; - font-size: 11px; - padding: 8px 0; -} -.tiva-calendar-compact .calendar-table tr th, .tiva-calendar-compact .calendar-table tr td { - width: 14.285714285714285%; - line-height: 19px; -} -.tiva-calendar-compact .calendar-day-blank { - background: #f6f6f6; - padding: 0 !important; -} -.tiva-calendar-compact .calendar-day-normal { - text-align: center; - color: #666; - padding: 0 !important; - height: 34px; - vertical-align: middle !important; -} -.tiva-calendar-compact .calendar-day-normal .calendar-day-event { - cursor: pointer; -} -.tiva-calendar-compact .calendar-day-today { - background: #d5e9e9; -} -.tiva-calendar-compact .calendar-day-weekend { - color: #ef4f69; -} -.tiva-calendar-compact .calendar-event-mark { - position: absolute; - top: -8px; - right: 0; - background: none !important; -} -.tiva-calendar-compact .calendar-event-mark::after { - content: ''; - visibility: visible; - display: block; - position: absolute; - top: 0; - right: 0; - width: 0; - height: 0; - border-top: 16px solid #567BD2; - border-left: 16px solid transparent; -} - -/* Event list */ -.tiva-event-list-compact { - padding: 15px; - background: #eeeeee; - display: none; -} -.tiva-event-list-compact .event-item { - width: 100%; - border-top: 1px dotted #666; - margin-top: 20px; - padding-top: 20px; -} -.tiva-event-list-compact .event-item:first-child { - border-top: none; - margin-top: 0; - padding-top: 0; -} -.tiva-event-list-compact .event-image img { - width: 100%; - border: 1px solid #eee; - margin-bottom: 10px; -} -.tiva-event-list-compact .event-name { - font-size: 16px; - color: #5AA4A3; - margin-bottom: 6px; -} -.tiva-event-list-compact .event-time, .tiva-event-list-compact .event-date { - margin-bottom: 3px; - color: #ef4f69; - font-size: 13px; -} -.tiva-event-list-compact .event-time i, .tiva-event-list-compact .event-date i { - margin-right: 5px; -} -.tiva-event-list-compact .event-intro { - color: #666; - font-size: 14px; -} -.tiva-event-list-compact .link { - cursor: pointer; -} - -/* Event detail */ -.tiva-event-detail-compact { - padding: 15px; - background: #eeeeee; - display: none; -} -.tiva-event-detail-compact .event-item { - width: 100%; - border-top: 1px dotted #666; - margin-top: 20px; - padding-top: 20px; -} -.tiva-event-detail-compact .event-item:first-child { - border-top: none; - margin-top: 0; - padding-top: 0; -} -.tiva-event-detail-compact .event-image img { - width: 100%; - border: 1px solid #eee; - margin-bottom: 10px; -} -.tiva-event-detail-compact .event-name { - font-size: 16px; - color: #5AA4A3; - margin-bottom: 6px; -} -.tiva-event-detail-compact .event-time, .tiva-event-detail-compact .event-date, .tiva-event-detail-compact .event-location { - margin-bottom: 5px; - color: #666; - font-size: 14px; -} -.tiva-event-detail-compact .event-time i, .tiva-event-detail-compact .event-date i, .tiva-event-detail-compact .event-location i { - margin-right: 5px; - width: 14px; -} -.tiva-event-detail-compact .event-location i { - font-size: 18px; -} -.tiva-event-detail-compact .event-desc { - color: #666; - border-top: 1px solid #e2e2e2; - padding-top: 15px; - margin-top: 15px; - margin-bottom: 22px; - line-height: 22px; - font-size: 14px; -} -.tiva-event-detail-compact .event-link { - margin-bottom: 30px; -} -.tiva-event-detail-compact .event-link a { - color: #fff; - background: #5AA4A3; - padding: 8px 10px 8px 10px; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; - font-size: 14px; - border: 0; - cursor: pointer; - position: relative; -} -.tiva-event-detail-compact .event-link a:hover { - text-decoration: none; -} -.tiva-event-detail-compact .event-link a i { - margin-right: 5px; -} \ No newline at end of file diff --git a/lacommunaute/static/vendor/tiva-calendar/css/calendar_full.css b/lacommunaute/static/vendor/tiva-calendar/css/calendar_full.css deleted file mode 100644 index e7d352dc9..000000000 --- a/lacommunaute/static/vendor/tiva-calendar/css/calendar_full.css +++ /dev/null @@ -1,287 +0,0 @@ -/* Events Calendar contain */ -.tiva-events-calendar.full .tiva-events-calendar-wrap { - margin: 25px 0 40px 0; - border: 1px solid #dedade; - box-shadow: 0 0 5px 2px rgba(145,145,145,.35); - -moz-border-radius-bottomleft: 4px; - -webkit-border-bottom-left-radius: 4px; - border-bottom-left-radius: 4px; - -moz-border-radius-bottomright: 4px; - -webkit-border-bottom-right-radius: 4px; - border-bottom-right-radius: 4px; - -moz-border-radius-topright: 4px; - -webkit-border-top-right-radius: 4px; - border-top-right-radius: 4px; - -moz-border-radius-topleft: 4px; - -webkit-border-top-left-radius: 4px; - border-top-left-radius: 4px; - border-collapse: collapse; - border-spacing: 0; -} - -/* Calendar */ -.tiva-calendar-full .calendar-table { - margin-bottom: 0 !important; -} -.tiva-calendar-full .calendar-title , .tiva-calendar-full .calendar-btn { - text-align: center !important; - background: #5AA4A3; - color: #ffffff; - height: 30px; - vertical-align: middle !important; -} -.tiva-calendar-full .calendar-btn { - padding: 0 !important; -} -.tiva-calendar-full .calendar-btn span { - cursor: pointer; - font-size: 13px !important; -} -.tiva-calendar-full .calendar-title { - font-size: 15px; - font-weight: bold; - padding-top: 12px !important; - padding-left: 30px !important; -} -.tiva-calendar-full .calendar-title span { - position: relative; - color: #fff; - font-weight: bold; - font-size: 15px; - line-height: 20px; -} -.tiva-calendar-full .calendar-title i { - position: absolute; - left: -22px; - top: -1px; -} -.tiva-calendar-full .calendar-table tr th { - text-align: center; - color: #5AA4A3; - background: #eeeeee; - font-size: 14px; -} -.tiva-calendar-full .calendar-table tr th, .tiva-calendar-full .calendar-table tr td { - width: 14.285714285714285%; -} -.tiva-calendar-full .calendar-day-blank { - background: #f6f6f6; -} -.tiva-calendar-full .calendar-day-normal { - height: 60px; - font-size: 16px; - text-align: right !important; - padding: 6px 10px !important; - color: #666; -} -.tiva-calendar-full .calendar-day-today { - background: #d5e9e9; -} -.tiva-calendar-full .calendar-day-weekend { - color: #ef4f69; - line-height: 20px; - font-size: 16px; -} -.tiva-calendar-full .calendar-event-name { - color: #ffffff; - background: #567BD2; - font-size: 11px; - margin-top: 5px; - text-align: center; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - border-radius: 4px; - line-height: 20px; - padding: 0 3px; - cursor: pointer; -} -.tiva-calendar-full .calendar-event-name span { - color: #ffffff; - font-size: 11px; - line-height: 20px; -} -.tiva-calendar-full .calendar-event-name.no-name { - opacity: 0; - visibility: hidden; -} -.tiva-calendar-full .calendar-event-name.color-1 { - background: #567BD2; -} -.tiva-calendar-full .calendar-event-name.color-2 { - background: #13baff; -} -.tiva-calendar-full .calendar-event-name.color-3 { - background: #669933; -} -.tiva-calendar-full .calendar-event-name.color-4 { - background: #ff8a23; -} -.tiva-calendar-full .calendar-event-name.first-day { - margin-right: -11px; - -moz-border-radius-topright: 0; - -webkit-border-top-right-radius: 0; - border-top-right-radius: 0; - -moz-border-radius-bottomright: 0; - -webkit-border-bottom-right-radius: 0; - border-bottom-right-radius: 0; -} -.tiva-calendar-full .calendar-event-name.middle-day { - margin-left: -11px; - margin-right: -11px; - -webkit-border-radius: 0; - -moz-border-radius: 0; - border-radius: 0; -} -.tiva-calendar-full .calendar-event-name.middle-day span { - opacity: 0; -} -.tiva-calendar-full .calendar-event-name.last-day { - margin-left: -11px; - -moz-border-radius-topleft: 0; - -webkit-border-top-left-radius: 0; - border-top-left-radius: 0; - -moz-border-radius-bottomleft: 0; - -webkit-border-bottom-left-radius: 0; - border-bottom-left-radius: 0; -} -.tiva-calendar-full .calendar-event-name.last-day span { - opacity: 0; -} - -/* Event list */ -.tiva-event-list-full { - padding: 15px; - background: #eeeeee; - display: none; -} -.tiva-event-list-full .event-item { - width: 100%; - border-top: 1px dotted #666; - margin-top: 20px; - padding-top: 20px; -} -.tiva-event-list-full .event-item:first-child { - border-top: none; - margin-top: 0; - padding-top: 0; -} -.tiva-event-list-full .event-item-left { - width: 20%; - margin-right: 2%; -} -.tiva-event-list-full .event-item-right { - width: 78%; -} -.tiva-event-list-full .event-image img { - width: 100%; - border: 1px solid #eee; -} -.tiva-event-list-full .event-name { - font-size: 17px; - color: #5AA4A3; - margin-bottom: 4px; -} -.tiva-event-list-full .event-time, .tiva-event-list-full .event-date { - margin-bottom: 3px; - color: #ef4f69; - font-size: 13px; -} -.tiva-event-list-full .event-time i, .tiva-event-list-full .event-date i { - margin-right: 5px; -} -.tiva-event-list-full .event-intro { - color: #666; - font-size: 14px; -} -.tiva-event-list-full .link { - cursor: pointer; -} - -/* Event detail */ -.tiva-event-detail-full { - padding: 15px; - background: #eeeeee; - display: none; -} -.tiva-event-detail-full .event-image { - text-align: center; - margin-bottom: 20px; -} -.tiva-event-detail-full .event-image img { - max-width: 100%; - border: 1px solid #eee; -} -.tiva-event-detail-full .event-name { - font-size: 22px; - color: #5AA4A3; - margin-bottom: 15px; -} -.tiva-event-detail-full .event-time, .tiva-event-detail-full .event-date, .tiva-event-detail-full .event-location { - margin-bottom: 5px; - color: #666; - font-size: 14px; -} -.tiva-event-detail-full .event-time i, .tiva-event-detail-full .event-date i, .tiva-event-detail-full .event-location i { - margin-right: 5px; - width: 14px; -} -.tiva-event-detail-full .event-location i { - font-size: 18px; -} -.tiva-event-detail-full .event-desc { - color: #666; - border-top: 1px solid #e2e2e2; - padding-top: 15px; - margin-top: 15px; - margin-bottom: 22px; - line-height: 22px; - font-size: 14px; -} -.tiva-event-detail-full .event-link { - margin-bottom: 30px; -} -.tiva-event-detail-full .event-link a { - color: #fff; - background: #5AA4A3; - padding: 8px 10px 8px 10px; - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - border-radius: 3px; - font-size: 14px; - border: 0; - cursor: pointer; - position: relative; -} -.tiva-event-detail-full .event-link a:hover { - text-decoration: none; -} -.tiva-event-detail-full .event-link a i { - margin-right: 5px; -} - -/* Responsive */ -@media (min-width: 768px) { - .tiva-event-list-full .event-item-left { - margin-right: 2% !important; - } - .tiva-event-list-full .event-item-left.pull-left, .tiva-event-list-full .event-item-right.pull-left { - float: left !important; - } -} -@media (max-width: 768px) { - .tiva-calendar-full .btn-change-date { - display: none; - } - .tiva-calendar-full .calendar-day-normal, .tiva-calendar-full .calendar-day-blank { - padding: 2px !important; - } - .tiva-calendar-full .calendar-table tr th { - padding: 5px 3px !important; - } - .tiva-event-list-full .event-item-left { - margin-bottom: 10px !important; - } - .tiva-event-list-full .event-item-left, .tiva-event-list-full .event-item-right { - width: 100%; - } -} diff --git a/lacommunaute/static/vendor/tiva-calendar/css/style.css b/lacommunaute/static/vendor/tiva-calendar/css/style.css deleted file mode 100644 index 03fa5891b..000000000 --- a/lacommunaute/static/vendor/tiva-calendar/css/style.css +++ /dev/null @@ -1,53 +0,0 @@ -body { - font-family: "Helvetica Neue",Helvetica,Arial,sans-serif; -} -.page-block-header { - padding: 15px 60px 40px 60px; - font-size: 18px; - font-weight: 200; - line-height: 30px; - color: inherit; - background-color: #eeeeee; - -webkit-border-radius: 6px; - -moz-border-radius: 6px; - border-radius: 6px; -} -.page-block-header h1 { - margin-bottom: 0; - font-size: 60px; - line-height: 1; - letter-spacing: -1px; - color: inherit; -} -.block-title { - font-size: 24px; - border-bottom: 1px solid #e2e2e2; - padding-bottom: 15px; - color: #666666; -} -.guide { - color: #666; - margin-bottom: 40px; -} -h4 { - border-bottom: 1px solid #e2e2e2; - padding-bottom: 8px; - color: #245269; - margin-top: 20px; -} -.code { - background-color: #f5f5f5; - border: 1px solid #ccc; - padding: 10px; - margin-bottom: 15px; - color: #5AA4A3; -} -.code-title { - color: #f0c674; -} -.code-attribute { - color: #567BD2; -} -.code-value { - color: #de935f; -} \ No newline at end of file diff --git a/lacommunaute/static/vendor/tiva-calendar/js/calendar.js b/lacommunaute/static/vendor/tiva-calendar/js/calendar.js deleted file mode 100644 index 68f54f873..000000000 --- a/lacommunaute/static/vendor/tiva-calendar/js/calendar.js +++ /dev/null @@ -1,890 +0,0 @@ -// Variable -var thisDate = 1; -var today = new Date(); -var todaysDay = today.getDay() + 1; -var todaysDate = today.getDate(); -var todaysMonth = today.getMonth() + 1; -var todaysYear = today.getFullYear(); - -var firstDate; -var firstDay; -var lastDate; -var numbDays; -var numevents = 0; -var daycounter = 0; -var calendarString = ""; - -var monthNum_full = todaysMonth; -var yearNum_full = todaysYear; -var monthNum_compact = todaysMonth; -var yearNum_compact = todaysYear; - -var tiva_events = []; -var order_num = 0; - -// Config variable -var wordDay; -var date_start; - -function getShortText(text, num) { - if (text) { - // Get num of word - var textArray = text.split(" "); - if (textArray.length > num) { - return textArray.slice(0, num).join(" ") + " ..."; - } - return text; - } - return ""; -} - -function sortEventsByDate(a, b) { - if (a.date < b.date) { - return -1; - } else if (a.date > b.date) { - return 1; - } else { - return 0; - } -} - -function sortEventsByUpcoming(a, b) { - var today_date = new Date(todaysYear, todaysMonth - 1, todaysDate); - if (Math.abs(a.date - today_date.getTime()) < Math.abs(b.date - today_date.getTime())) { - return -1; - } else if (Math.abs(a.date - today_date.getTime()) > Math.abs(b.date - today_date.getTime())) { - return 1; - } else { - return 0; - } -} - -function getEventsByTime(type) { - var events = []; - var today_date = new Date(todaysYear, todaysMonth - 1, todaysDate); - for (var i = 0; i < tiva_events.length; i++) { - if (type == 'upcoming') { - if (tiva_events[i].date >= today_date.getTime()) { - events.push(tiva_events[i]); - } - } else { - if (tiva_events[i].date < today_date.getTime()) { - events.push(tiva_events[i]); - } - } - } - return events; -} - -// Change month or year on calendar -function changedate(btn, layout) { - if (btn == "prevyr") { - eval("yearNum_" + layout + "--;"); - } else if (btn == "nextyr") { - eval("yearNum_" + layout + "++;"); - } else if (btn == "prevmo") { - eval("monthNum_" + layout + "--;"); - } else if (btn == "nextmo") { - eval("monthNum_" + layout + "++;"); - } else if (btn == "current") { - eval("monthNum_" + layout + " = todaysMonth;"); - eval("yearNum_" + layout + " = todaysYear;"); - } - - if (monthNum_full == 0) { - monthNum_full = 12; - yearNum_full--; - } else if (monthNum_full == 13) { - monthNum_full = 1; - yearNum_full++ - } - - if (monthNum_compact == 0) { - monthNum_compact = 12; - yearNum_compact--; - } else if (monthNum_compact == 13) { - monthNum_compact = 1; - yearNum_compact++ - } - - // Get first day and number days of month - eval("firstDate = new Date(yearNum_" + layout + ", monthNum_" + layout + " - 1, 1);"); - if (date_start == 'sunday') { - firstDay = firstDate.getDay() + 1; - } else { - firstDay = firstDate.getDay(); - } - eval("lastDate = new Date(yearNum_" + layout + ", monthNum_" + layout + ", 0);"); - numbDays = lastDate.getDate(); - - // Create calendar - eval("createCalendar(layout, firstDay, numbDays, monthNum_" + layout + ", yearNum_" + layout + ");"); - - return; -} - -// Create calendar -function createCalendar(layout, firstDay, numbDays, monthNum, yearNum) { - calendarString = ''; - daycounter = 0; - - calendarString += ''; - calendarString += ''; - calendarString += ''; - if (layout == 'full') { - calendarString += ''; - for (var m = 0; m < wordDay.length; m++) { - calendarString += ''; - for (var x = 1; x <= 7; x++) { - daycounter = (thisDate - firstDay) + 1; - thisDate++; - if ((daycounter > numbDays) || (daycounter < 1)) { - calendarString += ''; - calendarString += '
      « ' + prev_month + '<\/span><\/span><\/td>'; - calendarString += '<\/i>' + wordMonth[monthNum - 1] + '  ' + yearNum + '<\/span><\/td>'; - calendarString += '' + next_month + '<\/span> »<\/span><\/td>'; - } else { - calendarString += '«<\/span><\/td>'; - calendarString += '' + wordMonth[monthNum - 1] + '  ' + yearNum + '<\/span><\/td>'; - calendarString += '»<\/span><\/td>'; - } - calendarString += '<\/tr>'; - - calendarString += '
      ' + wordDay[m].substring(0, 3) + '<\/th>'; - } - calendarString += '<\/tr>'; - - thisDate == 1; - - for (var i = 1; i <= 6; i++) { - var k = (i - 1) * 7 + 1; - if (k < (firstDay + numbDays)) { - calendarString += '
       <\/td>'; - } else { - // Saturday or Sunday - if (date_start == 'sunday') { - if ((x == 1) || (x == 7)) { - daycounter_s = '' + daycounter + ''; - } else { - daycounter_s = daycounter; - } - } else { - if ((x == 6) || (x == 7)) { - daycounter_s = '' + daycounter + ''; - } else { - daycounter_s = daycounter; - } - } - - if ((todaysDate == daycounter) && (todaysMonth == monthNum)) { - calendarString += ''; - } else { - calendarString += ''; - } - if (checkEvents(daycounter, monthNum, yearNum)) { - if (layout == 'full') { - calendarString += '
      '; - } else { - calendarString += '
      '; - } - calendarString += daycounter_s; - - // Get events of day - if (layout == 'full') { - var events = getEvents(daycounter, monthNum, yearNum); - for (var t = 0; t < events.length; t++) { - if (typeof events[t] != "undefined") { - var color = events[t].color ? events[t].color : 1; - var event_class = "one-day"; - if (events[t].first_day && !events[t].last_day) { - event_class = "first-day"; - } else if (events[t].last_day && !events[t].first_day) { - event_class = "last-day"; - } else if (!events[t].first_day && !events[t].last_day) { - event_class = "middle-day"; - } - - calendarString += '
      ' + getShortText(events[t].name, 2) + '<\/div>'; - } else { - var event_fake; - if (typeof events[t + 1] != "undefined") { - if (typeof tiva_events[events[t + 1].id - 1] != "undefined") { - event_fake = getShortText(tiva_events[events[t + 1].id - 1].name, 2); - } else { - event_fake = "no-name"; - } - } else { - event_fake = "no-name"; - } - calendarString += '
      ' + event_fake + '
      '; - } - } - } else { - calendarString += ''; - } - - // Tooltip - calendarString += '
      <\/div>'; - calendarString += '<\/div>'; - } else { - calendarString += daycounter_s; - } - calendarString += '<\/td>'; - } - } - calendarString += '<\/tr>'; - } - } - calendarString += '
      '; - - if (layout == 'full') { - jQuery('.tiva-calendar-full').html(calendarString); - } else { - jQuery('.tiva-calendar-compact').html(calendarString); - } - thisDate = 1; -} - -// Check day has events or not -function checkEvents(day, month, year) { - numevents = 0; - var date_check = new Date(year, Number(month) - 1, day); - for (var i = 0; i < tiva_events.length; i++) { - var start_date = new Date(tiva_events[i].year, Number(tiva_events[i].month) - 1, tiva_events[i].day); - var end_date = new Date(tiva_events[i].year, Number(tiva_events[i].month) - 1, Number(tiva_events[i].day) + Number(tiva_events[i].duration) - 1); - if ((start_date.getTime() <= date_check.getTime()) && (date_check.getTime() <= end_date.getTime())) { - numevents++; - } - } - - if (numevents == 0) { - return false; - } else { - return true; - } -} - -function getOrderNumber(id, day, month, year) { - var date_check = new Date(year, Number(month) - 1, day); - var events = []; - for (var i = 0; i < tiva_events.length; i++) { - var start_date = new Date(tiva_events[i].year, Number(tiva_events[i].month) - 1, tiva_events[i].day); - var end_date = new Date(tiva_events[i].year, Number(tiva_events[i].month) - 1, Number(tiva_events[i].day) + Number(tiva_events[i].duration) - 1); - if ((start_date.getTime() <= date_check.getTime()) && (date_check.getTime() <= end_date.getTime())) { - var first_day = (start_date.getTime() == date_check.getTime()) ? true : false; - var event = { id: tiva_events[i].id, name: tiva_events[i].name, day: tiva_events[i].day, month: tiva_events[i].month, year: tiva_events[i].year, first_day: first_day }; - events.push(event); - } - } - - if (events.length) { - if (events[0].id == id) { - var num = order_num; - order_num = 0; - return num; - } else { - order_num++; - for (var j = 0; j < events.length; j++) { - if (events[j].id == id) { - return getOrderNumber(events[j - 1].id, events[j - 1].day, events[j - 1].month, events[j - 1].year); - } - } - - } - } - - return 0; -} - -// Get events of day -function getEvents(day, month, year) { - var n = 0; - var date_check = new Date(year, Number(month) - 1, day); - var events = []; - for (var i = 0; i < tiva_events.length; i++) { - var start_date = new Date(tiva_events[i].year, Number(tiva_events[i].month) - 1, tiva_events[i].day); - var end_date = new Date(tiva_events[i].year, Number(tiva_events[i].month) - 1, Number(tiva_events[i].day) + Number(tiva_events[i].duration) - 1); - if ((start_date.getTime() <= date_check.getTime()) && (date_check.getTime() <= end_date.getTime())) { - var first_day = (start_date.getTime() == date_check.getTime()) ? true : false; - var last_day = (end_date.getTime() == date_check.getTime()) ? true : false; - var event = { id: tiva_events[i].id, name: tiva_events[i].name, first_day: first_day, last_day: last_day, color: tiva_events[i].color }; - - if (!first_day) { - n = getOrderNumber(tiva_events[i].id, tiva_events[i].day, tiva_events[i].month, tiva_events[i].year); - } - - events[n] = event; - n++; - } - } - - return events; -} - -// Show tooltip when mouse over -function showTooltip(id, layout, day, month, year, el) { - if (layout == 'full') { - if (tiva_events[id].image) { - var event_image = '' + tiva_events[id].name + ''; - } else { - var event_image = ''; - } - if (tiva_events[id].time) { - var event_time = '
      ' + tiva_events[id].time + '
      '; - } else { - var event_time = ''; - } - - // Change position of tooltip - var index = jQuery(el).parent().find('.calendar-event-name').index(el); - var count = jQuery(el).parent().find('.calendar-event-name').length; - var bottom = 32 + ((count - index - 1) * 25); - jQuery(el).parent().find('.tiva-event-tooltip').css('bottom', bottom + 'px'); - - jQuery(el).parent().find('.tiva-event-tooltip').html('
      ' - + event_time - + '
      ' + tiva_events[id].name + '
      ' - + '
      ' + event_image + '
      ' - + '
      ' + getShortText(tiva_events[id].description, 10) + '
      ' - + '
      ' - ); - jQuery(el).parent().find('.tiva-event-tooltip').css('opacity', '1'); - jQuery(el).parent().find('.tiva-event-tooltip').css('-webkit-transform', 'translate3d(0,0,0) rotate3d(0,0,0,0)'); - jQuery(el).parent().find('.tiva-event-tooltip').css('transform', 'translate3d(0,0,0) rotate3d(0,0,0,0)'); - } else { - jQuery(el).find('.tiva-event-tooltip').html(''); - var events = getEvents(day, month, year); - for (var i = 0; i < events.length; i++) { - if (typeof events[i] != "undefined") { - if (tiva_events[events[i].id].image) { - var event_image = '' + tiva_events[events[i].id].name + ''; - } else { - var event_image = ''; - } - if (tiva_events[events[i].id].time) { - var event_time = '
      ' + tiva_events[events[i].id].time + '
      '; - } else { - var event_time = ''; - } - - jQuery(el).find('.tiva-event-tooltip').append('
      ' - + event_time - + '
      ' + tiva_events[events[i].id].name + '
      ' - + '
      ' + event_image + '
      ' - + '
      ' + getShortText(tiva_events[events[i].id].description, 10) + '
      ' - + '
      ' - ); - } - } - jQuery(el).find('.tiva-event-tooltip').css('opacity', '1'); - jQuery(el).find('.tiva-event-tooltip').css('-webkit-transform', 'translate3d(0,0,0) rotate3d(0,0,0,0)'); - jQuery(el).find('.tiva-event-tooltip').css('transform', 'translate3d(0,0,0) rotate3d(0,0,0,0)'); - } -} - -// Clear tooltip when mouse out -function clearTooltip(layout, el) { - if (layout == 'full') { - jQuery(el).parent().find('.tiva-event-tooltip').css('opacity', '0'); - jQuery(el).parent().find('.tiva-event-tooltip').css('-webkit-transform', 'translate3d(0,-10px,0)'); - jQuery(el).parent().find('.tiva-event-tooltip').css('transform', 'translate3d(0,-10px,0)'); - } else { - jQuery(el).find('.tiva-event-tooltip').css('opacity', '0'); - jQuery(el).find('.tiva-event-tooltip').css('-webkit-transform', 'translate3d(0,-10px,0)'); - jQuery(el).find('.tiva-event-tooltip').css('transform', 'translate3d(0,-10px,0)'); - } -} - -// Show event detail -function showEventList(layout, max_events) { - // Sort event via upcoming - var upcoming_events = getEventsByTime('upcoming'); - upcoming_events.sort(sortEventsByUpcoming); - var past_events = getEventsByTime('past'); - past_events.sort(sortEventsByUpcoming); - var tiva_list_events = upcoming_events.concat(past_events); - tiva_list_events = tiva_list_events.slice(0, max_events); - - if (layout == 'full') { - jQuery('.tiva-event-list-full').html(''); - for (var i = 0; i < tiva_list_events.length; i++) { - // Start date - var day = new Date(tiva_list_events[i].year, Number(tiva_list_events[i].month) - 1, tiva_list_events[i].day); - if (date_start == 'sunday') { - var event_day = wordDay[day.getDay()]; - } else { - if (day.getDay() > 0) { - var event_day = wordDay[day.getDay() - 1]; - } else { - var event_day = wordDay[6]; - } - } - var event_date = wordMonth[Number(tiva_list_events[i].month) - 1] + ' ' + tiva_list_events[i].day + ', ' + tiva_list_events[i].year; - - // End date - var event_end_time = ''; - if (tiva_list_events[i].duration > 1) { - var end_date = new Date(tiva_list_events[i].year, Number(tiva_list_events[i].month) - 1, Number(tiva_list_events[i].day) + Number(tiva_list_events[i].duration) - 1); - - if (date_start == 'sunday') { - var event_end_day = wordDay[end_date.getDay()]; - } else { - if (end_date.getDay() > 0) { - var event_end_day = wordDay[end_date.getDay() - 1]; - } else { - var event_end_day = wordDay[6]; - } - } - var event_end_date = wordMonth[Number(end_date.getMonth())] + ' ' + end_date.getDate() + ', ' + end_date.getFullYear(); - event_end_time = ' - ' + event_end_day + ', ' + event_end_date; - } - - // Event time - if (tiva_list_events[i].time) { - var event_time = '' + tiva_list_events[i].time; - } else { - var event_time = ''; - } - - // Event image - if (tiva_list_events[i].image) { - var event_image = '' + tiva_list_events[i].name + ''; - } else { - var event_image = ''; - } - - // Event location - if (tiva_list_events[i].location) { - var event_location = '' + '' + tiva_list_events[i].location + ''; - } else { - var event_location = ''; - } - - jQuery('.tiva-event-list-full').append('
      ' - + '
      ' - + '' - + '
      ' - + '
      ' - + '' - + '
      ' + event_day + ', ' + event_date + event_end_time + '
      ' - + '
      ' + event_time + '
      ' - + '
      ' + event_location + '
      ' - + '
      ' + getShortText(tiva_list_events[i].description, 25) + '
      ' - + '
      ' - + '
      ' - + '
      ' - ); - } - } else { - jQuery('.tiva-event-list-compact').html(''); - for (var i = 0; i < tiva_list_events.length; i++) { - // Start date - var day = new Date(tiva_list_events[i].year, Number(tiva_list_events[i].month) - 1, tiva_list_events[i].day); - if (date_start == 'sunday') { - var event_day = wordDay[day.getDay()]; - } else { - if (day.getDay() > 0) { - var event_day = wordDay[day.getDay() - 1]; - } else { - var event_day = wordDay[6]; - } - } - var event_date = wordMonth[Number(tiva_list_events[i].month) - 1] + ' ' + tiva_list_events[i].day + ', ' + tiva_list_events[i].year; - - // End date - var event_end_time = ''; - if (tiva_list_events[i].duration > 1) { - var end_date = new Date(tiva_list_events[i].year, Number(tiva_list_events[i].month) - 1, Number(tiva_list_events[i].day) + Number(tiva_list_events[i].duration) - 1); - - if (date_start == 'sunday') { - var event_end_day = wordDay[end_date.getDay()]; - } else { - if (end_date.getDay() > 0) { - var event_end_day = wordDay[end_date.getDay() - 1]; - } else { - var event_end_day = wordDay[6]; - } - } - var event_end_date = wordMonth[Number(end_date.getMonth())] + ' ' + end_date.getDate() + ', ' + end_date.getFullYear(); - event_end_time = ' - ' + event_end_day + ', ' + event_end_date; - } - - // Event time - if (tiva_list_events[i].time) { - var event_time = '' + tiva_list_events[i].time; - } else { - var event_time = ''; - } - - // Event image - if (tiva_list_events[i].image) { - var event_image = '' + tiva_list_events[i].name + ''; - } else { - var event_image = ''; - } - - // Event location - if (tiva_list_events[i].location) { - var event_location = '' + '' + tiva_list_events[i].location + ''; - } else { - var event_location = ''; - } - - jQuery('.tiva-event-list-compact').append('
      ' - + '' - + '' - + '
      ' + event_day + ', ' + event_date + event_end_time + '
      ' - + '
      ' + event_time + '
      ' - + '
      ' + event_location + '
      ' - + '
      ' + getShortText(tiva_list_events[i].description, 15) + '
      ' - + '
      ' - + '
      ' - ); - } - } -} - -// Show event detail -function showEventDetail(id, layout, day, month, year) { - jQuery('.tiva-events-calendar.' + layout + ' .back-calendar').show(); - jQuery('.tiva-events-calendar.' + layout + ' .tiva-calendar').hide(); - jQuery('.tiva-events-calendar.' + layout + ' .tiva-event-list').hide(); - jQuery('.tiva-events-calendar.' + layout + ' .tiva-event-detail').fadeIn(1500); - - jQuery('.tiva-events-calendar.' + layout + ' .list-view').removeClass('active'); - jQuery('.tiva-events-calendar.' + layout + ' .calendar-view').removeClass('active'); - - if (layout == 'full') { - // Start date - var day = new Date(tiva_events[id].year, Number(tiva_events[id].month) - 1, tiva_events[id].day); - if (date_start == 'sunday') { - var event_day = wordDay[day.getDay()]; - } else { - if (day.getDay() > 0) { - var event_day = wordDay[day.getDay() - 1]; - } else { - var event_day = wordDay[6]; - } - } - var event_date = wordMonth[Number(tiva_events[id].month) - 1] + ' ' + tiva_events[id].day + ', ' + tiva_events[id].year; - - // End date - var event_end_time = ''; - if (tiva_events[id].duration > 1) { - var end_date = new Date(tiva_events[id].year, Number(tiva_events[id].month) - 1, Number(tiva_events[id].day) + Number(tiva_events[id].duration) - 1); - - if (date_start == 'sunday') { - var event_end_day = wordDay[end_date.getDay()]; - } else { - if (end_date.getDay() > 0) { - var event_end_day = wordDay[end_date.getDay() - 1]; - } else { - var event_end_day = wordDay[6]; - } - } - var event_end_date = wordMonth[Number(end_date.getMonth())] + ' ' + end_date.getDate() + ', ' + end_date.getFullYear(); - event_end_time = ' - ' + event_end_day + ', ' + event_end_date; - } - - // Event time - if (tiva_events[id].time) { - var event_time = '' + tiva_events[id].time; - } else { - var event_time = ''; - } - - // Event image - if (tiva_events[id].image) { - var event_image = '' + tiva_events[id].name + ''; - } else { - var event_image = ''; - } - - // Event location - if (tiva_events[id].location) { - var event_location = '' + '' + tiva_events[id].location + ''; - } else { - var event_location = ''; - } - - // Event description - if (tiva_events[id].description) { - var event_desc = '
      ' + tiva_events[id].description + '
      '; - } else { - var event_desc = ''; - } - - jQuery('.tiva-event-detail-full').html('
      ' - + '
      ' + event_image + '
      ' - + '
      ' + tiva_events[id].name + '
      ' - + '
      ' + event_day + ', ' + event_date + event_end_time + '
      ' - + '
      ' + event_time + '
      ' - + '
      ' + event_location + '
      ' - + event_desc - + '
      ' - ); - } else { - jQuery('.tiva-event-detail-compact').html(''); - if (day && month && year) { - var events = getEvents(day, month, year); - } else { - var events = [{ id: id }]; - } - for (var i = 0; i < events.length; i++) { - if (typeof events[i] != "undefined") { - // Start date - var day = new Date(tiva_events[events[i].id].year, Number(tiva_events[events[i].id].month) - 1, tiva_events[events[i].id].day); - if (date_start == 'sunday') { - var event_day = wordDay[day.getDay()]; - } else { - if (day.getDay() > 0) { - var event_day = wordDay[day.getDay() - 1]; - } else { - var event_day = wordDay[6]; - } - } - var event_date = wordMonth[Number(tiva_events[events[i].id].month) - 1] + ' ' + tiva_events[events[i].id].day + ', ' + tiva_events[events[i].id].year; - - // End date - var event_end_time = ''; - if (tiva_events[events[i].id].duration > 1) { - var end_date = new Date(tiva_events[events[i].id].year, Number(tiva_events[events[i].id].month) - 1, Number(tiva_events[events[i].id].day) + Number(tiva_events[events[i].id].duration) - 1); - - if (date_start == 'sunday') { - var event_end_day = wordDay[end_date.getDay()]; - } else { - if (end_date.getDay() > 0) { - var event_end_day = wordDay[end_date.getDay() - 1]; - } else { - var event_end_day = wordDay[6]; - } - } - var event_end_date = wordMonth[Number(end_date.getMonth())] + ' ' + end_date.getDate() + ', ' + end_date.getFullYear(); - event_end_time = ' - ' + event_end_day + ', ' + event_end_date; - } - - // Event time - if (tiva_events[events[i].id].time) { - var event_time = '' + tiva_events[events[i].id].time; - } else { - var event_time = ''; - } - - // Event image - if (tiva_events[events[i].id].image) { - var event_image = '' + tiva_events[events[i].id].name + ''; - } else { - var event_image = ''; - } - - // Event location - if (tiva_events[events[i].id].location) { - var event_location = '' + '' + tiva_events[events[i].id].location; + ''; - } else { - var event_location = ''; - } - - // Event description - if (tiva_events[events[i].id].description) { - var event_desc = '
      ' + tiva_events[events[i].id].description + '
      '; - } else { - var event_desc = ''; - } - - jQuery('.tiva-event-detail-compact').append('
      ' - + '
      ' + event_image + '
      ' - + '
      ' + tiva_events[events[i].id].name + '
      ' - + '
      ' + event_day + ', ' + event_date + event_end_time + '
      ' - + '
      ' + event_time + '
      ' - + '
      ' + event_location + '
      ' - + event_desc - + '
      ' - ); - } - } - } -} - -jQuery(document).ready(function () { - // Init calendar full - if (jQuery('.tiva-events-calendar.full').length) { - jQuery('.tiva-events-calendar.full').html('
      ' - + '' + calendar_view + '' - + '' + list_view + '' - + '' + back + '' - + '
      ' - + '
      ' - + '
      ' - + '
      ' - + '
      ' - + '
      ' - + '
      ' - ); - } - - // Init calendar compact - if (jQuery('.tiva-events-calendar.compact').length) { - jQuery('.tiva-events-calendar.compact').html('
      ' - + '' + calendar_view + '' - + '' + list_view + '' - + '' + back + '' - + '
      ' - + '
      ' - + '
      ' - + '
      ' - + '
      ' - + '
      ' - + '
      ' - ); - } - - // Show - Hide view - jQuery('.tiva-events-calendar .back-calendar').hide(); - jQuery('.tiva-event-list').hide(); - jQuery('.tiva-event-detail').hide(); - - jQuery('.tiva-events-calendar').each(function (index) { - // Hide switch button - var switch_button = (typeof jQuery(this).attr('data-switch') != "undefined") ? jQuery(this).attr('data-switch') : 'show'; - if (switch_button == 'hide') { - jQuery(this).find('.calendar-view').hide(); - jQuery(this).find('.list-view').hide(); - - // Change css of button back - jQuery(this).find('.events-calendar-bar').css('position', 'relative'); - jQuery(this).find('.back-calendar').css({ "position": "absolute", "margin-top": "15px", "right": "15px" }); - jQuery(this).find('.tiva-event-detail').css('padding-top', '60px'); - } - }); - - // Set wordDay - date_start = (typeof jQuery('.tiva-events-calendar').attr('data-start') != "undefined") ? jQuery('.tiva-events-calendar').attr('data-start') : 'sunday'; - if (date_start == 'sunday') { - wordDay = new Array(wordDay_sun, wordDay_mon, wordDay_tue, wordDay_wed, wordDay_thu, wordDay_fri, wordDay_sat); - } else { // Start with Monday - wordDay = new Array(wordDay_mon, wordDay_tue, wordDay_wed, wordDay_thu, wordDay_fri, wordDay_sat, wordDay_sun); - } - - // Get events from json file or ajax php - var source = (typeof jQuery('.tiva-events-calendar').attr('data-source') != "undefined") ? jQuery('.tiva-events-calendar').attr('data-source') : 'json'; - if (source == 'json') { // Get events from json file : events/events.json - console.log(events_json) - jQuery.getJSON(events_json, function (data) { - for (var i = 0; i < data.items.length; i++) { - var event_date = new Date(data.items[i].year, Number(data.items[i].month) - 1, data.items[i].day); - data.items[i].date = event_date.getTime(); - tiva_events.push(data.items[i]); - } - - // Sort events by date - tiva_events.sort(sortEventsByDate); - - for (var j = 0; j < tiva_events.length; j++) { - tiva_events[j].id = j; - if (!tiva_events[j].duration) { - tiva_events[j].duration = 1; - } - } - - // Create calendar - changedate('current', 'full'); - changedate('current', 'compact'); - - jQuery('.tiva-events-calendar').each(function (index) { - // Initial view - var initial_view = (typeof jQuery(this).attr('data-view') != "undefined") ? jQuery(this).attr('data-view') : 'calendar'; - if (initial_view == 'list') { - jQuery(this).find('.list-view').click(); - } - }); - }); - } else { // Get events from php file via ajax - jQuery.ajax({ - url: events_php, - dataType: 'json', - data: '', - beforeSend: function () { - jQuery('.tiva-calendar').html('
      '); - }, - success: function (data) { - for (var i = 0; i < data.length; i++) { - var event_date = new Date(data[i].year, Number(data[i].month) - 1, data[i].day); - data[i].date = event_date.getTime(); - tiva_events.push(data[i]); - } - - // Sort events by date - tiva_events.sort(sortEventsByDate); - - for (var j = 0; j < tiva_events.length; j++) { - tiva_events[j].id = j; - if (!tiva_events[j].duration) { - tiva_events[j].duration = 1; - } - } - - // Create calendar - changedate('current', 'full'); - changedate('current', 'compact'); - - jQuery('.tiva-events-calendar').each(function (index) { - // Initial view - var initial_view = (typeof jQuery(this).attr('data-view') != "undefined") ? jQuery(this).attr('data-view') : 'calendar'; - if (initial_view == 'list') { - jQuery(this).find('.list-view').click(); - } - }); - } - }); - } - - // Click - Calendar view btn - jQuery('.tiva-events-calendar .calendar-view').click(function () { - jQuery(this).parents('.tiva-events-calendar').find('.back-calendar').hide(); - jQuery(this).parents('.tiva-events-calendar').find('.tiva-event-list').hide(); - jQuery(this).parents('.tiva-events-calendar').find('.tiva-event-detail').hide(); - jQuery(this).parents('.tiva-events-calendar').find('.tiva-calendar').fadeIn(1500); - - jQuery(this).parents('.tiva-events-calendar').find('.list-view').removeClass('active'); - jQuery(this).parents('.tiva-events-calendar').find('.calendar-view').addClass('active'); - }); - - // Click - List view btn - jQuery('.tiva-events-calendar .list-view').click(function () { - jQuery(this).parents('.tiva-events-calendar').find('.back-calendar').hide(); - jQuery(this).parents('.tiva-events-calendar').find('.tiva-calendar').hide(); - jQuery(this).parents('.tiva-events-calendar').find('.tiva-event-detail').hide(); - jQuery(this).parents('.tiva-events-calendar').find('.tiva-event-list').fadeIn(1500); - - jQuery(this).parents('.tiva-events-calendar').find('.calendar-view').removeClass('active'); - jQuery(this).parents('.tiva-events-calendar').find('.list-view').addClass('active'); - - var layout = jQuery(this).parents('.tiva-events-calendar').attr('class') ? jQuery(this).parents('.tiva-events-calendar').attr('class') : 'full'; - var max_events = jQuery(this).parents('.tiva-events-calendar').attr('data-events') ? jQuery(this).parents('.tiva-events-calendar').attr('data-events') : 1000; - if (layout.indexOf('full') != -1) { - showEventList('full', max_events); - } else { - showEventList('compact', max_events); - } - }); - - // Click - Back calendar btn - jQuery('.tiva-events-calendar .back-calendar').click(function () { - jQuery(this).parents('.tiva-events-calendar').find('.back-calendar').hide(); - jQuery(this).parents('.tiva-events-calendar').find('.tiva-event-detail').hide(); - - var initial_view = (typeof jQuery(this).parents('.tiva-events-calendar').attr('data-view') != "undefined") ? jQuery(this).parents('.tiva-events-calendar').attr('data-view') : 'calendar'; - if (initial_view == 'calendar') { - jQuery(this).parents('.tiva-events-calendar').find('.tiva-calendar').fadeIn(1500); - - jQuery(this).parents('.tiva-events-calendar').find('.list-view').removeClass('active'); - jQuery(this).parents('.tiva-events-calendar').find('.calendar-view').addClass('active'); - } else { - jQuery(this).parents('.tiva-events-calendar').find('.tiva-event-list').fadeIn(1500); - - jQuery(this).parents('.tiva-events-calendar').find('.calendar-view').removeClass('active'); - jQuery(this).parents('.tiva-events-calendar').find('.list-view').addClass('active'); - } - }); - -}); diff --git a/lacommunaute/static/vendor/tiva-calendar/js/config.js b/lacommunaute/static/vendor/tiva-calendar/js/config.js deleted file mode 100644 index ea6de9e0c..000000000 --- a/lacommunaute/static/vendor/tiva-calendar/js/config.js +++ /dev/null @@ -1,3 +0,0 @@ -// Path of events source -var events_json = "events/events.json"; -var events_php = "events/events.php"; diff --git a/lacommunaute/static/vendor/tiva-calendar/languages/en.js b/lacommunaute/static/vendor/tiva-calendar/languages/en.js deleted file mode 100644 index 1ecb67dea..000000000 --- a/lacommunaute/static/vendor/tiva-calendar/languages/en.js +++ /dev/null @@ -1,20 +0,0 @@ -// Day, Month -var wordMonth = new Array("Janvier", "Février", "Mars", "Avril", "Mai", "Juin", "Juillet", "Août", "Septembre", "Octobre", "Novembre", "Décembre"); -var wordDay_sun = "Dimanche"; -var wordDay_mon = "Lundi"; -var wordDay_tue = "Mardi"; -var wordDay_wed = "Mercredi"; -var wordDay_thu = "Jeudi"; -var wordDay_fri = "Vendredi"; -var wordDay_sat = "Samedi"; - -// View Button -var calendar_view = "Calendrier" -var list_view = "Liste" -var back = "Retour" - -// Calendar Button -var prev_year = "Année Précédente" -var prev_month = "Mois Précédent" -var next_month = "Mois Suivant" -var next_year = "Année Suivante" diff --git a/lacommunaute/templates/event/event_calendar.html b/lacommunaute/templates/event/event_calendar.html deleted file mode 100644 index 33cf81a25..000000000 --- a/lacommunaute/templates/event/event_calendar.html +++ /dev/null @@ -1,55 +0,0 @@ -{% extends "layouts/base.html" %} -{% load i18n %} -{% load static %} -{% load str_filters %} - -{% block title %}{% trans "calendar" %}{{ block.super }}{% endblock %} - -{% block content %} -
      -
      -
      -
      -

      Les évènements à venir

      -
      -
      -
      -
      - -
      -
      -
      -
      -
      -
      -
      -
      -
      - - -
      - -
      - -{% endblock content %} - -{% block extra_css %} - - - - -{% endblock %} -{% block extra_js %} - - - -{% endblock %} From e0b937de91b2cb8baa40ba245e4cb3e02a4f4ba3 Mon Sep 17 00:00:00 2001 From: vincent porte Date: Mon, 2 Oct 2023 11:46:11 +0200 Subject: [PATCH 7/8] [EVENT] remove unused EventCurrentUpcomingManager --- lacommunaute/event/models.py | 8 -------- lacommunaute/event/tests/tests_model.py | 21 --------------------- 2 files changed, 29 deletions(-) diff --git a/lacommunaute/event/models.py b/lacommunaute/event/models.py index b678596c9..b29c5b6c0 100644 --- a/lacommunaute/event/models.py +++ b/lacommunaute/event/models.py @@ -1,15 +1,8 @@ from django.conf import settings from django.db import models -from django.db.models.functions import TruncMonth -from django.utils import timezone from machina.models.abstract_models import DatedModel -class CurrentUpcomingManager(models.Manager): - def get_queryset(self): - return super().get_queryset().filter(date__gte=TruncMonth(timezone.now())) - - class Event(DatedModel): name = models.CharField(max_length=100, verbose_name="Nom") date = models.DateField(verbose_name="Date de début", help_text="au format JJ/MM/YYYY") @@ -27,7 +20,6 @@ class Event(DatedModel): ) objects = models.Manager() - current_and_upcomings = CurrentUpcomingManager() class Meta: verbose_name = "Event" diff --git a/lacommunaute/event/tests/tests_model.py b/lacommunaute/event/tests/tests_model.py index c19ce8310..501dff72b 100644 --- a/lacommunaute/event/tests/tests_model.py +++ b/lacommunaute/event/tests/tests_model.py @@ -1,28 +1,7 @@ -from dateutil.relativedelta import relativedelta from django.db import IntegrityError from django.test import TestCase -from django.utils import timezone from lacommunaute.event.factories import EventFactory -from lacommunaute.event.models import Event - - -class EventCurrentUpcomingManagerTest(TestCase): - def test_manager(self): - now = timezone.now() - - EventFactory(date=now) - - old_event = EventFactory(date=now - relativedelta(months=1)) - - # upcomming event - EventFactory(date=now + relativedelta(months=1)) - - # Event at the beginning of the current month - EventFactory(date=now.replace(now.year, now.month, 1)) - - self.assertEqual(Event.current_and_upcomings.count(), 3) - self.assertNotIn(old_event, Event.current_and_upcomings.all()) class EventModelTest(TestCase): From cd5d8b43d62739ccd8f4c36c8fb7ada392bae924 Mon Sep 17 00:00:00 2001 From: vincent porte Date: Mon, 2 Oct 2023 11:46:39 +0200 Subject: [PATCH 8/8] [EVENT] update event_form template --- lacommunaute/templates/event/event_form.html | 24 ++++++++++++-------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/lacommunaute/templates/event/event_form.html b/lacommunaute/templates/event/event_form.html index 9ae224ea2..882c224cd 100644 --- a/lacommunaute/templates/event/event_form.html +++ b/lacommunaute/templates/event/event_form.html @@ -49,15 +49,21 @@

      {% trans "Post a new Public Event" %} -
      - - {% if event %} - {% trans "Delete" %} - {% endif %} +
      +
      + {% if event %} + + {% endif %} +
      +