Browse Source

Corrige erro no salvamento dos anexos das ocorrencias

stable/1.0
Sesostris Vieira 11 years ago
parent
commit
d4ec47b737
  1. 22
      sigi/apps/ocorrencias/admin.py

22
sigi/apps/ocorrencias/admin.py

@ -18,7 +18,7 @@ class ComentarioViewInline(admin.TabularInline):
class ComentarioInline(admin.StackedInline): class ComentarioInline(admin.StackedInline):
model = Comentario model = Comentario
extra = 3 extra = 1
verbose_name, verbose_name_plural = u"Comentário novo", u"Comentários novos" verbose_name, verbose_name_plural = u"Comentário novo", u"Comentários novos"
fieldsets = ((None, {'fields': (('novo_status', 'encaminhar_setor',), 'descricao', )}),) fieldsets = ((None, {'fields': (('novo_status', 'encaminhar_setor',), 'descricao', )}),)
def queryset(self, request): def queryset(self, request):
@ -90,16 +90,16 @@ class OcorrenciaAdmin(admin.ModelAdmin):
servidor = Servidor.objects.get(user=request.user) servidor = Servidor.objects.get(user=request.user)
instances = formset.save(commit=False) instances = formset.save(commit=False)
for instance in instances: for instance in instances:
instance.usuario = servidor if isinstance(instance, Ocorrencia):
instance.usuario = servidor
if instance.encaminhar_setor and (instance.encaminhar_setor != instance.ocorrencia.setor_responsavel):
instance.ocorrencia.setor_responsavel = instance.encaminhar_setor
instance.ocorrencia.save()
if instance.novo_status and (instance.novo_status != instance.ocorrencia.status):
instance.ocorrencia.status = instance.novo_status
instance.ocorrencia.save()
instance.save() instance.save()
if instance.encaminhar_setor and (instance.encaminhar_setor != instance.ocorrencia.setor_responsavel): formset.save_m2m()
instance.ocorrencia.setor_responsavel = instance.encaminhar_setor
instance.ocorrencia.save()
if instance.novo_status and (instance.novo_status != instance.ocorrencia.status):
instance.ocorrencia.status = instance.novo_status
instance.ocorrencia.save()
formset.save_m2m()
admin.site.register(Ocorrencia, OcorrenciaAdmin) admin.site.register(Ocorrencia, OcorrenciaAdmin)
admin.site.register(Categoria) admin.site.register(Categoria)
Loading…
Cancel
Save