On ajoute la sélection par défaut des événements publiés
This commit is contained in:
parent
be8b6b8f48
commit
923c7a0d77
@ -287,6 +287,16 @@ class EventFilter(django_filters.FilterSet):
|
||||
def is_selected(self, cat):
|
||||
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):
|
||||
context = {
|
||||
@ -338,6 +348,8 @@ def week_view(request, year=None, week=None, home=False):
|
||||
if week is None:
|
||||
week = now.isocalendar()[1]
|
||||
|
||||
|
||||
request = EventFilter.set_default_values(request)
|
||||
filter = EventFilter(request.GET, queryset=get_event_qs(request), request=request)
|
||||
cweek = CalendarWeek(year, week, filter)
|
||||
|
||||
@ -358,6 +370,7 @@ def day_view(request, year=None, month=None, day=None):
|
||||
|
||||
day = date(year, month, day)
|
||||
|
||||
request = EventFilter.set_default_values(request)
|
||||
filter = EventFilter(request.GET, get_event_qs(request), request=request)
|
||||
cday = CalendarDay(day, filter)
|
||||
|
||||
@ -470,7 +483,6 @@ class EventModerateView(
|
||||
|
||||
def form_valid(self, form):
|
||||
ModerationAnswer.objects.all()
|
||||
logger.warning("ON valide la forme")
|
||||
|
||||
for f in form.cleaned_data:
|
||||
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):
|
||||
now = date.today()
|
||||
|
||||
request = EventFilter.set_default_values(request)
|
||||
filter = EventFilter(request.GET, queryset=get_event_qs(request), request=request)
|
||||
calendar = CalendarList(now + timedelta(days=-7), now + timedelta(days=+60), filter)
|
||||
ical = calendar.export_to_ics()
|
||||
|
Loading…
Reference in New Issue
Block a user