File tree Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Expand file tree Collapse file tree 2 files changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -335,7 +335,10 @@ def get_context_data(self, **kwargs):
335335 today = datetime .today ()
336336 year = int (self .request .GET .get ("year" , today .year ))
337337 month = int (self .request .GET .get ("month" , today .month ))
338- shifts = Shift .objects .filter (start_time__month = month , start_time__year = year )
338+ events = get_objects_for_user (self .request .user , "core.view_event" , klass = Event )
339+ shifts = Shift .objects .filter (
340+ event__in = events , start_time__month = month , start_time__year = year
341+ )
339342 calendar = ShiftCalendar (shifts )
340343 kwargs .setdefault ("calendar" , mark_safe (calendar .formatmonth (year , month )))
341344 nextyear , nextmonth = _nextmonth (year , month )
Original file line number Diff line number Diff line change 1+ from django .urls import reverse
2+
3+
4+ def test_calendar_display (client , volunteer , event ):
5+ # we are using the django test client here because we couldn't get the session stuff to
6+ # work with pytest. Don't copy this!
7+ session = client .session
8+ session ["event_list_view_type" ] = "calendar"
9+ session .save ()
10+ client .force_login (volunteer )
11+ response = client .get (reverse ("core:event_list" ))
12+ assert response .status_code == 200
13+ assert "core/event_calendar.html" in response .template_name
14+
15+
16+ def test_calendar_display_restricitions (client , volunteer , event ):
17+ # we are using the django test client here because we couldn't get the session stuff to
18+ # work with pytest. Don't copy this!
19+ volunteer .groups .set ([])
20+ volunteer .save ()
21+ session = client .session
22+ session ["event_list_view_type" ] = "calendar"
23+ session .save ()
24+ client .force_login (volunteer )
25+ shift = event .shifts .first ()
26+ response = client .get (
27+ f"{ reverse ('core:event_list' )} ?year={ shift .start_time .year } &month={ shift .start_time .month } "
28+ )
29+ assert response .status_code == 200
30+ assert "core/event_calendar.html" in response .template_name
31+ assert event .title not in response .rendered_content
You can’t perform that action at this time.
0 commit comments