From 4e16c6639ba6524e2886f8f49a25712162497995 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Mon, 20 Feb 2012 19:39:26 +0100 Subject: [PATCH] some minor bug fixes --- openslides/agenda/urls.py | 10 +++++----- openslides/agenda/views.py | 32 +++++++++++++------------------- openslides/system/forms.py | 2 ++ 3 files changed, 20 insertions(+), 24 deletions(-) diff --git a/openslides/agenda/urls.py b/openslides/agenda/urls.py index 17a1ed365..1b9bf4fe9 100644 --- a/openslides/agenda/urls.py +++ b/openslides/agenda/urls.py @@ -19,30 +19,30 @@ urlpatterns = patterns('agenda.views', name='item_overview', ), - url(r'^(?P\d+)/$', + url(r'^(?P\d+)/$', View.as_view(), name='item_view', ), - url(r'^(?P\d+)/activate/$', + url(r'^(?P\d+)/activate/$', SetActive.as_view(), {'summary': False}, name='item_activate', ), - url(r'^(?P\d+)/activate/summary/$', + url(r'^(?P\d+)/activate/summary/$', SetActive.as_view(), {'summary': True}, name='item_activate_summary', ), - url(r'^(?P\d+)/close/$', + url(r'^(?P\d+)/close/$', SetClosed.as_view(), {'closed': True}, name='item_close', ), - url(r'^(?P\d+)/open/$', + url(r'^(?P\d+)/open/$', SetClosed.as_view(), {'closed': False}, name='item_open', diff --git a/openslides/agenda/views.py b/openslides/agenda/views.py index 94c3b431a..68f37cac2 100644 --- a/openslides/agenda/views.py +++ b/openslides/agenda/views.py @@ -13,6 +13,7 @@ from django.core.urlresolvers import reverse from django.contrib import messages from django.utils.translation import ugettext as _ from django.core.context_processors import csrf +from django.views.generic.detail import SingleObjectMixin from utils.pdf import print_agenda from utils.views import TemplateView, RedirectView, UpdateView, CreateView, DeleteView @@ -70,53 +71,51 @@ class Overview(TemplateView): return self.render_to_response(context) -class SetActive(RedirectView): +class SetActive(RedirectView, SingleObjectMixin): """ Set an Item as the active one. """ url = 'item_overview' allow_ajax = True permission_required = 'agenda.can_manage_agenda' + model = Item def get_ajax_context(self, **kwargs): context = super(SetActive, self).get_ajax_context(**kwargs) context.update({ - 'active': kwargs['item_id'], + 'active': kwargs['pk'], 'summary': is_summary(), }) return context def pre_redirect(self, request, *args, **kwargs): - item_id = kwargs['item_id'] summary = kwargs['summary'] - if item_id == "0": + if kwargs['pk'] == "0": set_active_slide("agenda_show") else: - try: - item = Item.objects.get(pk=item_id) - item.set_active(summary) - except Item.DoesNotExist: - messages.error(request, _('Item ID %d does not exist.') % int(item_id)) + self.object = self.get_object() + self.object.set_active(summary) config["bigger"] = 100 config["up"] = 0 return super(SetActive, self).pre_redirect(request, *args, **kwargs) -class SetClosed(RedirectView): +class SetClosed(RedirectView, SingleObjectMixin): """ Close or open an Item. """ permission_required = 'agenda.can_manage_agenda' allow_ajax = True url = 'item_overview' + model = Item def get_ajax_context(self, **kwargs): context = super(SetClosed, self).get_ajax_context(**kwargs) closed = kwargs['closed'] if closed: - link = reverse('item_open', args=[self.item.id]) + link = reverse('item_open', args=[self.object.id]) else: - link = reverse('item_close', args=[self.item.id]) + link = reverse('item_close', args=[self.object.id]) context.update({ 'closed': kwargs['closed'], 'link': link, @@ -124,14 +123,9 @@ class SetClosed(RedirectView): return context def pre_redirect(self, request, *args, **kwargs): - item_id = kwargs['item_id'] + self.object = self.get_object() closed = kwargs['closed'] - try: - item = Item.objects.get(pk=item_id) - item.set_closed(closed) - except Item.DoesNotExist: - messages.error(request, _('Item ID %d does not exist.') % int(item_id)) - self.item = item + self.object.set_closed(closed) return super(SetClosed, self).pre_redirect(request, *args, **kwargs) diff --git a/openslides/system/forms.py b/openslides/system/forms.py index 6361ef389..fdb264193 100644 --- a/openslides/system/forms.py +++ b/openslides/system/forms.py @@ -34,6 +34,7 @@ class EventConfigForm(Form, CssClassMixin): class AgendaConfigForm(Form, CssClassMixin): agenda_countdown_time = IntegerField(widget=TextInput(attrs={'class':'small-input'}),label=_("Countdown (in seconds)"),initial=60, min_value=0) + class ApplicationConfigForm(Form, CssClassMixin): application_min_supporters = IntegerField(widget=TextInput(attrs={'class':'small-input'}),label=_("Number of (minimum) required supporters for a application"),initial=4, min_value=0, max_value=8) application_preamble = CharField(widget=TextInput(), required=False, label=_("Application preamble")) @@ -42,6 +43,7 @@ class ApplicationConfigForm(Form, CssClassMixin): application_pdf_title = CharField(widget=TextInput(), required=False, label=_("Title for PDF document (all applications)")) application_pdf_preamble = CharField(widget=Textarea(), required=False, label=_("Preamble text for PDF document (all applications)")) + class AssignmentConfigForm(Form, CssClassMixin): assignment_publish_winner_results_only = BooleanField(required=False, label=_("Only publish voting results for selected winners (Projector view only)")) assignment_pdf_ballot_papers_selection = ChoiceField(widget=Select(), required=False, label=_("Number of ballot papers (selection)"), choices=[("1", _("Number of all delegates")),("2", _("Number of all participants")),("0", _("Use the following custum number"))])