Categories for Motions

This commit is contained in:
Oskar Hahn 2013-03-11 20:17:19 +01:00
parent 73723feb74
commit 2614a1cb2f
3 changed files with 52 additions and 8 deletions

View File

@ -65,7 +65,9 @@ class Motion(SlideMixin, models.Model):
unique=True) unique=True)
"""A string as human readable identifier for the motion.""" """A string as human readable identifier for the motion."""
# category = models.ForeignKey('Category', null=True, blank=True) category = models.ForeignKey('Category', null=True, blank=True)
"""ForeignKey to one category of motions."""
# TODO: proposal # TODO: proposal
#master = models.ForeignKey('self', null=True, blank=True) #master = models.ForeignKey('self', null=True, blank=True)
@ -523,12 +525,16 @@ class MotionSupporter(models.Model):
return unicode(self.person) return unicode(self.person)
## class Category(models.Model): class Category(models.Model):
## name = models.CharField(max_length=255, verbose_name=ugettext_lazy("Category name")) name = models.CharField(max_length=255, verbose_name=ugettext_lazy("Category name"))
## prefix = models.CharField(max_length=32, verbose_name=ugettext_lazy("Category prefix")) prefix = models.CharField(max_length=32, verbose_name=ugettext_lazy("Category prefix"))
## def __unicode__(self): def __unicode__(self):
## return self.name return self.name
def get_absolute_url(self, link='update'):
if link == 'update' or link == 'edit':
return reverse('motion_category_update', args=[str(self.id)])
## class Comment(models.Model): ## class Comment(models.Model):

View File

@ -19,8 +19,9 @@ urlpatterns = patterns('openslides.motion.views',
name='motion_list', name='motion_list',
), ),
url(r'^create/$', url(r'^new/$',
'motion_create', 'motion_create',
# TODO: rename to motion_create
name='motion_new', name='motion_new',
), ),
@ -103,4 +104,19 @@ urlpatterns = patterns('openslides.motion.views',
'motion_detail_pdf', 'motion_detail_pdf',
name='motion_detail_pdf', name='motion_detail_pdf',
), ),
url(r'^category/$',
'category_list',
name='motion_category_list',
),
url(r'^category/new/$',
'category_create',
name='motion_category_create',
),
url(r'^category/(?P<pk>\d+)/edit/$',
'category_update',
name='motion_category_update',
),
) )

View File

@ -32,7 +32,8 @@ 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 openslides.agenda.models import Item
from .models import Motion, MotionSubmitter, MotionSupporter, MotionPoll, MotionVersion, State, WorkflowError from .models import (Motion, MotionSubmitter, MotionSupporter, MotionPoll,
MotionVersion, State, WorkflowError, Category)
from .forms import (BaseMotionForm, MotionSubmitterMixin, MotionSupporterMixin, from .forms import (BaseMotionForm, MotionSubmitterMixin, MotionSupporterMixin,
MotionDisableVersioningMixin, ConfigForm) MotionDisableVersioningMixin, ConfigForm)
from .pdf import motions_to_pdf, motion_to_pdf from .pdf import motions_to_pdf, motion_to_pdf
@ -473,6 +474,27 @@ motion_list_pdf = MotionPDFView.as_view(print_all_motions=True)
motion_detail_pdf = MotionPDFView.as_view(print_all_motions=False) motion_detail_pdf = MotionPDFView.as_view(print_all_motions=False)
class CategoryListView(ListView):
permission_required = 'motion.can_manage_motion'
model = Category
category_list = CategoryListView.as_view()
class CategoryCreateView(CreateView):
permission_required = 'motion.can_manage_motion'
model = Category
category_create = CategoryCreateView.as_view()
class CategoryUpdateView(UpdateView):
permission_required = 'motion.can_manage_motion'
model = Category
category_update = CategoryUpdateView.as_view()
class Config(FormView): class Config(FormView):
"""The View for the config tab.""" """The View for the config tab."""
permission_required = 'config.can_manage_config' permission_required = 'config.can_manage_config'