2
0

models.py 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. from wagtailcrx.models.page_models import CoderedPage
  2. from modelcluster.fields import ParentalKey
  3. from wagtailcrx.forms import CoderedFormField
  4. from wagtailcrx.models import (
  5. CoderedArticlePage,
  6. CoderedArticleIndexPage,
  7. CoderedEventIndexPage,
  8. CoderedEventPage,
  9. CoderedEventOccurrence,
  10. CoderedEmail,
  11. CoderedFormPage,
  12. CoderedLocationIndexPage,
  13. CoderedLocationPage,
  14. CoderedStreamFormPage,
  15. CoderedWebPage
  16. )
  17. class ArticlePage(CoderedArticlePage):
  18. """
  19. Article, suitable for news or blog content.
  20. """
  21. class Meta:
  22. verbose_name = 'Article'
  23. ordering = ['-first_published_at', ]
  24. # Only allow this page to be created beneath an ArticleIndexPage.
  25. parent_page_types = ['testapp.ArticleIndexPage']
  26. template = 'wagtailcrx/pages/article_page.html'
  27. search_template = 'wagtailcrx/pages/article_page.search.html'
  28. class ArticleIndexPage(CoderedArticleIndexPage):
  29. """
  30. Shows a list of article sub-pages.
  31. """
  32. class Meta:
  33. verbose_name = 'Article Landing Page'
  34. index_order_by_default = ''
  35. # Override to specify custom index ordering choice/default.
  36. index_query_pagemodel = 'testapp.ArticlePage'
  37. # Only allow ArticlePages beneath this page.
  38. subpage_types = ['testapp.ArticlePage']
  39. template = 'wagtailcrx/pages/article_index_page.html'
  40. class FormPage(CoderedFormPage):
  41. """
  42. A page with an html <form>.
  43. """
  44. class Meta:
  45. verbose_name = 'Form'
  46. template = 'wagtailcrx/pages/form_page.html'
  47. class FormPageField(CoderedFormField):
  48. """
  49. A field that links to a FormPage.
  50. """
  51. class Meta:
  52. ordering = ['sort_order']
  53. page = ParentalKey('FormPage', related_name='form_fields')
  54. class FormConfirmEmail(CoderedEmail):
  55. """
  56. Sends a confirmation email after submitting a FormPage.
  57. """
  58. page = ParentalKey('FormPage', related_name='confirmation_emails')
  59. class WebPage(CoderedWebPage):
  60. """
  61. General use page with featureful streamfield and SEO attributes.
  62. """
  63. class Meta:
  64. verbose_name = 'Web Page'
  65. template = 'wagtailcrx/pages/web_page.html'
  66. class EventPage(CoderedEventPage):
  67. class Meta:
  68. verbose_name = 'Event Page'
  69. parent_page_types = ['testapp.EventIndexPage']
  70. subpage_types = []
  71. template = 'wagtailcrx/pages/event_page.html'
  72. class EventIndexPage(CoderedEventIndexPage):
  73. """
  74. Shows a list of event sub-pages.
  75. """
  76. class Meta:
  77. verbose_name = 'Events Landing Page'
  78. index_query_pagemodel = 'testapp.EventPage'
  79. index_order_by_default = ''
  80. # Only allow EventPages beneath this page.
  81. subpage_types = ['testapp.EventPage']
  82. template = 'wagtailcrx/pages/event_index_page.html'
  83. class EventOccurrence(CoderedEventOccurrence):
  84. event = ParentalKey(EventPage, related_name='occurrences')
  85. class LocationPage(CoderedLocationPage):
  86. """
  87. A page that holds a location. This could be a store, a restaurant, etc.
  88. """
  89. class Meta:
  90. verbose_name = 'Location Page'
  91. template = 'wagtailcrx/pages/location_page.html'
  92. # Only allow LocationIndexPages above this page.
  93. parent_page_types = ['testapp.LocationIndexPage']
  94. class LocationIndexPage(CoderedLocationIndexPage):
  95. """
  96. A page that holds a list of locations and displays them with a Google Map.
  97. This does require a Google Maps API Key that can be defined in Settings >
  98. Google API Settings
  99. """
  100. class Meta:
  101. verbose_name = 'Location Landing Page'
  102. # Override to specify custom index ordering choice/default.
  103. index_query_pagemodel = 'testapp.LocationPage'
  104. # Only allow LocationPages beneath this page.
  105. subpage_types = ['testapp.LocationPage']
  106. template = 'wagtailcrx/pages/location_index_page.html'
  107. class StreamFormPage(CoderedStreamFormPage):
  108. class Meta:
  109. verbose_name = 'Stream Form'
  110. template = 'wagtailcrx/pages/stream_form_page.html'
  111. class StreamFormConfirmEmail(CoderedEmail):
  112. page = ParentalKey('StreamFormPage', related_name='confirmation_emails')
  113. """
  114. --------------------------------------------------------------------------------
  115. CUSTOM PAGE TYPES for testing specific features. These should be based on
  116. CoderedPage when testing CoderedPage-specific functionality (which is where most
  117. of our logic lives).
  118. --------------------------------------------------------------------------------
  119. """
  120. class IndexTestPage(CoderedPage):
  121. """
  122. Tests indexing features (show/sort/filter child pages).
  123. """
  124. class Meta:
  125. verbose_name = "Index Test Page"
  126. index_query_pagemodel = "testapp.WebPage"
  127. template = 'wagtailcrx/pages/base.html'