Browse Source

Delete user

pull/906/head
Eduardo Edson Batista Cordeiro Alves 8 years ago
parent
commit
de67f6c8aa
  1. 1
      sapl/parlamentares/forms.py
  2. 11
      sapl/parlamentares/views.py

1
sapl/parlamentares/forms.py

@ -309,7 +309,6 @@ class VotanteForm(ModelForm):
def save(self, commit=False):
votante = super(VotanteForm, self).save(commit)
u = User.objects.get(username=self.cleaned_data['username'])
u = User.objects.create(
username=self.cleaned_data['username'],
email=self.cleaned_data['email'])

11
sapl/parlamentares/views.py

@ -4,6 +4,7 @@ from django.core.urlresolvers import reverse, reverse_lazy
from django.utils.datastructures import MultiValueDictKeyError
from django.utils.translation import ugettext_lazy as _
from django.views.generic import FormView
from django.http.response import HttpResponseRedirect
from sapl.comissoes.models import Participacao
from sapl.crud.base import (RP_CHANGE, RP_DETAIL, RP_LIST, Crud, CrudAux,
@ -57,6 +58,16 @@ class VotanteView(MasterDetailCrud):
def detail_create_url(self):
return None
class DeleteView(MasterDetailCrud.DeleteView):
def delete(self, *args, **kwargs):
obj = self.get_object()
if obj.user:
obj.user.delete()
return HttpResponseRedirect(
reverse('sapl.parlamentares:votante_list',
kwargs={'pk': obj.parlamentar.pk}))
class FrenteList(MasterDetailCrud):
model = Frente

Loading…
Cancel
Save