From d4ec47b737c547179f087e282071179f00485876 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ses=C3=B3stris=20Vieira?= Date: Thu, 24 Oct 2013 18:29:19 -0200 Subject: [PATCH] Corrige erro no salvamento dos anexos das ocorrencias --- sigi/apps/ocorrencias/admin.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sigi/apps/ocorrencias/admin.py b/sigi/apps/ocorrencias/admin.py index 6d9b4b9..cb61a3f 100644 --- a/sigi/apps/ocorrencias/admin.py +++ b/sigi/apps/ocorrencias/admin.py @@ -18,7 +18,7 @@ class ComentarioViewInline(admin.TabularInline): class ComentarioInline(admin.StackedInline): model = Comentario - extra = 3 + extra = 1 verbose_name, verbose_name_plural = u"Comentário novo", u"Comentários novos" fieldsets = ((None, {'fields': (('novo_status', 'encaminhar_setor',), 'descricao', )}),) def queryset(self, request): @@ -90,16 +90,16 @@ class OcorrenciaAdmin(admin.ModelAdmin): servidor = Servidor.objects.get(user=request.user) instances = formset.save(commit=False) 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() - 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() - - formset.save_m2m() + formset.save_m2m() admin.site.register(Ocorrencia, OcorrenciaAdmin) -admin.site.register(Categoria) +admin.site.register(Categoria) \ No newline at end of file