Commit 11838fd2 authored by Robert's avatar Robert

Added delete action

parent 2997b788
......@@ -91,6 +91,7 @@ class Gestalt(core.models.Model):
data['associations'] = self.associations
data['contributions'] = self.contributions
data['images'] = self.images
data['memberships_created'] = self.memberships_created
data['versions'] = self.versions
data['votes'] = self.votes
return data
......
......@@ -3,6 +3,7 @@ import django
from allauth.account import views
from allauth.account import views as allauth_views
from crispy_forms import layout
from django.conf import settings
from django.urls import reverse
from django.views import generic
from django.views.generic import edit as edit_views, DeleteView, UpdateView
......@@ -35,11 +36,22 @@ class Create(utils_views.ActionMixin, views.SignupView):
class Delete(PermissionMixin, DeleteView):
permission_required = 'gestalten.delete'
template_name = 'gestalten/delete.html'
success_url = '/'
def delete(self, request, *args, **kwargs):
unknown_gestalt = models.Gestalt.objects.get(id=settings.GROUPRISE_UNKNOWN_GESTALT_ID)
self.data['associations'].update(entity_id=unknown_gestalt.id)
self.data['contributions'].update(author=unknown_gestalt)
self.data['images'].update(creator=unknown_gestalt)
self.data['memberships_created'].update(created_by=unknown_gestalt)
self.data['versions'].update(author=unknown_gestalt)
self.data['votes'].update(voter=unknown_gestalt)
return super().delete(request, *args, **kwargs)
def get_object(self):
gestalt = self.request.user.gestalt
self.data = gestalt.get_data()
return gestalt
user = self.request.user
self.data = user.gestalt.get_data()
return user
class Detail(
......
......@@ -226,6 +226,8 @@ HAS_PIWIK = True
STADTGESTALTEN_INTRO_TEXT = ''
GROUPRISE_UNKNOWN_GESTALT_ID = 1
# Authentication
# http://django-allauth.readthedocs.org/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment