2
0

events.rst 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. Events
  2. =============
  3. Create a calendar or list of events. Visitors can download ical invitations to their own calendars
  4. for each event, recurring events, or all events.
  5. Usage
  6. -----
  7. If events are implemented on your site (see instructions below), first start by creating an
  8. "Event Landing Page" (may be named differently on your specific website). Add content to this
  9. page as usual. Under the **Layout** tab, you can choose a few options:
  10. * Show list of child pages: Check this box to show a list of all events.
  11. * Calendar style: There are several options here. Choose one that fits your needs.
  12. Next, save the Event Landing Page. Now create a child page. Each child page here represents
  13. an individual event. Events can be one time, or recurring, similar to Outlook or other
  14. calendar software.
  15. When creating an event page, fill out the relevant information, and click the **+** icon next
  16. to "Dates and times" to add an event occurrence. You can create multiple occurrences, or set
  17. an occurrence to repeat.
  18. Implementation
  19. --------------
  20. The event functionality is built-in to CodeRed CMS but it is not enabled by default.
  21. There are two abstract pages when dealing with events. The first ``CoderedEventPage`` holds
  22. the information regarding the event. Dates, location, etc. all will fall under this page. The
  23. ``CoderedEventIndexPage`` will aggregate its children ``CoderedEventPage`` and display them in a
  24. calendar or list.
  25. To implement, add the following to your ``website/models.py``::
  26. from modelcluster.fields import ParentalKey
  27. from coderedcms.models import (
  28. CoderedEventPage,
  29. CoderedEventIndexPage,
  30. CoderedEventOccurrence
  31. )
  32. class EventPage(CoderedEventPage):
  33. class Meta:
  34. verbose_name = 'Event Page'
  35. parent_page_types = ['website.EventIndexPage']
  36. subpage_types = []
  37. template = 'coderedcms/pages/event_page.html'
  38. class EventIndexPage(CoderedEventIndexPage):
  39. """
  40. Shows a list of event sub-pages.
  41. """
  42. class Meta:
  43. verbose_name = 'Events Landing Page'
  44. index_query_pagemodel = 'website.EventPage'
  45. # Only allow EventPages beneath this page.
  46. subpage_types = ['website.EventPage']
  47. template = 'coderedcms/pages/event_index_page.html'
  48. class EventOccurrence(CoderedEventOccurrence):
  49. event = ParentalKey(EventPage, related_name='occurrences')
  50. Next run ``python manage.py makemigrations website`` and ``python manage.py migrate`` to
  51. create the new pages in your project.
  52. Now when going to the wagtail admin, you can create an Event Landing Page, and child Event Pages.