apps.py 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. import sys
  2. from django.apps import AppConfig
  3. class CoreConfig(AppConfig):
  4. name = 'core'
  5. def ready(self):
  6. if 'migrate' in sys.argv:
  7. return
  8. print("-- Démarage du Core --")
  9. print(">> Vérification des variables d'environement")
  10. from core.models import Data
  11. print(">>> check site-name")
  12. try :
  13. data = Data.objects.get(d_titre_slugify = "site-name")
  14. except:
  15. data = Data()
  16. data.d_titre = "site-name"
  17. data.d_type = "txt"
  18. data.d_variable = "Duhaz Core"
  19. data.save()
  20. print(">>> check site-logo")
  21. try :
  22. data = Data.objects.get(d_titre_slugify = "site-logo")
  23. except:
  24. data = Data()
  25. data.d_titre = "site-logo"
  26. data.d_type = "txt"
  27. data.d_variable = "far fa-clone"
  28. data.save()
  29. print(">>> heck site-version")
  30. try :
  31. data = Data.objects.get(d_titre_slugify = "site-version")
  32. except :
  33. data = Data()
  34. data.d_titre = "site-version"
  35. data.d_type = "txt"
  36. data.d_variable = "Jan. 2024"
  37. data.save()
  38. print(">>> check background-color")
  39. try :
  40. data = Data.objects.get(d_titre_slugify = "background-color")
  41. except :
  42. data = Data()
  43. data.d_titre = "background-color"
  44. data.d_type = "txt"
  45. data.d_variable = "#999"
  46. data.save()
  47. print(">>> check background")
  48. try :
  49. data = Data.objects.get(d_titre_slugify = "background")
  50. except :
  51. data = Data()
  52. data.d_titre = "background"
  53. data.d_type = "txt"
  54. data.d_variable = "background.jpeg"
  55. data.save()
  56. print(">>> check background-logo")
  57. try :
  58. data = Data.objects.get(d_titre_slugify = "background-logo")
  59. except :
  60. data = Data()
  61. data.d_titre = "background-logo"
  62. data.d_type = "txt"
  63. data.d_variable = "logo-txt-Mrduhaz.png"
  64. data.save()
  65. print(">>> check login-menu")
  66. try :
  67. data = Data.objects.get(d_titre_slugify = "login-menu")
  68. except :
  69. data = Data()
  70. data.d_titre = "login-menu"
  71. data.d_type = "txt"
  72. data.d_variable = "True"
  73. data.save()
  74. print(">>> check includ-right-panel")
  75. try :
  76. data = Data.objects.get(d_titre_slugify = "includ-right-panel")
  77. except :
  78. data = Data()
  79. data.d_titre = "includ-right-panel"
  80. data.d_type = "txt"
  81. data.d_variable = "None"
  82. data.save()
  83. print(">>> check card-main-panel")
  84. try :
  85. data = Data.objects.get(d_titre_slugify = "card-main-panel")
  86. except :
  87. data = Data()
  88. data.d_titre = "card-main-panel"
  89. data.d_type = "txt"
  90. data.d_variable = "True"
  91. data.save()
  92. print(">>> check card-right-panel")
  93. try :
  94. data = Data.objects.get(d_titre_slugify = "card-right-panel")
  95. except :
  96. data = Data()
  97. data.d_titre = "card-right-panel"
  98. data.d_type = "txt"
  99. data.d_variable = "True"
  100. data.save()
  101. print(">> Vérification des pages par default")
  102. from core.models import Page
  103. print(">>> check bienvenus ")
  104. try :
  105. page = Page.objects.get(p_titre_slugify = "bienvenus")
  106. except :
  107. page = Page()
  108. page.p_titre = "Bienvenus"
  109. page.p_icone = "fas fa-home"
  110. page.p_contenu = "Bravo,</br>Ceci est votre 1er page."
  111. page.p_description = "Bravo, ceci est votre 1er page."
  112. page.p_adresse = "/"
  113. page.p_publier = True
  114. page.p_type = "sys"
  115. page.save()