parent
822191af8f
commit
31b7881c90
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
L'agenda culturel est un projet django créé à partir de [Django Docker Quickstard](https://github.com/godd0t/django-docker-quickstart/) pour faciliter son développemnt et déploiement. Il est distribué sous licence AGPL.
|
L'agenda culturel est un projet django créé à partir de [Django Docker Quickstard](https://github.com/godd0t/django-docker-quickstart/) pour faciliter son développemnt et déploiement. Il est distribué sous licence AGPL.
|
||||||
|
|
||||||
Une instance de démonstration est disponible à l'adresse https://agenda-culturel.lecridelagirafe.org/.
|
Une instance de démonstration est disponible à l'adresse https://pommesdelune.fr/.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
|
@ -771,3 +771,7 @@ article>article {
|
|||||||
margin-right: 1em;
|
margin-right: 1em;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.strike {
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
@ -12,6 +12,9 @@
|
|||||||
{% for t in filter.get_tags %}
|
{% for t in filter.get_tags %}
|
||||||
{{ t | tag_button }}
|
{{ t | tag_button }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% for t in filter.get_exclude_tags %}
|
||||||
|
{{ t | tag_button_strike }}
|
||||||
|
{% endfor %}
|
||||||
{% else %}
|
{% else %}
|
||||||
Filtrer
|
Filtrer
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -5,8 +5,14 @@ from django.urls import reverse_lazy
|
|||||||
register = template.Library()
|
register = template.Library()
|
||||||
|
|
||||||
@register.filter
|
@register.filter
|
||||||
def tag_button(tag, link=False):
|
def tag_button(tag, link=False, strike=False):
|
||||||
|
strike_class = " strike" if strike else ""
|
||||||
if link:
|
if link:
|
||||||
return mark_safe('<a href="' + reverse_lazy('view_tag', {"tag": tag}) +'" role="button" class="small-cat">' + tag + '</a>')
|
return mark_safe('<a href="' + reverse_lazy('view_tag', {"tag": tag}) +'" role="button" class="small-cat' + strike_class + '">' + tag + '</a>')
|
||||||
else:
|
else:
|
||||||
return mark_safe('<span role="button" class="small-cat">' + tag + '</span>')
|
return mark_safe('<span role="button" class="small-cat' + strike_class + '">' + tag + '</span>')
|
||||||
|
|
||||||
|
|
||||||
|
@register.filter
|
||||||
|
def tag_button_strike(tag, link=False):
|
||||||
|
return tag_button(tag, link, strike=True)
|
@ -59,14 +59,21 @@ class TagCheckboxSelectMultiple(forms.CheckboxSelectMultiple):
|
|||||||
|
|
||||||
|
|
||||||
class EventFilter(django_filters.FilterSet):
|
class EventFilter(django_filters.FilterSet):
|
||||||
tags = django_filters.MultipleChoiceFilter(label="Étiquettes",
|
exclude_tags = django_filters.MultipleChoiceFilter(label="Exclure les étiquettes",
|
||||||
|
choices=[(t, t) for t in Event.get_all_tags()],
|
||||||
|
lookup_expr='icontains',
|
||||||
|
field_name="tags",
|
||||||
|
exclude=True,
|
||||||
|
widget=TagCheckboxSelectMultiple)
|
||||||
|
|
||||||
|
tags = django_filters.MultipleChoiceFilter(label="Filtrer par étiquettes",
|
||||||
choices=[(t, t) for t in Event.get_all_tags()],
|
choices=[(t, t) for t in Event.get_all_tags()],
|
||||||
lookup_expr='icontains',
|
lookup_expr='icontains',
|
||||||
field_name="tags",
|
field_name="tags",
|
||||||
widget=TagCheckboxSelectMultiple)
|
widget=TagCheckboxSelectMultiple)
|
||||||
|
|
||||||
|
|
||||||
category = django_filters.ModelMultipleChoiceFilter(label="Catégories",
|
category = django_filters.ModelMultipleChoiceFilter(label="Filtrer par catégories",
|
||||||
field_name="category__id",
|
field_name="category__id",
|
||||||
to_field_name='id',
|
to_field_name='id',
|
||||||
queryset=Category.objects.all(),
|
queryset=Category.objects.all(),
|
||||||
@ -75,7 +82,7 @@ class EventFilter(django_filters.FilterSet):
|
|||||||
|
|
||||||
class Meta:
|
class Meta:
|
||||||
model = Event
|
model = Event
|
||||||
fields = ["category", "tags"]
|
fields = ["category", "tags", "exclude_tags"]
|
||||||
|
|
||||||
def get_url(self):
|
def get_url(self):
|
||||||
if isinstance(self.form.data, QueryDict):
|
if isinstance(self.form.data, QueryDict):
|
||||||
@ -93,11 +100,14 @@ class EventFilter(django_filters.FilterSet):
|
|||||||
def get_tags(self):
|
def get_tags(self):
|
||||||
return self.form.cleaned_data["tags"]
|
return self.form.cleaned_data["tags"]
|
||||||
|
|
||||||
|
def get_exclude_tags(self):
|
||||||
|
return self.form.cleaned_data["exclude_tags"]
|
||||||
|
|
||||||
def is_active(self, only_categories=False):
|
def is_active(self, only_categories=False):
|
||||||
if only_categories:
|
if only_categories:
|
||||||
return len(self.form.cleaned_data["category"]) != 0
|
return len(self.form.cleaned_data["category"]) != 0
|
||||||
else:
|
else:
|
||||||
return len(self.form.cleaned_data["category"]) != 0 or len(self.form.cleaned_data["tags"]) != 0
|
return len(self.form.cleaned_data["category"]) != 0 or len(self.form.cleaned_data["tags"]) != 0 or len(self.form.cleaned_data["exclude_tags"]) != 0
|
||||||
|
|
||||||
def is_selected(self, cat):
|
def is_selected(self, cat):
|
||||||
return cat in self.form.cleaned_data["category"]
|
return cat in self.form.cleaned_data["category"]
|
||||||
|
Loading…
Reference in New Issue
Block a user