diff --git a/src/agenda_culturel/migrations/0011_alter_event_category.py b/src/agenda_culturel/migrations/0011_alter_event_category.py new file mode 100644 index 0000000..ec340b9 --- /dev/null +++ b/src/agenda_culturel/migrations/0011_alter_event_category.py @@ -0,0 +1,19 @@ +# Generated by Django 4.2.1 on 2023-11-08 11:24 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('agenda_culturel', '0010_remove_category_plural_category_alt_name'), + ] + + operations = [ + migrations.AlterField( + model_name='event', + name='category', + field=models.ForeignKey(default=47, help_text='Category of the event', on_delete=django.db.models.deletion.SET_DEFAULT, to='agenda_culturel.category', verbose_name='Category'), + ), + ] diff --git a/src/agenda_culturel/static/style.scss b/src/agenda_culturel/static/style.scss index 45f3195..5177e8b 100644 --- a/src/agenda_culturel/static/style.scss +++ b/src/agenda_culturel/static/style.scss @@ -234,16 +234,25 @@ article.day>ul { @media only screen and (prefers-color-scheme: light) { [data-theme="light"], :root:not([data-theme="dark"]) { - .filter summary:after { + #filters summary:after { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='24' viewBox='0 0 24 24' fill='none' stroke='#{to-rgb($black)}' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); } } } -article.filter { - form>div { +article#filters { + .buttons-filter { + float: right; + text-align: right; + } + form>label { + display: inline-block; + } + .options-filter { + clear: both; padding: 0.5em; - [role="button"] { + + [role="button"].small-cat { margin: 0.2em; height: 2.6em; line-height: 2.2em; diff --git a/src/agenda_culturel/templates/agenda_culturel/filter-inc.html b/src/agenda_culturel/templates/agenda_culturel/filter-inc.html index 7e71c73..b934146 100644 --- a/src/agenda_culturel/templates/agenda_culturel/filter-inc.html +++ b/src/agenda_culturel/templates/agenda_culturel/filter-inc.html @@ -1,7 +1,7 @@ {% load cat_extra %} {% load tag_extra %} -
+
{% if filter.is_active %} diff --git a/src/agenda_culturel/templates/agenda_culturel/forms/category-checkbox.html b/src/agenda_culturel/templates/agenda_culturel/forms/category-checkbox.html index ad3c365..abedf2d 100644 --- a/src/agenda_culturel/templates/agenda_culturel/forms/category-checkbox.html +++ b/src/agenda_culturel/templates/agenda_culturel/forms/category-checkbox.html @@ -1,5 +1,15 @@ {% load cat_extra %} -
{% for group, options, index in widget.optgroups %}{% if group %} +
+ + +
+
{% for group, options, index in widget.optgroups %}{% if group %}
{% endif %}{% for widget in options %}
{{ widget.value.instance | circle_cat }}{% include widget.template_name %}
{% endfor %}{% if group %}
{% endif %}{% endfor %} diff --git a/src/agenda_culturel/templates/agenda_culturel/forms/category-checkbox-option.html b/src/agenda_culturel/templates/agenda_culturel/forms/checkbox-option.html similarity index 100% rename from src/agenda_culturel/templates/agenda_culturel/forms/category-checkbox-option.html rename to src/agenda_culturel/templates/agenda_culturel/forms/checkbox-option.html diff --git a/src/agenda_culturel/templates/agenda_culturel/forms/tag-checkbox.html b/src/agenda_culturel/templates/agenda_culturel/forms/tag-checkbox.html index c8d9e9e..3a72023 100644 --- a/src/agenda_culturel/templates/agenda_culturel/forms/tag-checkbox.html +++ b/src/agenda_culturel/templates/agenda_culturel/forms/tag-checkbox.html @@ -1,6 +1,16 @@ {% load cat_extra %} -
{% for group, options, index in widget.optgroups %}{% if group %} -
{% endif %}{% for widget in options %}
- {% include widget.template_name %}
{% endfor %}{% if group %} -
{% endif %}{% endfor %} +
+ + +
+
{% for group, options, index in widget.optgroups %}{% if group %} +
{% endif %}{% for widget in options %}
+ {% include widget.template_name %}
{% endfor %}{% if group %} +
{% endif %}{% endfor %}
\ No newline at end of file diff --git a/src/agenda_culturel/views.py b/src/agenda_culturel/views.py index 3ff181b..f123ec5 100644 --- a/src/agenda_culturel/views.py +++ b/src/agenda_culturel/views.py @@ -173,10 +173,11 @@ class CalendarWeek(CalendarList): class CategoryCheckboxSelectMultiple(forms.CheckboxSelectMultiple): template_name = 'agenda_culturel/forms/category-checkbox.html' - option_template_name = 'agenda_culturel/forms/category-checkbox-option.html' + option_template_name = 'agenda_culturel/forms/checkbox-option.html' class TagCheckboxSelectMultiple(forms.CheckboxSelectMultiple): template_name = 'agenda_culturel/forms/tag-checkbox.html' + option_template_name = 'agenda_culturel/forms/checkbox-option.html' class EventFilter(django_filters.FilterSet): @@ -185,17 +186,13 @@ class EventFilter(django_filters.FilterSet): lookup_expr='icontains', field_name="tags", widget=TagCheckboxSelectMultiple) + + category = django_filters.ModelMultipleChoiceFilter(label="Catégories", field_name="category__id", to_field_name='id', queryset=Category.objects.all(), widget=CategoryCheckboxSelectMultiple) - - - - def filter_queryset(self, queryset): - # TODO - return super().filter_queryset(queryset) class Meta: