Commit db73b510 by benjaoming

redirect for delete view to parent

parent dcf7e721
...@@ -126,21 +126,20 @@ class Delete(FormView, ArticleMixin): ...@@ -126,21 +126,20 @@ class Delete(FormView, ArticleMixin):
therefore it is separate.""" therefore it is separate."""
urlpath = kwargs.get('urlpath', None) urlpath = kwargs.get('urlpath', None)
# Where to go after deletion... # Where to go after deletion...
self.next = request.GET.get('next', None) self.next = ""
self.cannot_delete_root = False self.cannot_delete_root = False
if not self.next: if urlpath and urlpath.parent:
if urlpath and urlpath.parent: self.next = reverse('wiki:get', kwargs={'path': urlpath.parent.path})
self.next = reverse('wiki:get', kwargs={'path': urlpath.parent.path}) elif urlpath:
elif urlpath: # We are a urlpath with no parent. This is the root
# We are a urlpath with no parent. This is the root self.cannot_delete_root = True
self.cannot_delete_root = True else:
else: # We have no urlpath. Get it if a urlpath exists
# We have no urlpath. Get it if a urlpath exists for art_obj in article.articleforobject_set.filter(is_mptt=True):
for art_obj in article.articleforobject_set.filter(is_mptt=True): if art_obj.content_object.parent:
if art_obj.content_object.parent: self.next = reverse('wiki:get', kwargs={'article_id': art_obj.content_object.parent.article.id})
self.next = reverse('wiki:get', kwargs={'article_id': art_obj.content_object.parent.article.id}) else:
else: self.cannot_delete_root = True
self.cannot_delete_root = True
return super(Delete, self).dispatch(request, article, *args, **kwargs) return super(Delete, self).dispatch(request, article, *args, **kwargs)
......
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