diff --git a/openslides/motion/models.py b/openslides/motion/models.py index 0be499419..8c8d8ad60 100644 --- a/openslides/motion/models.py +++ b/openslides/motion/models.py @@ -336,9 +336,16 @@ class MotionPoll(CountInvalid, CountVotesCast, BasePoll): class Meta: unique_together = ("motion", "poll_number") + def __unicode__(self): + return _('Ballot %d') % self.poll_number + def get_absolute_url(self, link='edit'): - return reverse('motion_poll_edit', args=[str(self.motion.pk), - str(self.poll_number)]) + if link == 'edit': + return reverse('motion_poll_edit', args=[str(self.motion.pk), + str(self.poll_number)]) + if link == 'delete': + return reverse('motion_poll_delete', args=[str(self.motion.pk), + str(self.poll_number)]) def get_motion(self): return self.motion diff --git a/openslides/motion/templates/motion/motion_detail.html b/openslides/motion/templates/motion/motion_detail.html index 86c27502e..22e80067c 100644 --- a/openslides/motion/templates/motion/motion_detail.html +++ b/openslides/motion/templates/motion/motion_detail.html @@ -43,10 +43,10 @@
  • {% if perms.motion.can_manage_motion %} {{ forloop.counter }}. {% trans "Vote" %} - + - + {% elif poll.has_votes %} diff --git a/openslides/motion/urls.py b/openslides/motion/urls.py index bdd7575a6..449de24d8 100644 --- a/openslides/motion/urls.py +++ b/openslides/motion/urls.py @@ -53,13 +53,13 @@ urlpatterns = patterns('openslides.motion.views', name='motion_poll_create', ), - url(r'^(?P\d+)/poll/(?P\d+)/edit$', + url(r'^(?P\d+)/poll/(?P\d+)/edit/$', 'poll_edit', name='motion_poll_edit', ), - ## url(r'^poll/(?P\d+)/del/$', - ## 'delete_poll', - ## name='motion_poll_delete', - ## ), + url(r'^(?P\d+)/poll/(?P\d+)/del/$', + 'poll_delete', + name='motion_poll_delete', + ), ) diff --git a/openslides/motion/views.py b/openslides/motion/views.py index c0cada64d..b08f6d29f 100644 --- a/openslides/motion/views.py +++ b/openslides/motion/views.py @@ -201,10 +201,8 @@ class PollCreateView(SingleObjectMixin, RedirectView): poll_create = PollCreateView.as_view() -class PollUpdateView(PollFormView): +class PollMixin(object): permission_required = 'motion.can_manage_motion' - poll_class = MotionPoll - template_name = 'motion/poll_form.html' success_url_name = 'motion_detail' def get_object(self): @@ -212,18 +210,29 @@ class PollUpdateView(PollFormView): motion=self.kwargs['pk'], poll_number=self.kwargs['poll_number']).get() + def get_url_name_args(self): + return [self.object.motion.pk] + + +class PollUpdateView(PollMixin, PollFormView): + poll_class = MotionPoll + template_name = 'motion/poll_form.html' + def get_context_data(self, **kwargs): context = super(PollUpdateView, self).get_context_data(**kwargs) context.update({ 'motion': self.poll.motion}) return context - def get_url_name_args(self): - return [self.poll.motion.pk] - poll_edit = PollUpdateView.as_view() +class PollDeleteView(PollMixin, DeleteView): + model = MotionPoll + +poll_delete = PollDeleteView.as_view() + + class Config(FormView): permission_required = 'config.can_manage_config' form_class = ConfigForm