Commit 63848d8c authored by Robert's avatar Robert

Moved delete command to gestalt model

parent 11838fd2
......@@ -64,6 +64,17 @@ class Gestalt(core.models.Model):
def can_login(self):
return self.user.has_usable_password()
def delete(self, *args, **kwargs):
data = self.get_data()
unknown_gestalt = Gestalt.objects.get(id=settings.GROUPRISE_UNKNOWN_GESTALT_ID)
data['associations'].update(entity_id=unknown_gestalt.id)
data['contributions'].update(author=unknown_gestalt)
data['images'].update(creator=unknown_gestalt)
data['memberships_created'].update(created_by=unknown_gestalt)
data['versions'].update(author=unknown_gestalt)
data['votes'].update(voter=unknown_gestalt)
self.user.delete()
def get_absolute_url(self):
if self.public:
return self.get_profile_url()
......
......@@ -38,20 +38,10 @@ class Delete(PermissionMixin, DeleteView):
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):
user = self.request.user
self.data = user.gestalt.get_data()
return user
gestalt = self.request.user.gestalt
self.data = gestalt.get_data()
return gestalt
class Detail(
......
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