Add motion to agenda

This commit is contained in:
Oskar Hahn 2013-02-02 00:51:08 +01:00
parent 910e0f17e7
commit a27bd7eade
4 changed files with 29 additions and 1 deletions

View File

@ -314,6 +314,13 @@ class Motion(SlideMixin, models.Model):
data['template'] = 'projector/Motion.html' data['template'] = 'projector/Motion.html'
return data return data
def get_agenda_title(self):
return self.last_version.title
## def get_agenda_title_supplement(self):
## number = self.number or '<i>[%s]</i>' % ugettext('no number')
## return '(%s %s)' % (ugettext('motion'), number)
class MotionVersion(models.Model): class MotionVersion(models.Model):
title = models.CharField(max_length=255, verbose_name=ugettext_lazy("Title")) title = models.CharField(max_length=255, verbose_name=ugettext_lazy("Title"))

View File

@ -77,4 +77,9 @@ urlpatterns = patterns('openslides.motion.views',
'reset_state', 'reset_state',
name='motion_reset_state', name='motion_reset_state',
), ),
url(r'^(?P<pk>\d+)/agenda/$',
'create_agenda_item',
name='motion_create_agenda',
),
) )

View File

@ -29,6 +29,7 @@ from openslides.poll.views import PollFormView
from openslides.projector.api import get_active_slide from openslides.projector.api import get_active_slide
from openslides.projector.projector import Widget, SLIDE from openslides.projector.projector import Widget, SLIDE
from openslides.config.models import config from openslides.config.models import config
from openslides.agenda.models import Item
from .models import Motion, MotionSubmitter, MotionSupporter, MotionPoll from .models import Motion, MotionSubmitter, MotionSupporter, MotionPoll
from .forms import (BaseMotionForm, MotionSubmitterMixin, MotionSupporterMixin, from .forms import (BaseMotionForm, MotionSubmitterMixin, MotionSupporterMixin,
MotionCreateNewVersionMixin, ConfigForm) MotionCreateNewVersionMixin, ConfigForm)
@ -274,6 +275,21 @@ set_state = MotionSetStateView.as_view()
reset_state = MotionSetStateView.as_view(reset=True) reset_state = MotionSetStateView.as_view(reset=True)
class CreateAgendaItemView(SingleObjectMixin, RedirectView):
permission_required = 'agenda.can_manage_agenda'
url_name = 'item_overview'
model = Motion
def get(self, request, *args, **kwargs):
self.object = self.get_object()
return super(CreateAgendaItemView, self).get(request, *args, **kwargs)
def pre_redirect(self, request, *args, **kwargs):
self.item = Item.objects.create(related_sid=self.object.sid)
create_agenda_item = CreateAgendaItemView.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

View File

@ -83,7 +83,7 @@ class ModelTest(TestCase):
self.assertEqual(self.motion.get_absolute_url('detail'), '/motion/%d/' % motion_id) self.assertEqual(self.motion.get_absolute_url('detail'), '/motion/%d/' % motion_id)
self.assertEqual(self.motion.get_absolute_url('edit'), '/motion/%d/edit/' % motion_id) self.assertEqual(self.motion.get_absolute_url('edit'), '/motion/%d/edit/' % motion_id)
#self.assertEqual(self.motion.get_absolute_url('delete'), '/motion/%d/del/' % motion_id) self.assertEqual(self.motion.get_absolute_url('delete'), '/motion/%d/del/' % motion_id)
def test_supporter(self): def test_supporter(self):
self.assertFalse(self.motion.is_supporter(self.test_user)) self.assertFalse(self.motion.is_supporter(self.test_user))