settings.py 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. import os
  2. from django.conf import settings
  3. import bootstrap4.bootstrap as bootstrap
  4. class _DefaultSettings:
  5. CRX_BANNER = None
  6. CRX_BANNER_BACKGROUND = '#f00'
  7. CRX_BANNER_TEXT_COLOR = '#fff'
  8. CRX_DB_TABLE_CODEREDCMS = False
  9. CRX_FRONTEND_BTN_SIZE_DEFAULT = ''
  10. CRX_FRONTEND_BTN_SIZE_CHOICES = [
  11. ('btn-sm', 'Small'),
  12. ('', 'Default'),
  13. ('btn-lg', 'Large'),
  14. ]
  15. CRX_FRONTEND_BTN_STYLE_DEFAULT = 'btn-primary'
  16. CRX_FRONTEND_BTN_STYLE_CHOICES = [
  17. ('btn-primary', 'Primary'),
  18. ('btn-secondary', 'Secondary'),
  19. ('btn-success', 'Success'),
  20. ('btn-danger', 'Danger'),
  21. ('btn-warning', 'Warning'),
  22. ('btn-info', 'Info'),
  23. ('btn-link', 'Link'),
  24. ('btn-light', 'Light'),
  25. ('btn-dark', 'Dark'),
  26. ('btn-outline-primary', 'Outline Primary'),
  27. ('btn-outline-secondary', 'Outline Secondary'),
  28. ('btn-outline-success', 'Outline Success'),
  29. ('btn-outline-danger', 'Outline Danger'),
  30. ('btn-outline-warning', 'Outline Warning'),
  31. ('btn-outline-info', 'Outline Info'),
  32. ('btn-outline-light', 'Outline Light'),
  33. ('btn-outline-dark', 'Outline Dark'),
  34. ]
  35. CRX_FRONTEND_CAROUSEL_FX_DEFAULT = ''
  36. CRX_FRONTEND_CAROUSEL_FX_CHOICES = [
  37. ('', 'Slide'),
  38. ('carousel-fade', 'Fade'),
  39. ]
  40. CRX_FRONTEND_COL_SIZE_DEFAULT = ''
  41. CRX_FRONTEND_COL_SIZE_CHOICES = [
  42. ('', 'Automatically size'),
  43. ('12', 'Full row'),
  44. ('6', 'Half - 1/2 column'),
  45. ('4', 'Thirds - 1/3 column'),
  46. ('8', 'Thirds - 2/3 column'),
  47. ('3', 'Quarters - 1/4 column'),
  48. ('9', 'Quarters - 3/4 column'),
  49. ('2', 'Sixths - 1/6 column'),
  50. ('10', 'Sixths - 5/6 column'),
  51. ('1', 'Twelfths - 1/12 column'),
  52. ('5', 'Twelfths - 5/12 column'),
  53. ('7', 'Twelfths - 7/12 column'),
  54. ('11', 'Twelfths - 11/12 column'),
  55. ]
  56. CRX_FRONTEND_COL_BREAK_DEFAULT = 'md'
  57. CRX_FRONTEND_COL_BREAK_CHOICES = [
  58. ('', 'Always expanded'),
  59. ('sm', 'sm - Expand on small screens (phone, 576px) and larger'),
  60. ('md', 'md - Expand on medium screens (tablet, 768px) and larger'),
  61. ('lg', 'lg - Expand on large screens (laptop, 992px) and larger'),
  62. ('xl', 'xl - Expand on extra large screens (wide monitor, 1200px)'),
  63. ]
  64. CRX_FRONTEND_NAVBAR_FORMAT_DEFAULT = ''
  65. CRX_FRONTEND_NAVBAR_FORMAT_CHOICES = [
  66. ('', 'Default Bootstrap Navbar'),
  67. ('codered-navbar-center', 'Centered logo at top'),
  68. ]
  69. CRX_FRONTEND_NAVBAR_COLOR_SCHEME_DEFAULT = 'navbar-light'
  70. CRX_FRONTEND_NAVBAR_COLOR_SCHEME_CHOICES = [
  71. ('navbar-light', 'Light - for use with a light-colored navbar'),
  72. ('navbar-dark', 'Dark - for use with a dark-colored navbar'),
  73. ]
  74. CRX_FRONTEND_NAVBAR_CLASS_DEFAULT = 'bg-light'
  75. CRX_FRONTEND_NAVBAR_COLLAPSE_MODE_DEFAULT = 'navbar-expand-lg'
  76. CRX_FRONTEND_NAVBAR_COLLAPSE_MODE_CHOICES = [
  77. ('', 'Never show menu - Always collapse menu behind a button'),
  78. ('navbar-expand-sm', 'sm - Show on small screens (phone size) and larger'),
  79. ('navbar-expand-md', 'md - Show on medium screens (tablet size) and larger'),
  80. ('navbar-expand-lg', 'lg - Show on large screens (laptop size) and larger'),
  81. ('navbar-expand-xl', 'xl - Show on extra large screens (desktop, wide monitor)'),
  82. ]
  83. CRX_FRONTEND_THEME_DEFAULT = ''
  84. CRX_FRONTEND_THEME_CHOICES = [
  85. ('', 'Default - Classic Bootstrap'),
  86. ('cerulean', 'Cerulean - A calm blue sky'),
  87. ('cosmo', 'Cosmo - An ode to Metro'),
  88. ('cyborg', 'Cyborg - Jet black and electric blue'),
  89. ('darkly', 'Darkly - Flatly in night mode'),
  90. ('flatly', 'Flatly - Flat and modern'),
  91. ('journal', 'Journal - Crisp like a new sheet of paper'),
  92. ('litera', 'Litera - The medium is the message'),
  93. ('lumen', 'Lumen - Light and shadow'),
  94. ('lux', 'Lux - A touch of class'),
  95. ('materia', 'Materia - Material is the metaphor'),
  96. ('minty', 'Minty - A fresh feel'),
  97. ('pulse', 'Pulse - A trace of purple'),
  98. ('sandstone', 'Sandstone - A touch of warmth'),
  99. ('simplex', 'Simplex - Mini and minimalist'),
  100. ('sketchy', 'Sketchy - A hand-drawn look for mockups and mirth'),
  101. ('slate', 'Slate - Shades of gunmetal gray'),
  102. ('solar', 'Solar - A dark spin on Solarized'),
  103. ('spacelab', 'Spacelab - Silvery and sleek'),
  104. ('superhero', 'Superhero - The brave and the blue'),
  105. ('united', 'United - Ubuntu orange and unique font'),
  106. ('yeti', 'Yeti - A friendly foundation'),
  107. ]
  108. CRX_FRONTEND_TEMPLATES_BLOCKS = {
  109. 'cardblock': [
  110. ('wagtailcrx/blocks/card_block.html', 'Card'),
  111. ('wagtailcrx/blocks/card_head.html', 'Card with header'),
  112. ('wagtailcrx/blocks/card_foot.html', 'Card with footer'),
  113. ('wagtailcrx/blocks/card_head_foot.html', 'Card with header and footer'),
  114. ('wagtailcrx/blocks/card_blurb.html', 'Blurb - rounded image and no border'),
  115. ('wagtailcrx/blocks/card_img.html', 'Cover image - use image as background'),
  116. ],
  117. 'cardgridblock': [
  118. ('wagtailcrx/blocks/cardgrid_group.html', 'Card group - attached cards of equal size'),
  119. ('wagtailcrx/blocks/cardgrid_deck.html', 'Card deck - separate cards of equal size'),
  120. ('wagtailcrx/blocks/cardgrid_columns.html', 'Card masonry - fluid brick pattern'),
  121. ],
  122. 'pagelistblock': [
  123. ('wagtailcrx/blocks/pagelist_block.html', 'General, simple list'),
  124. ('wagtailcrx/blocks/pagelist_list_group.html', 'General, list group navigation panel'),
  125. ('wagtailcrx/blocks/pagelist_article_media.html', 'Article, media format'),
  126. ('wagtailcrx/blocks/pagelist_article_card_group.html',
  127. 'Article, card group - attached cards of equal size'),
  128. ('wagtailcrx/blocks/pagelist_article_card_deck.html',
  129. 'Article, card deck - separate cards of equal size'),
  130. ('wagtailcrx/blocks/pagelist_article_card_columns.html',
  131. 'Article, card masonry - fluid brick pattern'),
  132. ],
  133. 'pagepreviewblock': [
  134. ('wagtailcrx/blocks/pagepreview_card.html', 'Card'),
  135. ('wagtailcrx/blocks/pagepreview_form.html', 'Form inputs'),
  136. ],
  137. # templates that are available for all block types
  138. '*': [
  139. ('', 'Default'),
  140. ],
  141. }
  142. CRX_FRONTEND_TEMPLATES_PAGES = {
  143. # templates that are available for all page types
  144. '*': [
  145. ('', 'Default'),
  146. ('wagtailcrx/pages/web_page.html', 'Web page showing title and cover image'),
  147. ('wagtailcrx/pages/web_page_notitle.html', 'Web page without title and cover image'),
  148. ('wagtailcrx/pages/home_page.html', 'Home page without title and cover image'),
  149. ('wagtailcrx/pages/base.html', 'Blank page - no navbar or footer'),
  150. ],
  151. }
  152. CRX_PROTECTED_MEDIA_URL = '/protected/'
  153. CRX_PROTECTED_MEDIA_ROOT = os.path.join(settings.BASE_DIR, 'protected')
  154. CRX_PROTECTED_MEDIA_UPLOAD_WHITELIST = []
  155. CRX_PROTECTED_MEDIA_UPLOAD_BLACKLIST = [
  156. '.app',
  157. '.bat',
  158. '.exe',
  159. '.jar',
  160. '.php',
  161. '.pl',
  162. '.ps1',
  163. '.py',
  164. '.rb',
  165. '.sh',
  166. ]
  167. def __getattribute__(self, attr: str):
  168. # First load from Django settings.
  169. # If it does not exist, load from _DefaultSettings.
  170. try:
  171. return getattr(settings, attr)
  172. except AttributeError:
  173. return super().__getattribute__(attr)
  174. crx_settings = _DefaultSettings()
  175. get_bootstrap_setting = bootstrap.get_bootstrap_setting