Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class ExpedienteDPI():
- folio = models.CharField(max_length=13)
- fecha_tramite = models.DateField(null=True, blank=True)
- fecha_notificacion_aclaracion = models.DateField(
- 'TRÁMITE: Notificación',
- help_text='Fecha de notificación de aclaración al ciudadano AC',
- null=True, blank=True
- )
- # muchos campos mas
- # Siguen solo campos calculados
- delta_notificar = models.SmallIntegerField(
- help_text="Delta entre tramite y notificación",
- editable=False, null=True
- )
- completo = models.PositiveSmallIntegerField(editable=False, null=False, default=0)
- def save(self, force_insert=False, force_update=False):
- self.delta_notificar = delta(self.fecha_tramite, self.fecha_notificacion_aclaracion)
- # Muchos campos calculados
- if self.entidad == 29 and
- self.fecha_tramite and
- self.fecha_entrevista and
- self.fecha_envio_expediente and
- self.fecha_notificacion_aclaracion:
- self.completo = 1
- else:
- self.completo = 0
- super(ExpedienteDPI, self).save(force_insert=False, force_update=False)
- for x in ExpedienteDPI.objects.all():
- if x.entidad == 29 and
- x.fecha_tramite and
- x.fecha_entrevista and
- x.fecha_envio_expediente and
- x.fecha_notificacion_aclaracion:
- if x.completo == 0:
- print(f'Completo vale {x.completo}. Cambiando {x.folio} a "Completo"')
- x.completo = 1
- else:
- print(f"{x.folio} - Completo")
- else:
- print(f"{x.folio} - Incompleto")
- x.completo = 0
- x.save(force_update=True)
- 1729032100849 - Incompleto
- Completo vale 0. Cambiando 1729012101027 a "Completo"
- 1729022401044 - Incompleto
- 1729032100652 - Incompleto
- Completo vale 0. Cambiando 1729022200132 a "Completo"
- 1729032100109 - Incompleto
- UPDATE dpi_expedientedpi
- SET completo = 1
- WHERE folio = '1729025301604'
- SELECT folio, completo FROM dpi_expedientedpi WHERE folio = '1729025301604';
Add Comment
Please, Sign In to add comment