Added motion config tab

This commit is contained in:
Oskar Hahn 2013-01-26 16:33:55 +01:00
parent ecb6419f8c
commit d3b340769b
6 changed files with 90 additions and 10 deletions

View File

@ -0,0 +1 @@
import openslides.motion.signals

View File

@ -17,7 +17,7 @@ from django.db import models
from django.db.models import Max
from django.dispatch import receiver
from django.utils.translation import pgettext
from django.utils.translation import ugettext_lazy as _, ugettext_noop, ugettext
from django.utils.translation import ugettext_lazy, ugettext_noop, ugettext as _
from openslides.utils.utils import _propper_unicode
from openslides.utils.person import PersonField
@ -242,13 +242,13 @@ class Motion(SlideMixin, models.Model):
class MotionVersion(models.Model):
title = models.CharField(max_length=255, verbose_name=_("Title"))
title = models.CharField(max_length=255, verbose_name=ugettext_lazy("Title"))
text = models.TextField(verbose_name=_("Text"))
reason = models.TextField(null=True, blank=True, verbose_name=_("Reason"))
reason = models.TextField(null=True, blank=True, verbose_name=ugettext_lazy("Reason"))
rejected = models.BooleanField(default=False)
creation_time = models.DateTimeField(auto_now=True)
motion = models.ForeignKey(Motion, related_name='versions')
identifier = models.CharField(max_length=255, verbose_name=_("Version identifier"))
identifier = models.CharField(max_length=255, verbose_name=ugettext_lazy("Version identifier"))
note = models.TextField(null=True, blank=True)
def __unicode__(self):
@ -268,8 +268,8 @@ class MotionVersion(models.Model):
class Category(models.Model):
name = models.CharField(max_length=255, verbose_name=_("Category name"))
prefix = models.CharField(max_length=32, verbose_name=_("Category prefix"))
name = models.CharField(max_length=255, verbose_name=ugettext_lazy("Category name"))
prefix = models.CharField(max_length=32, verbose_name=ugettext_lazy("Category prefix"))
def __unicode__(self):
return self.name

View File

@ -0,0 +1,28 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
openslides.motion.signales
~~~~~~~~~~~~~~~~~~~~~~~~~~
Signals for the motion app.
:copyright: 2011, 2012 by OpenSlides team, see AUTHORS.
:license: GNU GPL, see LICENSE for more details.
"""
from django.dispatch import receiver
from django.utils.translation import ugettext as _
from openslides.config.signals import default_config_value
@receiver(default_config_value, dispatch_uid="motion_default_config")
def default_config(sender, key, **kwargs):
return {
'motion_min_supporters': 0,
'motion_preamble': _('The assembly may decide,'),
'motion_pdf_ballot_papers_selection': 'CUSTOM_NUMBER',
'motion_pdf_ballot_papers_number': '8',
'motion_pdf_title': _('Motions'),
'motion_pdf_preamble': '',
'motion_allow_trivial_change': False,
}.get(key)

View File

@ -0,0 +1,22 @@
{% extends "config/base_config.html" %}
{% load i18n %}
{% block title %}{{ block.super }} {% trans "Motion settings" %}{% endblock %}
{% block content %}
<h1>{% trans "Motion settings" %}</h1>
<form action="" method="post">{% csrf_token %}
{{ form.as_p }}
<p>
<button class="button" type="submit">
<span class="icon ok">{% trans 'Save' %}</span>
</button>
<a href="{% url 'config_motion' %}">
<button class="button" type="button" onclick="window.location='{% url 'config_motion' %}'">
<span class="icon cancel">{% trans 'Cancel' %}</span>
</button>
</a>
</p>
</form>
{% endblock %}

View File

@ -22,7 +22,7 @@ from django.http import Http404
from openslides.utils.pdf import stylesheet
from openslides.utils.views import (
TemplateView, RedirectView, UpdateView, CreateView, DeleteView, PDFView,
DetailView, ListView)
DetailView, ListView, FormView)
from openslides.utils.template import Tab
from openslides.utils.utils import html_strong
from openslides.projector.api import get_active_slide
@ -30,7 +30,7 @@ from openslides.projector.projector import Widget, SLIDE
from openslides.config.models import config
from .models import Motion, MotionSubmitter
from .forms import (BaseMotionForm, MotionSubmitterMixin, MotionSupporterMixin,
MotionTrivialChangesMixin)
MotionTrivialChangesMixin, ConfigForm)
class MotionListView(ListView):
"""
@ -111,6 +111,35 @@ class MotionUpdateView(MotionMixin, UpdateView):
motion_edit = MotionUpdateView.as_view()
class Config(FormView):
permission_required = 'config.can_manage_config'
form_class = ConfigForm
template_name = 'motion/config.html'
success_url_name = 'config_motion'
def get_initial(self):
return {
'motion_min_supporters': config['motion_min_supporters'],
'motion_preamble': config['motion_preamble'],
'motion_pdf_ballot_papers_selection': config['motion_pdf_ballot_papers_selection'],
'motion_pdf_ballot_papers_number': config['motion_pdf_ballot_papers_number'],
'motion_pdf_title': config['motion_pdf_title'],
'motion_pdf_preamble': config['motion_pdf_preamble'],
'motion_allow_trivial_change': config['motion_allow_trivial_change'],
}
def form_valid(self, form):
config['motion_min_supporters'] = form.cleaned_data['motion_min_supporters']
config['motion_preamble'] = form.cleaned_data['motion_preamble']
config['motion_pdf_ballot_papers_selection'] = form.cleaned_data['motion_pdf_ballot_papers_selection']
config['motion_pdf_ballot_papers_number'] = form.cleaned_data['motion_pdf_ballot_papers_number']
config['motion_pdf_title'] = form.cleaned_data['motion_pdf_title']
config['motion_pdf_preamble'] = form.cleaned_data['motion_pdf_preamble']
config['motion_allow_trivial_change'] = form.cleaned_data['motion_allow_trivial_change']
messages.success(self.request, _('Motion settings successfully saved.'))
return super(Config, self).form_valid(form)
def register_tab(request):
"""
Register the projector tab.

View File

@ -127,11 +127,11 @@ class UrlMixin(object):
"No URL to redirect to. Provide an apply_url_name.")
def get_success_url(self):
messages.success(self.request, self.get_success_message())
if 'apply' in self.request.POST:
return self.get_apply_url()
if self.success_url_name:
return reverse(self.success_url)
return reverse(self.success_url_name)
elif self.success_url:
return self.success_url
else: