parent
bcf768e888
commit
8f9bd567af
@ -313,6 +313,7 @@ article#filters {
|
|||||||
float: right;
|
float: right;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
display: none;
|
display: none;
|
||||||
|
margin-top: -2em;
|
||||||
}
|
}
|
||||||
form>label {
|
form>label {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
@ -386,7 +387,7 @@ article#filters {
|
|||||||
margin-top: -0.5em;
|
margin-top: -0.5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
.form.recent, .form.main-filter {
|
.form.recent, .form.main-filter, .search .form {
|
||||||
#id_status>div {
|
#id_status>div {
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
margin-right: 2em;
|
margin-right: 2em;
|
||||||
@ -624,8 +625,8 @@ nav .badge {
|
|||||||
border-radius: .5em;
|
border-radius: .5em;
|
||||||
}
|
}
|
||||||
|
|
||||||
form [role="button"] {
|
form [role="button"], form button {
|
||||||
margin: 0 0 var(--spacing) 0;
|
margin: var(--spacing) 0 var(--spacing) 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.large {
|
.large {
|
||||||
|
@ -46,7 +46,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
def get_event_qs(request):
|
def get_event_qs(request):
|
||||||
if request.user.is_authenticated:
|
if request.user.is_authenticated:
|
||||||
return Event.objects.filter(~Q(status=Event.STATUS.TRASH))
|
return Event.objects.filter()
|
||||||
else:
|
else:
|
||||||
return Event.objects.filter(status=Event.STATUS.PUBLISHED)
|
return Event.objects.filter(status=Event.STATUS.PUBLISHED)
|
||||||
|
|
||||||
@ -484,6 +484,11 @@ def contactmessages(request):
|
|||||||
class SimpleSearchEventFilter(django_filters.FilterSet):
|
class SimpleSearchEventFilter(django_filters.FilterSet):
|
||||||
q = django_filters.CharFilter(method='custom_filter', label=_("Search"))
|
q = django_filters.CharFilter(method='custom_filter', label=_("Search"))
|
||||||
|
|
||||||
|
status = django_filters.MultipleChoiceFilter(label="Filtrer par status",
|
||||||
|
choices=Event.STATUS.choices,
|
||||||
|
field_name="status",
|
||||||
|
widget=forms.CheckboxSelectMultiple)
|
||||||
|
|
||||||
def custom_filter(self, queryset, name, value):
|
def custom_filter(self, queryset, name, value):
|
||||||
search_query = SearchQuery(value, config='french')
|
search_query = SearchQuery(value, config='french')
|
||||||
qs = queryset.filter(
|
qs = queryset.filter(
|
||||||
@ -501,6 +506,11 @@ class SimpleSearchEventFilter(django_filters.FilterSet):
|
|||||||
model = Event
|
model = Event
|
||||||
fields = ['q']
|
fields = ['q']
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
if not kwargs["request"].user.is_authenticated:
|
||||||
|
self.form.fields.pop("status")
|
||||||
|
|
||||||
|
|
||||||
class SearchEventFilter(django_filters.FilterSet):
|
class SearchEventFilter(django_filters.FilterSet):
|
||||||
tags = django_filters.CharFilter(lookup_expr='icontains')
|
tags = django_filters.CharFilter(lookup_expr='icontains')
|
||||||
@ -508,6 +518,10 @@ class SearchEventFilter(django_filters.FilterSet):
|
|||||||
location = django_filters.CharFilter(method="hl_filter_contains")
|
location = django_filters.CharFilter(method="hl_filter_contains")
|
||||||
description = django_filters.CharFilter(method="hl_filter_contains")
|
description = django_filters.CharFilter(method="hl_filter_contains")
|
||||||
start_day = django_filters.DateFromToRangeFilter(widget=django_filters.widgets.RangeWidget(attrs={'type': 'date'}))
|
start_day = django_filters.DateFromToRangeFilter(widget=django_filters.widgets.RangeWidget(attrs={'type': 'date'}))
|
||||||
|
status = django_filters.MultipleChoiceFilter(label="Filtrer par status",
|
||||||
|
choices=Event.STATUS.choices,
|
||||||
|
field_name="status",
|
||||||
|
widget=forms.CheckboxSelectMultiple)
|
||||||
|
|
||||||
o = django_filters.OrderingFilter(
|
o = django_filters.OrderingFilter(
|
||||||
# tuple-mapping retains order
|
# tuple-mapping retains order
|
||||||
@ -538,14 +552,18 @@ class SearchEventFilter(django_filters.FilterSet):
|
|||||||
model = Event
|
model = Event
|
||||||
fields = ['title', 'location', 'description', 'category', 'tags', 'start_day']
|
fields = ['title', 'location', 'description', 'category', 'tags', 'start_day']
|
||||||
|
|
||||||
|
def __init__(self, *args, **kwargs):
|
||||||
|
super().__init__(*args, **kwargs)
|
||||||
|
if not kwargs["request"].user.is_authenticated:
|
||||||
|
self.form.fields.pop("status")
|
||||||
|
|
||||||
|
|
||||||
def event_search(request, full=False):
|
def event_search(request, full=False):
|
||||||
|
|
||||||
if full:
|
if full:
|
||||||
filter = SearchEventFilter(request.GET, queryset=get_event_qs(request).order_by("-start_day"))
|
filter = SearchEventFilter(request.GET, queryset=get_event_qs(request).order_by("-start_day"), request=request)
|
||||||
else:
|
else:
|
||||||
filter = SimpleSearchEventFilter(request.GET, queryset=get_event_qs(request).order_by("-start_day"))
|
filter = SimpleSearchEventFilter(request.GET, queryset=get_event_qs(request).order_by("-start_day"), request=request)
|
||||||
|
|
||||||
|
|
||||||
paginator = Paginator(filter.qs, 10)
|
paginator = Paginator(filter.qs, 10)
|
||||||
|
Loading…
Reference in New Issue
Block a user