Browse Source

Fix #113

pull/153/head
Edward Ribeiro 9 years ago
parent
commit
5278a6b4e6
  1. 2
      base/models.py
  2. 7
      base/views.py

2
base/models.py

@ -3,7 +3,7 @@ from django.utils.translation import ugettext_lazy as _
def get_sessao_media_path(instance, subpath, filename):
return './casa/%s/%s/%s' % (instance.codigo, subpath, filename)
return './casa/%s/%s' % (subpath, filename)
def get_casa_media_path(instance, filename):

7
base/views.py

@ -183,8 +183,9 @@ class CasaLegislativaTableAuxView(FormMixin, GenericView):
if form.is_valid():
casa = CasaLegislativa.objects.first()
if casa is not None:
if "remover" in request.POST:
if casa:
if ("remover" in request.POST or
(form.cleaned_data['logotipo'] and casa.logotipo)):
try:
os.unlink(casa.logotipo.path)
except OSError:
@ -196,7 +197,7 @@ class CasaLegislativaTableAuxView(FormMixin, GenericView):
instance=casa
).save(commit=False)
casa_save.save()
elif casa is None:
else:
form.save()
return self.form_valid(form)
else:

Loading…
Cancel
Save