apps.py 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import sys
  2. from django.apps import AppConfig
  3. class ParcInfoConfig(AppConfig):
  4. default_auto_field = 'django.db.models.BigAutoField'
  5. name = 'parc_info'
  6. verbose_name = 'Parc Informatique'
  7. def ready(self):
  8. if 'migrate' in sys.argv:
  9. return
  10. print("-- Démarage de la gestion du Parc --")
  11. print(">> Vérification des variables d'environement")
  12. from core.models import Data
  13. try :
  14. data = Data.objects.get(d_titre_slugify = "range-imp")
  15. except:
  16. data = Data()
  17. data.d_titre = "range-imp"
  18. data.d_type = "IMP"
  19. data.d_variable = "900;999"
  20. data.save()
  21. try :
  22. data = Data.objects.get(d_titre_slugify = "range-pc")
  23. except:
  24. data = Data()
  25. data.d_titre = "range-pc"
  26. data.d_type = "PC"
  27. data.d_variable = "1;899"
  28. data.save()
  29. print(">> Vérification des pages")
  30. from core.models import Page
  31. try :
  32. page = Page.objects.get(p_titre_slugify = "parc")
  33. except :
  34. page = Page()
  35. page.p_titre = "Parc"
  36. page.p_icone = "fas fa-map-marked-alt"
  37. page.p_adresse = "/parc"
  38. page.p_menu_position = "haut"
  39. page.p_menu_est_parent = "True"
  40. page.p_type = "sys"
  41. page.p_menu_poid = 90
  42. page.p_publier = False
  43. page.save()
  44. tmp_page_parent = page
  45. try :
  46. page = Page.objects.get(p_titre_slugify = "les-equipements-utilisateurs")
  47. except :
  48. page = Page()
  49. page.p_titre = "Les équipements utilisateurs"
  50. page.p_icone = "fas fa-desktop"
  51. page.p_adresse = "/parc/clients"
  52. page.p_menu_position = "haut"
  53. page.p_menu_est_parent = "False"
  54. page.p_menu_parent = tmp_page_parent
  55. page.p_type = "sys"
  56. page.p_menu_poid = 90
  57. page.p_publier = True
  58. page.save()
  59. try :
  60. page = Page.objects.get(p_titre_slugify = "les-serveurs")
  61. except :
  62. page = Page()
  63. page.p_titre = "Les serveurs"
  64. page.p_icone = "fas fa-server"
  65. page.p_adresse = "/parc/serveurs"
  66. page.p_menu_position = "haut"
  67. page.p_menu_est_parent = "False"
  68. page.p_menu_parent = tmp_page_parent
  69. page.p_type = "sys"
  70. page.p_menu_poid = 90
  71. page.p_publier = True
  72. page.save()
  73. try :
  74. page = Page.objects.get(p_titre_slugify = "les-switchs")
  75. except :
  76. page = Page()
  77. page.p_titre = "Les switchs"
  78. page.p_icone = "fas fa-ethernet"
  79. page.p_adresse = "/parc/switch"
  80. page.p_menu_position = "haut"
  81. page.p_menu_est_parent = "False"
  82. page.p_menu_parent = tmp_page_parent
  83. page.p_type = "sys"
  84. page.p_menu_poid = 90
  85. page.p_publier = True
  86. page.save()
  87. try :
  88. page = Page.objects.get(p_titre_slugify = "listing-des-imprimantes")
  89. except :
  90. page = Page()
  91. page.p_titre = "Listing des imprimantes"
  92. page.p_icone = "fas fa-print"
  93. page.p_adresse = "/parc/clients/imp"
  94. page.p_menu_position = "haut"
  95. page.p_menu_est_parent = "False"
  96. page.p_menu_parent = tmp_page_parent
  97. page.p_type = "sys"
  98. page.p_menu_poid = 90
  99. page.p_publier = True
  100. page.save()
  101. try :
  102. page = Page.objects.get(p_titre_slugify = "inventaire")
  103. except :
  104. page = Page()
  105. page.p_titre = "Inventaire par services"
  106. page.p_titre_slugify = "inventaire"
  107. page.p_icone = "fas fa-boxes"
  108. page.p_adresse = "/parc/clients/stat/par-services"
  109. page.p_menu_position = "haut"
  110. page.p_menu_est_parent = "False"
  111. page.p_menu_parent = tmp_page_parent
  112. page.p_type = "sys"
  113. page.p_menu_poid = 90
  114. page.p_publier = True
  115. page.save()