llazzaro / django-scheduler

A calendaring app for Django.
BSD 3-Clause "New" or "Revised" License
1.29k stars 392 forks source link

Fix bug that results in AttributeError - 'OccurrencePreview' object has no attribute 'object' #555

Open fatboystring opened 1 year ago

fatboystring commented 1 year ago

Fixes issues #301 and #554

A couple of issues identified with the OccurrencePreview view - as follows:

As a result of the above, when get_context_data is called, the object attribute of the view has not been set, resulting in an AttributeError.

The fix involves:

  1. using the event_id from the url pattern to fetch the event from the db
  2. getting the associated occurrence by constructing the start/end dates from the url parameters and using the Period class to get occurrences for that point in time
  3. returning the occurrence if found
  4. raising an http 404 if the event could not be found, or no occurrences exist for the specified point in time

Thanks for the library. Please let me know if you'd like anything changed in the pull request

coveralls commented 1 year ago

Coverage Status

coverage: 80.36% (+0.4%) from 79.986% when pulling f6479c22bfb7ddf8933c071257d3f58deb237982 on fatboystring:bugfix/301 into 8aa6f877f17e5b05f17d7c39e93d8e73625b0a65 on llazzaro:develop.

llazzaro commented 1 year ago

@fatboystring One check is failing, can you fix it? https://github.com/llazzaro/django-scheduler/actions/runs/5405303603/jobs/9970975750?pr=555

Regards

fatboystring commented 1 year ago

@llazzaro should be sorted now. Thanks

h3x4git commented 1 year ago

I don't think this is compatible with #488