Guest User

Untitled

a guest
Jun 18th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. class ExpedienteDPI():
  2. folio = models.CharField(max_length=13)
  3. fecha_tramite = models.DateField(null=True, blank=True)
  4. fecha_notificacion_aclaracion = models.DateField(
  5. 'TRÁMITE: Notificación',
  6. help_text='Fecha de notificación de aclaración al ciudadano AC',
  7. null=True, blank=True
  8. )
  9. # muchos campos mas
  10. # Siguen solo campos calculados
  11. delta_notificar = models.SmallIntegerField(
  12. help_text="Delta entre tramite y notificación",
  13. editable=False, null=True
  14. )
  15. completo = models.PositiveSmallIntegerField(editable=False, null=False, default=0)
  16.  
  17. def save(self, force_insert=False, force_update=False):
  18. self.delta_notificar = delta(self.fecha_tramite, self.fecha_notificacion_aclaracion)
  19. # Muchos campos calculados
  20. if self.entidad == 29 and
  21. self.fecha_tramite and
  22. self.fecha_entrevista and
  23. self.fecha_envio_expediente and
  24. self.fecha_notificacion_aclaracion:
  25. self.completo = 1
  26. else:
  27. self.completo = 0
  28. super(ExpedienteDPI, self).save(force_insert=False, force_update=False)
  29.  
  30. for x in ExpedienteDPI.objects.all():
  31. if x.entidad == 29 and
  32. x.fecha_tramite and
  33. x.fecha_entrevista and
  34. x.fecha_envio_expediente and
  35. x.fecha_notificacion_aclaracion:
  36. if x.completo == 0:
  37. print(f'Completo vale {x.completo}. Cambiando {x.folio} a "Completo"')
  38. x.completo = 1
  39. else:
  40. print(f"{x.folio} - Completo")
  41. else:
  42. print(f"{x.folio} - Incompleto")
  43. x.completo = 0
  44. x.save(force_update=True)
  45.  
  46. 1729032100849 - Incompleto
  47. Completo vale 0. Cambiando 1729012101027 a "Completo"
  48. 1729022401044 - Incompleto
  49. 1729032100652 - Incompleto
  50. Completo vale 0. Cambiando 1729022200132 a "Completo"
  51. 1729032100109 - Incompleto
  52.  
  53. UPDATE dpi_expedientedpi
  54. SET completo = 1
  55. WHERE folio = '1729025301604'
  56. SELECT folio, completo FROM dpi_expedientedpi WHERE folio = '1729025301604';
Add Comment
Please, Sign In to add comment