Category Delete View
This commit is contained in:
parent
f411040c3a
commit
31ba70efd1
@ -535,6 +535,8 @@ class Category(models.Model):
|
||||
def get_absolute_url(self, link='update'):
|
||||
if link == 'update' or link == 'edit':
|
||||
return reverse('motion_category_update', args=[str(self.id)])
|
||||
if link == 'delete':
|
||||
return reverse('motion_category_delete', args=[str(self.id)])
|
||||
|
||||
|
||||
## class Comment(models.Model):
|
||||
|
@ -119,4 +119,9 @@ urlpatterns = patterns('openslides.motion.views',
|
||||
'category_update',
|
||||
name='motion_category_update',
|
||||
),
|
||||
|
||||
url(r'^category/(?P<pk>\d+)/del/$',
|
||||
'category_delete',
|
||||
name='motion_category_delete',
|
||||
),
|
||||
)
|
||||
|
@ -496,6 +496,14 @@ class CategoryUpdateView(UpdateView):
|
||||
category_update = CategoryUpdateView.as_view()
|
||||
|
||||
|
||||
class CategoryDeleteView(DeleteView):
|
||||
permission_required = 'motion.can_manage_motion'
|
||||
model = Category
|
||||
success_url_name = 'motion_category_list'
|
||||
|
||||
category_delete = CategoryDeleteView.as_view()
|
||||
|
||||
|
||||
class Config(FormView):
|
||||
"""The View for the config tab."""
|
||||
permission_required = 'config.can_manage_config'
|
||||
|
@ -304,7 +304,8 @@ class DeleteView(SingleObjectMixin, QuestionMixin, RedirectView):
|
||||
return super(DeleteView, self).get(request, *args, **kwargs)
|
||||
|
||||
def get_redirect_url(self, **kwargs):
|
||||
if self.request.method == 'GET' and self.question_url_name is None:
|
||||
if self.question_url_name is None and (self.request.method == 'GET' or
|
||||
self.get_answer() == 'no'):
|
||||
return self.object.get_absolute_url()
|
||||
else:
|
||||
return super(DeleteView, self).get_redirect_url(**kwargs)
|
||||
|
Loading…
Reference in New Issue
Block a user