events.rst 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. Events
  2. =============
  3. Event pages allow users to create a calendar or list of events. These lists/calendars allow
  4. users to download ical invitations to their own calendars.
  5. There are two abstract pages when dealing with events. The first ``CoderedEventPage`` holds
  6. the information regarding the event. Dates, location, etc all will fall under this page. The
  7. ``CoderedEventIndexPage`` will aggregate its children ``CoderedEventPage`` and display them in a calendar.
  8. The event functionality is built-in to Codered CMS but it is not enabled by default. To implement,
  9. add the following to your ``website/models.py``::
  10. from modelcluster.fields import ParentalKey
  11. from coderedcms.models import (
  12. CoderedEventPage,
  13. CoderedEventIndexPage,
  14. CoderedEventOccurrence
  15. )
  16. class EventPage(CoderedEventPage):
  17. class Meta:
  18. verbose_name = 'Event Page'
  19. parent_page_types = ['website.EventIndexPage']
  20. subpage_types = []
  21. template = 'coderedcms/pages/event_page.html'
  22. class EventIndexPage(CoderedEventIndexPage):
  23. """
  24. Shows a list of event sub-pages.
  25. """
  26. class Meta:
  27. verbose_name = 'Events Landing Page'
  28. index_query_pagemodel = 'website.EventPage'
  29. # Only allow EventPages beneath this page.
  30. subpage_types = ['website.EventPage']
  31. template = 'coderedcms/pages/event_index_page.html'
  32. class EventOccurrence(CoderedEventOccurrence):
  33. event = ParentalKey(EventPage, related_name='occurrences')
  34. Next run ``python manage.py makemigrations`` and ``python manage.py migrate`` to create the new pages
  35. in your project.
  36. Now when going to the wagtail admin, you can create an EventIndexPage, and child EventPages.