On ajoute la sélection par défaut des événements publiés

This commit is contained in:
Jean-Marie Favreau 2024-08-15 14:28:26 +02:00
parent be8b6b8f48
commit 923c7a0d77

View File

@ -287,6 +287,16 @@ class EventFilter(django_filters.FilterSet):
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"]
def set_default_values(request):
if request.user.is_authenticated:
if request.GET.get('status', None) == None:
tempdict = request.GET.copy()
tempdict['status'] = 'published'
request.GET = tempdict
return request
return request
def mentions_legales(request): def mentions_legales(request):
context = { context = {
@ -338,6 +348,8 @@ def week_view(request, year=None, week=None, home=False):
if week is None: if week is None:
week = now.isocalendar()[1] week = now.isocalendar()[1]
request = EventFilter.set_default_values(request)
filter = EventFilter(request.GET, queryset=get_event_qs(request), request=request) filter = EventFilter(request.GET, queryset=get_event_qs(request), request=request)
cweek = CalendarWeek(year, week, filter) cweek = CalendarWeek(year, week, filter)
@ -358,6 +370,7 @@ def day_view(request, year=None, month=None, day=None):
day = date(year, month, day) day = date(year, month, day)
request = EventFilter.set_default_values(request)
filter = EventFilter(request.GET, get_event_qs(request), request=request) filter = EventFilter(request.GET, get_event_qs(request), request=request)
cday = CalendarDay(day, filter) cday = CalendarDay(day, filter)
@ -470,7 +483,6 @@ class EventModerateView(
def form_valid(self, form): def form_valid(self, form):
ModerationAnswer.objects.all() ModerationAnswer.objects.all()
logger.warning("ON valide la forme")
for f in form.cleaned_data: for f in form.cleaned_data:
ModerationAnswer.objects.get(pk=form.cleaned_data[f]).apply_answer( ModerationAnswer.objects.get(pk=form.cleaned_data[f]).apply_answer(
@ -665,6 +677,7 @@ def export_event_ical(request, year, month, day, pk):
def export_ical(request): def export_ical(request):
now = date.today() now = date.today()
request = EventFilter.set_default_values(request)
filter = EventFilter(request.GET, queryset=get_event_qs(request), request=request) filter = EventFilter(request.GET, queryset=get_event_qs(request), request=request)
calendar = CalendarList(now + timedelta(days=-7), now + timedelta(days=+60), filter) calendar = CalendarList(now + timedelta(days=-7), now + timedelta(days=+60), filter)
ical = calendar.export_to_ics() ical = calendar.export_to_ics()