Added a poll delete view to the new motion app

This commit is contained in:
Oskar Hahn 2013-02-01 13:24:44 +01:00
parent b6256b73e0
commit 3f02a28002
4 changed files with 31 additions and 15 deletions

View File

@ -336,9 +336,16 @@ class MotionPoll(CountInvalid, CountVotesCast, BasePoll):
class Meta: class Meta:
unique_together = ("motion", "poll_number") unique_together = ("motion", "poll_number")
def __unicode__(self):
return _('Ballot %d') % self.poll_number
def get_absolute_url(self, link='edit'): def get_absolute_url(self, link='edit'):
if link == 'edit':
return reverse('motion_poll_edit', args=[str(self.motion.pk), return reverse('motion_poll_edit', args=[str(self.motion.pk),
str(self.poll_number)]) 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): def get_motion(self):
return self.motion return self.motion

View File

@ -43,10 +43,10 @@
<li> <li>
{% if perms.motion.can_manage_motion %} {% if perms.motion.can_manage_motion %}
<strong>{{ forloop.counter }}. {% trans "Vote" %} </strong> <strong>{{ forloop.counter }}. {% trans "Vote" %} </strong>
<a class="icon edit" href="{% model_url poll %}" title="{% trans 'Edit Vote' %}"> <a class="icon edit" href="{% model_url poll 'edit' %}" title="{% trans 'Edit Vote' %}">
<span></span> <span></span>
</a> </a>
<a class="icon delete" href="{% model_url poll %}" title="{% trans 'Delete Vote' %}"> <a class="icon delete" href="{% model_url poll 'delete' %}" title="{% trans 'Delete Vote' %}">
<span></span> <span></span>
</a> </a>
{% elif poll.has_votes %} {% elif poll.has_votes %}

View File

@ -53,13 +53,13 @@ urlpatterns = patterns('openslides.motion.views',
name='motion_poll_create', name='motion_poll_create',
), ),
url(r'^(?P<pk>\d+)/poll/(?P<poll_number>\d+)/edit$', url(r'^(?P<pk>\d+)/poll/(?P<poll_number>\d+)/edit/$',
'poll_edit', 'poll_edit',
name='motion_poll_edit', name='motion_poll_edit',
), ),
## url(r'^poll/(?P<poll_id>\d+)/del/$', url(r'^(?P<pk>\d+)/poll/(?P<poll_number>\d+)/del/$',
## 'delete_poll', 'poll_delete',
## name='motion_poll_delete', name='motion_poll_delete',
## ), ),
) )

View File

@ -201,10 +201,8 @@ class PollCreateView(SingleObjectMixin, RedirectView):
poll_create = PollCreateView.as_view() poll_create = PollCreateView.as_view()
class PollUpdateView(PollFormView): class PollMixin(object):
permission_required = 'motion.can_manage_motion' permission_required = 'motion.can_manage_motion'
poll_class = MotionPoll
template_name = 'motion/poll_form.html'
success_url_name = 'motion_detail' success_url_name = 'motion_detail'
def get_object(self): def get_object(self):
@ -212,18 +210,29 @@ class PollUpdateView(PollFormView):
motion=self.kwargs['pk'], motion=self.kwargs['pk'],
poll_number=self.kwargs['poll_number']).get() 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): def get_context_data(self, **kwargs):
context = super(PollUpdateView, self).get_context_data(**kwargs) context = super(PollUpdateView, self).get_context_data(**kwargs)
context.update({ context.update({
'motion': self.poll.motion}) 'motion': self.poll.motion})
return context return context
def get_url_name_args(self):
return [self.poll.motion.pk]
poll_edit = PollUpdateView.as_view() poll_edit = PollUpdateView.as_view()
class PollDeleteView(PollMixin, DeleteView):
model = MotionPoll
poll_delete = PollDeleteView.as_view()
class Config(FormView): class Config(FormView):
permission_required = 'config.can_manage_config' permission_required = 'config.can_manage_config'
form_class = ConfigForm form_class = ConfigForm