Skip to content

Commit

Permalink
Fix bug #508
Browse files Browse the repository at this point in the history
  • Loading branch information
llazzaro committed May 19, 2021
1 parent 4f0414b commit 706f45a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Unreleased
- Dropped support for Django 1.11, 2.1 and 3.0.
- Add testing for Python 3.9.
- Add testing for Django 3.1 and 3.2.
- Fix bug #508. Fullcalendar API filters cancelled occurrences.

0.9.3 - 2019-10-31
==================
Expand Down
4 changes: 3 additions & 1 deletion schedule/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,9 @@ def convert(ddatetime):
# make event start and end dates aware in given timezone
event_start = event_start.astimezone(current_tz)
event_end = event_end.astimezone(current_tz)

if occurrence.cancelled:
# fixes bug 508
continue
response_data.append(
{
"id": occurrence_id,
Expand Down
34 changes: 34 additions & 0 deletions tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,6 +600,40 @@ def test_occurrences_api_fails_with_incorrect_date_string_formats(self):
expected_error = "does not match format '%Y-%m-%dT%H:%M:%S'"
self.assertIn(expected_error, resp)

def test_occurrences_api_filters_cancelled_events(self):
# create a calendar and event
calendar = Calendar.objects.create(name="MyCal", slug="MyCalSlug")
weekly_meeting_event = Event.objects.create(
title="Recent Event",
start=datetime.datetime(2021, 12, 27, 8, 0, tzinfo=pytz.utc),
end=datetime.datetime(2021, 12, 27, 9, 0, tzinfo=pytz.utc),
end_recurring_period=datetime.datetime(2021, 12, 31, 0, 0, tzinfo=pytz.utc),
calendar=calendar,
)
Occurrence.objects.create(
event=weekly_meeting_event,
start=weekly_meeting_event.start.replace(year=2021, month=12, day=27),
end=weekly_meeting_event.end.replace(year=2021, month=12, day=27),
cancelled=True,
original_start=weekly_meeting_event.start.replace(
year=2021, month=12, day=27
),
original_end=weekly_meeting_event.end.replace(year=2021, month=12, day=27),
)

# test fails with date string time format not '%Y-%m-%d' or '%Y-%m-%dT%H:%M:%S'
response = self.client.get(
reverse("api_occurrences"),
{
"start": "2021-12-27T08:00:00",
"end": "2021-12-27T09:00:00",
"calendar_slug": weekly_meeting_event.calendar.slug,
},
)
self.assertEqual(response.status_code, 200)
expected_content = []
self.assertEqual(json.loads(response.content.decode()), expected_content)

def test_check_next_url_valid_case(self):
expected = "/calendar/1"
res = check_next_url("/calendar/1")
Expand Down

0 comments on commit 706f45a

Please sign in to comment.