1
0

models.py 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. from email.policy import default
  2. from django.db import models
  3. from django.utils import timezone
  4. from django.template.defaultfilters import slugify
  5. from gest_clin.models import Clinique as Clinique
  6. from gest_clin.models import Services as Clin_Services
  7. TYPE = [
  8. ('PC', 'PC'),
  9. ('PORTABLE', 'Portable'),
  10. ('CL', 'Client Léger'),
  11. ('PANEL-PC', 'Panel-PC'),
  12. ('IMP', 'Imprimante'),
  13. ]
  14. STATUT = [
  15. ('RAS', '-'),
  16. ('PREPROD','En préparation'),
  17. ('HS','A réparer'),
  18. ('ADEPROD','A retirer'),
  19. ('EN STOCK', 'En stock'),
  20. ('INAPTE', 'Inapte / HS'),
  21. ]
  22. SWOS = [
  23. ('CISCO', 'Cisco'),
  24. ('ARUBA', 'Aruba'),
  25. ('HP', 'HP'),
  26. ]
  27. SWTYPE = [
  28. ('F', 'Fast'),
  29. ('G', 'Giga'),
  30. ]
  31. class VLAN(models.Model):
  32. VLAN_Nom = models.CharField("Nom du VLAN", max_length=64, unique=True)
  33. VLAN_N_slugify = models.CharField("Nom du VLAN slugifié", max_length=64, blank = True, editable = False)
  34. VLAN_Site = models.ForeignKey(Clinique, verbose_name="Clinique", on_delete=models.PROTECT, null=True)
  35. VLAN_IN = models.PositiveSmallIntegerField("Numéro uniq", default=0)
  36. VLAN_Des = models.CharField("Déscription VLAN", max_length=128)
  37. VLAN_Plag = models.CharField("Plage VLAN", max_length=64, blank = True,)
  38. VLAN_Route = models.CharField("Route VLAN", max_length=64, blank = True,)
  39. def save(self, *args, **kwargs) :
  40. self.VLAN_N_slugify = slugify(self.VLAN_Nom)
  41. super(VLAN, self).save(*args, **kwargs)
  42. def __str__(self):
  43. return str(self.VLAN_Nom)
  44. class Meta:
  45. verbose_name = "VLAN de la Clinique"
  46. verbose_name_plural = "VLANs de la Clinique"
  47. ordering = ["VLAN_IN"]
  48. class Accessory_Link(models.Model):
  49. Accessory_Nom = models.CharField("Nom de l\'accesoire", max_length=64, unique=True)
  50. Accessory_N_slugify = models.CharField("Nom de l\'accesoir slugifié", max_length=64, blank = True, editable = False)
  51. Accessory_icone = models.CharField("Code de l'icone", max_length = 64, blank = True)
  52. Accessory_on_list = models.BooleanField("Afficher sur le listing", default=False)
  53. def save(self, *args, **kwargs) :
  54. self.Accessory_N_slugify = slugify(self.Accessory_Nom)
  55. super(Accessory_Link, self).save(*args, **kwargs)
  56. def __str__(self):
  57. return str(self.Accessory_Nom)
  58. class Meta:
  59. verbose_name = "Accessoires lié un poste Informatique"
  60. verbose_name_plural = "Accessoires lié un poste Informatique"
  61. class PIC(models.Model):
  62. PIC_NUnic = models.PositiveSmallIntegerField("ID Sérial", unique=False, default=0)
  63. PIC_L_Statut = models.CharField("Statut", max_length=16, choices=STATUT, default='RAS')
  64. PIC_Site = models.ForeignKey(Clinique, verbose_name="Clinique", on_delete=models.PROTECT, null=True)
  65. PIC_L_Chassi_Type = models.CharField("Type", max_length=8, choices=TYPE, default='PC')
  66. PIC_Deg = models.BooleanField("Poste avec procédure dégradé", default=False)
  67. PIC_is_for_Cadre = models.BooleanField("Poste utiliser pas des RUS ou Cadre", default=False)
  68. PIC_with_Snow = models.BooleanField("Sync avec Snow", default=False)
  69. PIC_with_Office = models.BooleanField("Office installé sur le poste", default=False)
  70. PIC_Nom_netbios = models.CharField("Nom NETBIOS", max_length=64, blank=True, null=True)
  71. PIC_Utilisateur = models.CharField("Utilisateur", max_length=64, blank=True, null=True)
  72. PIC_Utilisateur_Fq = models.CharField("Utilisateur Frequent", max_length=64, blank=True, null=True)
  73. PIC_Service = models.ForeignKey(Clin_Services, verbose_name="Service", on_delete=models.PROTECT, blank=True, null=True)
  74. PIC_Local = models.CharField("Localisation", max_length=64, blank=True, null=True)
  75. PIC_Adresse_IP = models.CharField("Adresse IP", max_length=32, default="DHCP" )
  76. PIC_Adresse_Mac = models.CharField("Adresse MAC", max_length=18, blank=True, null=True)
  77. PIC_OS = models.CharField("OS", max_length=64, blank=True, null=True)
  78. PIC_Marque = models.CharField("Marque", max_length=64, blank=True, null=True)
  79. PIC_Type = models.CharField("Modèle", max_length=64, blank=True, null=True)
  80. PIC_SN = models.CharField("SN", max_length=64, blank=True, null=True)
  81. PIC_Date_Achat = models.CharField("Date d'achat", max_length=64, blank=True, null=True)
  82. PIC_Fin_de_Garantie = models.CharField("Date de fin de garentie", max_length=64, blank=True, null=True)
  83. PIC_CPU = models.CharField("CPU", max_length=64, blank=True, null=True)
  84. PIC_RAM = models.PositiveSmallIntegerField("RAM", blank=True, null=True)
  85. PIC_Commentaires = models.TextField("Commentaires", blank=True, null=True)
  86. PIC_Precisions = models.TextField("Precisions", blank=True, null=True)
  87. PIC_Accessory = models.ManyToManyField(Accessory_Link, blank=True)
  88. def __str__(self):
  89. return self.PIC_Nom_netbios
  90. def save(self, *args, **kwargs):
  91. if self.PIC_Nom_netbios != None :
  92. if "GEN-" in self.PIC_Nom_netbios or "CAP-" in self.PIC_Nom_netbios or "HPN-" in self.PIC_Nom_netbios:
  93. tmp_PIC_NUnic = self.PIC_Nom_netbios[-4:]
  94. try:
  95. self.PIC_NUnic = int(tmp_PIC_NUnic)
  96. except:
  97. pass
  98. self.PIC_Nom_netbios = self.PIC_Nom_netbios.upper()
  99. if self.PIC_Adresse_IP != None :
  100. self.PIC_Adresse_IP = self.PIC_Adresse_IP.replace(',','.').replace(';','.')
  101. if self.PIC_Adresse_IP != None :
  102. self.PIC_Adresse_IP = self.PIC_Adresse_IP.replace(',','.').replace(';','.')
  103. super(PIC, self).save(*args, **kwargs)
  104. class Meta:
  105. verbose_name = "Poste client"
  106. verbose_name_plural = "Postes clients"
  107. class PIC_History(models.Model):
  108. H_PIC = models.ForeignKey("PIC", on_delete=models.CASCADE)
  109. H_Date = models.DateTimeField("Date", auto_now_add=True)
  110. H_Commentaire = models.TextField("Historique")
  111. def __str__(self):
  112. return str(self.H_PIC)
  113. class Meta:
  114. verbose_name = "Historique un poste Informatique"
  115. verbose_name_plural = "Historique lié un poste Informatique"
  116. class PIS(models.Model):
  117. PIC_NUnic = models.PositiveSmallIntegerField("Numéro uniq", unique=True, blank=True, null=True)
  118. PIS_Site = models.ForeignKey(Clinique, verbose_name="Clinique", on_delete=models.PROTECT, null=True)
  119. PIS_Nom_netbios = models.CharField("Nom NETBIOS", max_length=64, blank=True, null=True)
  120. PIS_Friendly_Name = models.CharField("Friendly Name", max_length=64, blank=True, null=True)
  121. PIS_OS = models.CharField("OS", max_length=64, blank=True, null=True)
  122. PIS_with_Snow = models.BooleanField("Sync avec Snow", default=False)
  123. PIS_with_Web = models.BooleanField("Portail web", default=False)
  124. PIS_Adresse_IP = models.CharField("Adresse IP", max_length=64, blank=True, null=True)
  125. PIS_Adresse_Mac = models.CharField("Adresse MAC", max_length=64, blank=True, null=True)
  126. PIS_Role = models.CharField("Application", max_length=64, blank=True, null=True)
  127. PIS_Type = models.CharField("Type", max_length=64, blank=True, null=True)
  128. PIS_SN = models.CharField("SN", max_length=64, blank=True, null=True)
  129. PIS_CPU = models.CharField("CPU", max_length=64, blank=True, null=True)
  130. PIS_RAM = models.PositiveSmallIntegerField("RAM", blank=True, null=True)
  131. PIS_Localisation = models.CharField("Localisation", max_length=64, blank=True, null=True)
  132. PIS_Fonctionnalite = models.TextField("Fonctionnalité", blank=True, null=True)
  133. PIS_Commentaires = models.TextField("Commentaires", blank=True, null=True)
  134. PIS_Archive = models.BooleanField("Serveur plus en Production", default=False)
  135. def __str__(self):
  136. return self.PIS_Nom_netbios
  137. def save(self, *args, **kwargs):
  138. self.PIS_Nom_netbios = self.PIS_Nom_netbios.upper()
  139. if self.PIS_Type != None :
  140. self.PIS_Type = self.PIS_Type.upper()
  141. if self.PIS_Role != None :
  142. self.PIS_Role = self.PIS_Role.upper()
  143. if self.PIS_Adresse_IP != None :
  144. self.PIS_Adresse_IP = self.PIS_Adresse_IP.replace(',','.').replace(';','.')
  145. if self.PIS_Commentaires != None :
  146. self.PIS_Commentaires = self.PIS_Commentaires.replace(',','.').replace(';','.')
  147. super(PIS, self).save(*args, **kwargs)
  148. class Meta:
  149. verbose_name = "Serveur"
  150. verbose_name_plural = "Serveurs"
  151. class Swich(models.Model):
  152. SW_Baie = models.ForeignKey("Baie", on_delete=models.CASCADE)
  153. SW_Nom = models.CharField("Nom", max_length=64)
  154. SW_IP = models.CharField("Adresse IP", max_length=64, blank=True, null=True)
  155. SW_OS = models.CharField("OS", max_length=5, choices=SWOS, default='HP')
  156. SW_TYPE = models.CharField("Type", max_length=1, choices=SWTYPE, default='G')
  157. SW_Commentaires = models.TextField("Commentaires", blank=True, null=True)
  158. SW_Update_Port = models.TextField("Last Auto update port of switch", blank=True, null=True)
  159. SW_Archive = models.BooleanField("Switch plus en production", default=False)
  160. class Meta:
  161. verbose_name = "Switch"
  162. verbose_name_plural = "Switchs"
  163. def __str__(self):
  164. return self.SW_Nom
  165. class Port_Link(models.Model):
  166. PL_Swich = models.ForeignKey("Swich", on_delete=models.CASCADE)
  167. PL_Port_NG = models.CharField("Port sur le Switch", max_length=10)
  168. PL_VLAN = models.PositiveSmallIntegerField("VLAN sur le Port")
  169. PL_Headbang_plug = models.CharField("Prise sur le bandeau", max_length=8, blank=True)
  170. PL_Commentaires = models.TextField("Commentaires", blank=True, null=True)
  171. def __str__(self):
  172. return str(self.PL_Swich)+' - '+str(self.PL_Port)
  173. class Meta:
  174. verbose_name = "Lien des prises vers les Switchs"
  175. verbose_name_plural = "Lien des prises vers les Switchs"
  176. class Baie(models.Model):
  177. BAIE_Site_NG = models.ForeignKey(Clinique, verbose_name="Clinique", on_delete=models.PROTECT, null=True)
  178. BAIE_Nom = models.CharField("Nom de la Baie", max_length=32, unique=True)
  179. BAIE_Local = models.CharField("Localisation", max_length=64, blank=True, null=True)
  180. BAIE_Commentaire = models.TextField("Commentaires", blank=True, null=True)
  181. def __str__(self):
  182. return self.BAIE_Nom
  183. class Meta:
  184. verbose_name = "Baie"
  185. verbose_name_plural = "Baies"