settings.py 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  1. import os
  2. from django.apps import apps
  3. from django.conf import settings
  4. class _DefaultSettings:
  5. CRX_PROTECTED_MEDIA_URL = "/protected/"
  6. CRX_PROTECTED_MEDIA_ROOT = os.path.join(settings.BASE_DIR, "protected")
  7. CRX_PROTECTED_MEDIA_UPLOAD_WHITELIST = []
  8. CRX_PROTECTED_MEDIA_UPLOAD_BLACKLIST = [
  9. ".app",
  10. ".bat",
  11. ".exe",
  12. ".jar",
  13. ".php",
  14. ".pl",
  15. ".ps1",
  16. ".py",
  17. ".rb",
  18. ".sh",
  19. ]
  20. CRX_FRONTEND_BTN_SIZE_DEFAULT = ""
  21. CRX_FRONTEND_BTN_SIZE_CHOICES = [
  22. ("btn-sm", "Small"),
  23. ("", "Default"),
  24. ("btn-lg", "Large"),
  25. ]
  26. CRX_FRONTEND_BTN_STYLE_DEFAULT = "btn-primary"
  27. CRX_FRONTEND_BTN_STYLE_CHOICES = [
  28. ("btn-primary", "Primary"),
  29. ("btn-secondary", "Secondary"),
  30. ("btn-success", "Success"),
  31. ("btn-danger", "Danger"),
  32. ("btn-warning", "Warning"),
  33. ("btn-info", "Info"),
  34. ("btn-link", "Link"),
  35. ("btn-light", "Light"),
  36. ("btn-dark", "Dark"),
  37. ("btn-outline-primary", "Outline Primary"),
  38. ("btn-outline-secondary", "Outline Secondary"),
  39. ("btn-outline-success", "Outline Success"),
  40. ("btn-outline-danger", "Outline Danger"),
  41. ("btn-outline-warning", "Outline Warning"),
  42. ("btn-outline-info", "Outline Info"),
  43. ("btn-outline-light", "Outline Light"),
  44. ("btn-outline-dark", "Outline Dark"),
  45. ]
  46. CRX_FRONTEND_COL_SIZE_DEFAULT = ""
  47. CRX_FRONTEND_COL_SIZE_CHOICES = [
  48. ("", "Automatically size"),
  49. ("12", "Full row"),
  50. ("6", "Half - 1/2 column"),
  51. ("4", "Thirds - 1/3 column"),
  52. ("8", "Thirds - 2/3 column"),
  53. ("3", "Quarters - 1/4 column"),
  54. ("9", "Quarters - 3/4 column"),
  55. ("2", "Sixths - 1/6 column"),
  56. ("10", "Sixths - 5/6 column"),
  57. ("1", "Twelfths - 1/12 column"),
  58. ("5", "Twelfths - 5/12 column"),
  59. ("7", "Twelfths - 7/12 column"),
  60. ("11", "Twelfths - 11/12 column"),
  61. ]
  62. CRX_FRONTEND_COL_BREAK_DEFAULT = "md"
  63. CRX_FRONTEND_COL_BREAK_CHOICES = [
  64. ("", "Always expanded"),
  65. ("sm", "sm - Expand on small screens (phone, 576px) and larger"),
  66. ("md", "md - Expand on medium screens (tablet, 768px) and larger"),
  67. ("lg", "lg - Expand on large screens (laptop, 992px) and larger"),
  68. ("xl", "xl - Expand on extra large screens (wide monitor, 1200px)"),
  69. ]
  70. CRX_FRONTEND_NAVBAR_FORMAT_DEFAULT = ""
  71. CRX_FRONTEND_NAVBAR_FORMAT_CHOICES = [
  72. ("", "Default Bootstrap Navbar"),
  73. ("crx-navbar-center", "Centered logo at top"),
  74. ]
  75. CRX_FRONTEND_NAVBAR_COLOR_SCHEME_DEFAULT = "navbar-light"
  76. CRX_FRONTEND_NAVBAR_COLOR_SCHEME_CHOICES = [
  77. ("navbar-light", "Light - for use with a light-colored navbar"),
  78. ("navbar-dark", "Dark - for use with a dark-colored navbar"),
  79. ]
  80. CRX_FRONTEND_NAVBAR_CLASS_DEFAULT = "bg-light"
  81. CRX_FRONTEND_NAVBAR_COLLAPSE_MODE_DEFAULT = "navbar-expand-lg"
  82. CRX_FRONTEND_NAVBAR_COLLAPSE_MODE_CHOICES = [
  83. (
  84. "",
  85. "Never show menu - Always collapse menu behind a button",
  86. ),
  87. (
  88. "navbar-expand-sm",
  89. "sm - Show on small screens (phone size) and larger",
  90. ),
  91. (
  92. "navbar-expand-md",
  93. "md - Show on medium screens (tablet size) and larger",
  94. ),
  95. (
  96. "navbar-expand-lg",
  97. "lg - Show on large screens (laptop size) and larger",
  98. ),
  99. (
  100. "navbar-expand-xl",
  101. "xl - Show on extra large screens (desktop, wide monitor)",
  102. ),
  103. ]
  104. CRX_FRONTEND_TEMPLATES_BLOCKS = {
  105. "cardblock": [
  106. (
  107. "coderedcms/blocks/card_block.html",
  108. "Card",
  109. ),
  110. (
  111. "coderedcms/blocks/card_head.html",
  112. "Card with header",
  113. ),
  114. (
  115. "coderedcms/blocks/card_foot.html",
  116. "Card with footer",
  117. ),
  118. (
  119. "coderedcms/blocks/card_head_foot.html",
  120. "Card with header and footer",
  121. ),
  122. (
  123. "coderedcms/blocks/card_blurb.html",
  124. "Blurb - rounded image and no border",
  125. ),
  126. (
  127. "coderedcms/blocks/card_img.html",
  128. "Cover image - use image as background",
  129. ),
  130. ],
  131. "cardgridblock": [
  132. (
  133. "coderedcms/blocks/cardgrid_group.html",
  134. "Card group - attached cards of equal size",
  135. ),
  136. (
  137. "coderedcms/blocks/cardgrid_deck.html",
  138. "Card deck - separate cards of equal size",
  139. ),
  140. (
  141. "coderedcms/blocks/cardgrid_columns.html",
  142. "Card masonry - fluid brick pattern",
  143. ),
  144. ],
  145. # DEPRECATED: Remove in 3.0.
  146. "pagelistblock": [
  147. (
  148. "coderedcms/blocks/pagelist_block.html",
  149. "General, simple list",
  150. ),
  151. (
  152. "coderedcms/blocks/pagelist_list_group.html",
  153. "General, list group navigation panel",
  154. ),
  155. (
  156. "coderedcms/blocks/pagelist_article_media.html",
  157. "Article, media format",
  158. ),
  159. (
  160. "coderedcms/blocks/pagelist_article_card_group.html",
  161. "Article, card group - attached cards of equal size",
  162. ),
  163. (
  164. "coderedcms/blocks/pagelist_article_card_deck.html",
  165. "Article, card deck - separate cards of equal size",
  166. ),
  167. (
  168. "coderedcms/blocks/pagelist_article_card_columns.html",
  169. "Article, card masonry - fluid brick pattern",
  170. ),
  171. ],
  172. # DEPRECATED: Remove in 3.0
  173. "pagepreviewblock": [
  174. (
  175. "coderedcms/blocks/pagepreview_card.html",
  176. "Card",
  177. ),
  178. (
  179. "coderedcms/blocks/pagepreview_form.html",
  180. "Form inputs",
  181. ),
  182. ],
  183. # templates that are available for all block types
  184. "*": [
  185. ("", "Default"),
  186. ],
  187. }
  188. CRX_FRONTEND_TEMPLATES_PAGES = {
  189. # templates that are available for all page types
  190. "*": [
  191. (
  192. "",
  193. "Default",
  194. ),
  195. (
  196. "coderedcms/pages/web_page.html",
  197. "Web page showing title and cover image",
  198. ),
  199. (
  200. "coderedcms/pages/web_page_notitle.html",
  201. "Web page without title and cover image",
  202. ),
  203. (
  204. "coderedcms/pages/home_page.html",
  205. "Home page without title and cover image",
  206. ),
  207. (
  208. "coderedcms/pages/base.html",
  209. "Blank page - no navbar or footer",
  210. ),
  211. ],
  212. }
  213. CRX_BANNER = None
  214. CRX_BANNER_BACKGROUND = "#ff0"
  215. CRX_BANNER_TEXT_COLOR = "#000"
  216. CRX_DISABLE_ANALYTICS = False
  217. CRX_DISABLE_LAYOUT = False
  218. CRX_DISABLE_NAVBAR = False
  219. CRX_DISABLE_FOOTER = False
  220. def __getattribute__(self, attr: str):
  221. # First load from Django settings.
  222. # If it does not exist, load from _DefaultSettings.
  223. try:
  224. return getattr(settings, attr)
  225. except AttributeError:
  226. return super().__getattribute__(attr)
  227. crx_settings = _DefaultSettings()
  228. # If the older django-bootstrap4 is the only version listed in INSTALLED_APPS,
  229. # use it for compatibility. Otherwise use django-bootstrap5 which is a
  230. # dependency of coderedcms.
  231. if apps.is_installed("bootstrap4") and not apps.is_installed(
  232. "django_bootstrap5"
  233. ):
  234. import bootstrap4.bootstrap as bootstrap
  235. else:
  236. import django_bootstrap5.core as bootstrap
  237. get_bootstrap_setting = bootstrap.get_bootstrap_setting