models.py 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222
  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_Office = models.BooleanField("Office installé sur le poste", default=False)
  69. PIC_Nom_netbios = models.CharField("Nom NETBIOS", max_length=64, blank=True, null=True)
  70. PIC_Utilisateur = models.CharField("Utilisateur", max_length=64, blank=True, null=True)
  71. PIC_Utilisateur_Fq = models.CharField("Utilisateur Frequent", max_length=64, blank=True, null=True)
  72. PIC_Service = models.ForeignKey(Clin_Services, verbose_name="Service", on_delete=models.PROTECT, blank=True, null=True)
  73. PIC_Local = models.CharField("Localisation", max_length=64, blank=True, null=True)
  74. PIC_Adresse_IP = models.CharField("Adresse IP", max_length=64, default="DHCP" )
  75. PIC_Adresse_Mac = models.CharField("Adresse MAC", max_length=64, blank=True, null=True)
  76. PIC_OS = models.CharField("OS", max_length=64, blank=True, null=True)
  77. PIC_Marque = models.CharField("Marque", max_length=64, blank=True, null=True)
  78. PIC_Type = models.CharField("Modèle", max_length=64, blank=True, null=True)
  79. PIC_SN = models.CharField("SN", max_length=64, blank=True, null=True)
  80. PIC_Date_Achat = models.CharField("Date d'achat", max_length=64, blank=True, null=True)
  81. PIC_Fin_de_Garantie = models.CharField("Date de fin de garentie", max_length=64, blank=True, null=True)
  82. PIC_CPU = models.CharField("CPU", max_length=64, blank=True, null=True)
  83. PIC_RAM = models.PositiveSmallIntegerField("RAM", blank=True, null=True)
  84. PIC_Commentaires = models.TextField("Commentaires", blank=True, null=True)
  85. PIC_Precisions = models.TextField("Precisions", blank=True, null=True)
  86. PIC_Accessory = models.ManyToManyField(Accessory_Link, blank=True)
  87. def __str__(self):
  88. return self.PIC_Nom_netbios
  89. def save(self, *args, **kwargs):
  90. if self.PIC_Nom_netbios != None :
  91. if "GEN-" in self.PIC_Nom_netbios or "CAP-" in self.PIC_Nom_netbios or "HPN-" in self.PIC_Nom_netbios:
  92. tmp_PIC_NUnic = self.PIC_Nom_netbios[-4:]
  93. try:
  94. self.PIC_NUnic = int(tmp_PIC_NUnic)
  95. except:
  96. pass
  97. self.PIC_Nom_netbios = self.PIC_Nom_netbios.upper()
  98. if self.PIC_Adresse_IP != None :
  99. self.PIC_Adresse_IP = self.PIC_Adresse_IP.replace(',','.').replace(';','.')
  100. if self.PIC_Adresse_IP != None :
  101. self.PIC_Adresse_IP = self.PIC_Adresse_IP.replace(',','.').replace(';','.')
  102. super(PIC, self).save(*args, **kwargs)
  103. class Meta:
  104. verbose_name = "Poste client"
  105. verbose_name_plural = "Postes clients"
  106. class PIC_History(models.Model):
  107. H_PIC = models.ForeignKey("PIC", on_delete=models.CASCADE)
  108. H_Date = models.DateTimeField("Date", auto_now_add=True)
  109. H_Commentaire = models.TextField("Historique")
  110. def __str__(self):
  111. return str(self.H_PIC)
  112. class Meta:
  113. verbose_name = "Historique un poste Informatique"
  114. verbose_name_plural = "Historique lié un poste Informatique"
  115. class PIS(models.Model):
  116. PIC_NUnic = models.PositiveSmallIntegerField("Numéro uniq", unique=True, blank=True, null=True)
  117. PIS_Site = models.ForeignKey(Clinique, verbose_name="Clinique", on_delete=models.PROTECT, null=True)
  118. PIS_Nom_netbios = models.CharField("Nom NETBIOS", max_length=64, blank=True, null=True)
  119. PIS_Friendly_Name = models.CharField("Friendly Name", max_length=64, blank=True, null=True)
  120. PIS_OS = models.CharField("OS", max_length=64, blank=True, null=True)
  121. PIS_with_Web = models.BooleanField("Portail web", default=False)
  122. PIS_Adresse_IP = models.CharField("Adresse IP", max_length=64, blank=True, null=True)
  123. PIS_Adresse_Mac = models.CharField("Adresse MAC", max_length=64, blank=True, null=True)
  124. PIS_Role = models.CharField("Application", max_length=64, blank=True, null=True)
  125. PIS_Type = models.CharField("Type", max_length=64, blank=True, null=True)
  126. PIS_SN = models.CharField("SN", max_length=64, blank=True, null=True)
  127. PIS_CPU = models.CharField("CPU", max_length=64, blank=True, null=True)
  128. PIS_RAM = models.PositiveSmallIntegerField("RAM", blank=True, null=True)
  129. PIS_Localisation = models.CharField("Localisation", max_length=64, blank=True, null=True)
  130. PIS_Fonctionnalite = models.TextField("Fonctionnalité", blank=True, null=True)
  131. PIS_Commentaires = models.TextField("Commentaires", blank=True, null=True)
  132. PIS_Archive = models.BooleanField("Serveur plus en Production", default=False)
  133. def __str__(self):
  134. return self.PIS_Nom_netbios
  135. def save(self, *args, **kwargs):
  136. self.PIS_Nom_netbios = self.PIS_Nom_netbios.upper()
  137. if self.PIS_Type != None :
  138. self.PIS_Type = self.PIS_Type.upper()
  139. if self.PIS_Role != None :
  140. self.PIS_Role = self.PIS_Role.upper()
  141. if self.PIS_Adresse_IP != None :
  142. self.PIS_Adresse_IP = self.PIS_Adresse_IP.replace(',','.').replace(';','.')
  143. if self.PIS_Commentaires != None :
  144. self.PIS_Commentaires = self.PIS_Commentaires.replace(',','.').replace(';','.')
  145. super(PIS, self).save(*args, **kwargs)
  146. class Meta:
  147. verbose_name = "Serveur"
  148. verbose_name_plural = "Serveurs"
  149. class Swich(models.Model):
  150. SW_Baie = models.ForeignKey("Baie", on_delete=models.CASCADE)
  151. SW_Nom = models.CharField("Nom", max_length=64)
  152. SW_IP = models.CharField("Adresse IP", max_length=64, blank=True, null=True)
  153. SW_OS = models.CharField("OS", max_length=5, choices=SWOS, default='HP')
  154. SW_TYPE = models.CharField("Type", max_length=1, choices=SWTYPE, default='G')
  155. SW_Commentaires = models.TextField("Commentaires", blank=True, null=True)
  156. SW_Update_Port = models.TextField("Last Auto update port of switch", blank=True, null=True)
  157. SW_Archive = models.BooleanField("Switch plus en production", default=False)
  158. class Meta:
  159. verbose_name = "Switch"
  160. verbose_name_plural = "Switchs"
  161. def __str__(self):
  162. return self.SW_Nom
  163. class Port_Link(models.Model):
  164. PL_Swich = models.ForeignKey("Swich", on_delete=models.CASCADE)
  165. PL_Port_NG = models.CharField("Port sur le Switch", max_length=10)
  166. PL_VLAN = models.PositiveSmallIntegerField("VLAN sur le Port")
  167. PL_Headbang_plug = models.CharField("Prise sur le bandeau", max_length=8, blank=True)
  168. PL_Commentaires = models.TextField("Commentaires", blank=True, null=True)
  169. def __str__(self):
  170. return str(self.PL_Swich)+' - '+str(self.PL_Port)
  171. class Meta:
  172. verbose_name = "Lien des prises vers les Switchs"
  173. verbose_name_plural = "Lien des prises vers les Switchs"
  174. class Baie(models.Model):
  175. BAIE_Site_NG = models.ForeignKey(Clinique, verbose_name="Clinique", on_delete=models.PROTECT, null=True)
  176. BAIE_Nom = models.CharField("Nom de la Baie", max_length=32, unique=True)
  177. BAIE_Local = models.CharField("Localisation", max_length=64, blank=True, null=True)
  178. BAIE_Commentaire = models.TextField("Commentaires", blank=True, null=True)
  179. def __str__(self):
  180. return self.BAIE_Nom
  181. class Meta:
  182. verbose_name = "Baie"
  183. verbose_name_plural = "Baies"