From e8b94ac0a2ac7602aac5fedcef2800a44a7aea02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20H=C3=A4ttasch?= <benjamin.haettasch@fachschaft.informatik.tu-darmstadt.de> Date: Sat, 20 Apr 2024 17:04:02 +0200 Subject: [PATCH] Fix event wizard date picker (remove dependency) Use plain html functionality instead of bootsrap datepicker. Remove datepicker dependency. This resolves #200 (datepicker not loading since load from CDN is blocked by CSP). Improve how form media is loaded in event wizard. Additionally, improve which fields are shown (and how) in event wizard. --- AKModel/forms.py | 14 ++++++++++---- .../admin/AKModel/event_wizard/activate.html | 7 +++++-- .../event_wizard/created_prepare_import.html | 7 +++++-- .../admin/AKModel/event_wizard/import.html | 7 +++++-- .../admin/AKModel/event_wizard/settings.html | 7 +++++-- .../admin/AKModel/event_wizard/start.html | 5 +++++ AKPlanning/settings.py | 1 - 7 files changed, 35 insertions(+), 13 deletions(-) diff --git a/AKModel/forms.py b/AKModel/forms.py index f5475668..24074ecd 100644 --- a/AKModel/forms.py +++ b/AKModel/forms.py @@ -5,7 +5,6 @@ Central and admin forms import csv import io -from bootstrap_datepicker_plus.widgets import DateTimePickerInput from django import forms from django.forms.utils import ErrorList from django.utils.translation import gettext_lazy as _ @@ -14,6 +13,10 @@ from AKModel.availability.forms import AvailabilitiesFormMixin from AKModel.models import Event, AKCategory, AKRequirement, Room +class DateTimeInput(forms.DateInput): + input_type = 'datetime-local' + + class NewEventWizardStartForm(forms.ModelForm): """ Initial view of new event wizard @@ -47,14 +50,17 @@ class NewEventWizardSettingsForm(forms.ModelForm): class Meta: model = Event fields = "__all__" + exclude = ['plan_published_at'] widgets = { 'name': forms.HiddenInput(), 'slug': forms.HiddenInput(), 'timezone': forms.HiddenInput(), 'active': forms.HiddenInput(), - 'start': DateTimePickerInput(options={"format": "YYYY-MM-DD HH:mm"}), - 'end': DateTimePickerInput(options={"format": "YYYY-MM-DD HH:mm"}), - 'reso_deadline': DateTimePickerInput(options={"format": "YYYY-MM-DD HH:mm"}), + 'start': DateTimeInput(), + 'end': DateTimeInput(), + 'interest_start': DateTimeInput(), + 'interest_end': DateTimeInput(), + 'reso_deadline': DateTimeInput(), 'plan_hidden': forms.HiddenInput(), } diff --git a/AKModel/templates/admin/AKModel/event_wizard/activate.html b/AKModel/templates/admin/AKModel/event_wizard/activate.html index 44c08a31..9a2bd7d3 100644 --- a/AKModel/templates/admin/AKModel/event_wizard/activate.html +++ b/AKModel/templates/admin/AKModel/event_wizard/activate.html @@ -8,6 +8,11 @@ {% block title %}{% trans "New event wizard" %}: {{ wizard_step_text }}{% endblock %} +{% block extrahead %} + {{ block.super }} + {{ form.media }} +{% endblock %} + {% block content %} {% include "admin/AKModel/event_wizard/wizard_steps.html" %} @@ -17,8 +22,6 @@ <h5 class="mb-3">{% trans "Successfully imported.<br><br>Do you want to activate your event now?" %}</h5> - {{ form.media }} - <form method="post">{% csrf_token %} {% bootstrap_form form %} diff --git a/AKModel/templates/admin/AKModel/event_wizard/created_prepare_import.html b/AKModel/templates/admin/AKModel/event_wizard/created_prepare_import.html index 75e93653..81dee9af 100644 --- a/AKModel/templates/admin/AKModel/event_wizard/created_prepare_import.html +++ b/AKModel/templates/admin/AKModel/event_wizard/created_prepare_import.html @@ -8,6 +8,11 @@ {% block title %}{% trans "New event wizard" %}: {{ wizard_step_text }}{% endblock %} +{% block extrahead %} + {{ block.super }} + {{ form.media }} +{% endblock %} + {% block content %} {% include "admin/AKModel/event_wizard/wizard_steps.html" %} @@ -29,8 +34,6 @@ <h5 class="mb-3">{% trans "Your event was created and can now be further configured." %}</h5> - {{ form.media }} - <form method="post">{% csrf_token %} {% bootstrap_form form %} diff --git a/AKModel/templates/admin/AKModel/event_wizard/import.html b/AKModel/templates/admin/AKModel/event_wizard/import.html index c99ca2b2..56d708ed 100644 --- a/AKModel/templates/admin/AKModel/event_wizard/import.html +++ b/AKModel/templates/admin/AKModel/event_wizard/import.html @@ -8,11 +8,14 @@ {% block title %}{% trans "New event wizard" %}: {{ wizard_step_text }}{% endblock %} +{% block extrahead %} + {{ block.super }} + {{ form.media }} +{% endblock %} + {% block content %} {% include "admin/AKModel/event_wizard/wizard_steps.html" %} - {{ form.media }} - <form method="post">{% csrf_token %} {% bootstrap_form form %} diff --git a/AKModel/templates/admin/AKModel/event_wizard/settings.html b/AKModel/templates/admin/AKModel/event_wizard/settings.html index df5f9cae..1eab4747 100644 --- a/AKModel/templates/admin/AKModel/event_wizard/settings.html +++ b/AKModel/templates/admin/AKModel/event_wizard/settings.html @@ -8,11 +8,14 @@ {% block title %}{% trans "New event wizard" %}: {{ wizard_step_text }}{% endblock %} +{% block extrahead %} + {{ block.super }} + {{ form.media }} +{% endblock %} + {% block content %} {% include "admin/AKModel/event_wizard/wizard_steps.html" %} - {{ form.media }} - {% timezone timezone %} <form method="post">{% csrf_token %} diff --git a/AKModel/templates/admin/AKModel/event_wizard/start.html b/AKModel/templates/admin/AKModel/event_wizard/start.html index 6389a2ee..db9eca6e 100644 --- a/AKModel/templates/admin/AKModel/event_wizard/start.html +++ b/AKModel/templates/admin/AKModel/event_wizard/start.html @@ -7,6 +7,11 @@ {% block title %}{% trans "New event wizard" %}: {{ wizard_step_text }}{% endblock %} +{% block extrahead %} + {{ block.super }} + {{ form.media }} +{% endblock %} + {% block content %} {% include "admin/AKModel/event_wizard/wizard_steps.html" %} diff --git a/AKPlanning/settings.py b/AKPlanning/settings.py index 3dc46aa5..4cb4bb30 100644 --- a/AKPlanning/settings.py +++ b/AKPlanning/settings.py @@ -52,7 +52,6 @@ INSTALLED_APPS = [ 'rest_framework', 'simple_history', 'registration', - 'bootstrap_datepicker_plus', 'django_tex', 'compressor', 'docs', -- GitLab