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.
|
||||
|
||||
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
|
||||
|
||||
|
@ -770,4 +770,8 @@ article>article {
|
||||
line-height: 2em;
|
||||
margin-right: 1em;
|
||||
}
|
||||
}
|
||||
|
||||
.strike {
|
||||
text-decoration: line-through;
|
||||
}
|
@ -12,6 +12,9 @@
|
||||
{% for t in filter.get_tags %}
|
||||
{{ t | tag_button }}
|
||||
{% endfor %}
|
||||
{% for t in filter.get_exclude_tags %}
|
||||
{{ t | tag_button_strike }}
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
Filtrer
|
||||
{% endif %}
|
||||
|
@ -5,8 +5,14 @@ from django.urls import reverse_lazy
|
||||
register = template.Library()
|
||||
|
||||
@register.filter
|
||||
def tag_button(tag, link=False):
|
||||
def tag_button(tag, link=False, strike=False):
|
||||
strike_class = " strike" if strike else ""
|
||||
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:
|
||||
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):
|
||||
tags = django_filters.MultipleChoiceFilter(label="Étiquettes",
|
||||
choices=[(t, t) for t in Event.get_all_tags()],
|
||||
lookup_expr='icontains',
|
||||
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()],
|
||||
lookup_expr='icontains',
|
||||
field_name="tags",
|
||||
widget=TagCheckboxSelectMultiple)
|
||||
|
||||
|
||||
category = django_filters.ModelMultipleChoiceFilter(label="Catégories",
|
||||
category = django_filters.ModelMultipleChoiceFilter(label="Filtrer par catégories",
|
||||
field_name="category__id",
|
||||
to_field_name='id',
|
||||
queryset=Category.objects.all(),
|
||||
@ -75,7 +82,7 @@ class EventFilter(django_filters.FilterSet):
|
||||
|
||||
class Meta:
|
||||
model = Event
|
||||
fields = ["category", "tags"]
|
||||
fields = ["category", "tags", "exclude_tags"]
|
||||
|
||||
def get_url(self):
|
||||
if isinstance(self.form.data, QueryDict):
|
||||
@ -93,11 +100,14 @@ class EventFilter(django_filters.FilterSet):
|
||||
def get_tags(self):
|
||||
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):
|
||||
if only_categories:
|
||||
return len(self.form.cleaned_data["category"]) != 0
|
||||
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):
|
||||
return cat in self.form.cleaned_data["category"]
|
||||
|
Loading…
Reference in New Issue
Block a user