2
0

models.py 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. """
  2. Create or customize your page models here.
  3. """
  4. from modelcluster.fields import ParentalKey
  5. from wagtailcrx.forms import CoderedFormField
  6. from wagtailcrx.models import (
  7. CoderedArticlePage,
  8. CoderedArticleIndexPage,
  9. CoderedEmail,
  10. CoderedFormPage,
  11. CoderedWebPage
  12. )
  13. class ArticlePage(CoderedArticlePage):
  14. """
  15. Article, suitable for news or blog content.
  16. """
  17. class Meta:
  18. verbose_name = 'Article'
  19. ordering = ['-first_published_at']
  20. # Only allow this page to be created beneath an ArticleIndexPage.
  21. parent_page_types = ['website.ArticleIndexPage']
  22. template = 'wagtailcrx/pages/article_page.html'
  23. search_template = 'wagtailcrx/pages/article_page.search.html'
  24. class ArticleIndexPage(CoderedArticleIndexPage):
  25. """
  26. Shows a list of article sub-pages.
  27. """
  28. class Meta:
  29. verbose_name = 'Article Landing Page'
  30. # Override to specify custom index ordering choice/default.
  31. index_query_pagemodel = 'website.ArticlePage'
  32. # Only allow ArticlePages beneath this page.
  33. subpage_types = ['website.ArticlePage']
  34. template = 'wagtailcrx/pages/article_index_page.html'
  35. class FormPage(CoderedFormPage):
  36. """
  37. A page with an html <form>.
  38. """
  39. class Meta:
  40. verbose_name = 'Form'
  41. template = 'wagtailcrx/pages/form_page.html'
  42. class FormPageField(CoderedFormField):
  43. """
  44. A field that links to a FormPage.
  45. """
  46. class Meta:
  47. ordering = ['sort_order']
  48. page = ParentalKey('FormPage', related_name='form_fields')
  49. class FormConfirmEmail(CoderedEmail):
  50. """
  51. Sends a confirmation email after submitting a FormPage.
  52. """
  53. page = ParentalKey('FormPage', related_name='confirmation_emails')
  54. class WebPage(CoderedWebPage):
  55. """
  56. General use page with featureful streamfield and SEO attributes.
  57. """
  58. class Meta:
  59. verbose_name = 'Web Page'
  60. template = 'wagtailcrx/pages/web_page.html'