Merge pull request #2 from ostcar/category

Category Delete View
This commit is contained in:
Emanuel Schütze 2013-03-11 13:45:54 -07:00
commit db97d3c312
4 changed files with 17 additions and 1 deletions

View File

@ -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 Meta:
ordering = ['prefix']

View File

@ -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',
),
)

View File

@ -492,6 +492,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'

View File

@ -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)