cleanup the imports of the application app

This commit is contained in:
Oskar Hahn 2012-07-08 09:21:39 +02:00
parent 8feb195067
commit f074cb5bfd
4 changed files with 53 additions and 47 deletions

View File

@ -12,9 +12,9 @@
from django import forms
from django.contrib.auth.models import User
from django.utils.translation import ugettext as _, ugettext_noop
from openslides.utils.forms import CssClassMixin
from openslides.utils.translation_ext import ugettext as _
from openslides.application.models import Application
@ -39,17 +39,20 @@ class UserModelMultipleChoiceField(forms.ModelMultipleChoiceField):
class ApplicationForm(forms.Form, CssClassMixin):
title = forms.CharField(widget=forms.TextInput(), label=_("Title"))
text = forms.CharField(widget=forms.Textarea(), label=_("Text"))
reason = forms.CharField(widget=forms.Textarea(), required=False, label=_("Reason"))
reason = forms.CharField(widget=forms.Textarea(), required=False,
label=_("Reason"))
class ApplicationFormTrivialChanges(ApplicationForm):
trivial_change = forms.BooleanField(required=False, label=_("Trivial change"),
trivial_change = forms.BooleanField(required=False,
label=_("Trivial change"),
help_text=_("Trivial changes don't create a new version."))
class ApplicationManagerForm(forms.ModelForm, CssClassMixin):
submitter = UserModelChoiceField(
queryset=User.objects.all().exclude(profile=None).order_by("first_name"),
queryset=User.objects.all().exclude(profile=None).
order_by("first_name"),
label=_("Submitter"),
)
@ -60,7 +63,8 @@ class ApplicationManagerForm(forms.ModelForm, CssClassMixin):
class ApplicationManagerFormSupporter(ApplicationManagerForm):
supporter = UserModelMultipleChoiceField(
queryset=User.objects.all().exclude(profile=None).order_by("first_name"),
queryset=User.objects.all().exclude(profile=None).
order_by("first_name"),
required=False, label=_("Supporters"),
)
@ -73,7 +77,8 @@ class ApplicationImportForm(forms.Form, CssClassMixin):
import_permitted = forms.BooleanField(
required=False,
label=_("Import applications with status \"permitted\""),
help_text=_("Set the initial status for each application to \"permitted\""),
help_text=_('Set the initial status for each application to \
"permitted"'),
)
@ -120,6 +125,7 @@ class ConfigForm(forms.Form, CssClassMixin):
application_allow_trivial_change = forms.BooleanField(
label=_("Allow trivial changes"),
help_text=_('Warning: Trivial changes undermine the application permission system.'),
help_text=_('Warning: Trivial changes undermine the application \
permission system.'),
required=False,
)

View File

@ -17,18 +17,21 @@ from django.db.models import Max
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.utils.translation import pgettext
from django.utils.translation import ugettext as _, ugettext_noop
from projector.api import register_slidemodel
from projector.models import SlideMixin
from openslides.utils.utils import _propper_unicode
from participant.models import Profile
from config.models import config
from utils.utils import _propper_unicode
from utils.translation_ext import ugettext as _
from openslides.config.models import config
from poll.models import BaseOption, BasePoll, CountVotesCast, CountInvalid, Vote
from openslides.participant.models import Profile
from agenda.models import Item
from openslides.poll.models import (BaseOption, BasePoll, CountVotesCast,
CountInvalid, Vote)
from openslides.projector.api import register_slidemodel
from openslides.projector.models import SlideMixin
from openslides.agenda.models import Item
class Application(models.Model, SlideMixin):
@ -503,10 +506,10 @@ class Application(models.Model, SlideMixin):
class Meta:
permissions = (
('can_see_application', _("Can see application", fixstr=True)),
('can_create_application', _("Can create application", fixstr=True)),
('can_support_application', _("Can support application", fixstr=True)),
('can_manage_application', _("Can manage application", fixstr=True)),
('can_see_application', ugettext_noop("Can see application")),
('can_create_application', ugettext_noop("Can create application")),
('can_support_application', ugettext_noop("Can support application")),
('can_manage_application', ugettext_noop("Can manage application")),
)
@ -546,7 +549,8 @@ class ApplicationOption(BaseOption):
class ApplicationPoll(BasePoll, CountInvalid, CountVotesCast):
option_class = ApplicationOption
vote_values = [_('Yes', fixstr=True), _('No', fixstr=True), _('Abstain', fixstr=True)]
vote_values = [ugettext_noop('Yes'), ugettext_noop('No'),
ugettext_noop('Abstain')]
application = models.ForeignKey(Application)

View File

@ -12,7 +12,8 @@
from django.conf.urls.defaults import url, patterns
from application.views import ApplicationDelete, ViewPoll, ApplicationPDF, ApplicationPollPDF, CreateAgendaItem
from application.views import (ApplicationDelete, ViewPoll, ApplicationPDF,
ApplicationPollPDF, CreateAgendaItem)
urlpatterns = patterns('application.views',
url(r'^$',
@ -55,7 +56,7 @@ urlpatterns = patterns('application.views',
ApplicationDelete.as_view(),
name='application_delete',
),
url(r'^del/$',
ApplicationDelete.as_view(),
{ 'application_id' : None , 'application_ids' : None },
@ -67,7 +68,7 @@ urlpatterns = patterns('application.views',
name='application_set_number',
),
url(r'^(?P<application_id>\d+)/setstatus/' '(?P<status>[a-z]{3})/$',
url(r'^(?P<application_id>\d+)/setstatus/(?P<status>[a-z]{3})/$',
'set_status',
name='application_set_status',
),

View File

@ -9,13 +9,13 @@
:copyright: 2011, 2012 by OpenSlides team, see AUTHORS.
:license: GNU GPL, see LICENSE for more details.
"""
# for python 2.5 support
from __future__ import with_statement
import csv
import utils.csv_ext
import os
from urllib import urlencode
try:
from urlparse import parse_qs
except ImportError: # python <= 2.5
@ -23,46 +23,41 @@ except ImportError: # python <= 2.5
from reportlab.lib import colors
from reportlab.lib.units import cm
from reportlab.platypus import SimpleDocTemplate, PageBreak, Paragraph, Spacer, Table, TableStyle
from reportlab.platypus import (SimpleDocTemplate, PageBreak, Paragraph, Spacer,
Table, TableStyle)
from django.shortcuts import redirect
from django.conf import settings
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from django.contrib.auth.models import User, Group
from django.core.urlresolvers import reverse
from django.core.context_processors import csrf
from django.utils.translation import ugettext as _
from django.utils.translation import ungettext
from django.core.urlresolvers import reverse
from django.db import transaction
from django.conf import settings
from openslides.config.models import config
from django.shortcuts import redirect
from django.utils.translation import ugettext as _, ungettext
from openslides.utils import csv_ext
from openslides.utils.pdf import stylesheet
from openslides.utils.template import Tab
from openslides.utils.utils import (template, permission_required,
del_confirm_form, gen_confirm_form)
from openslides.utils.views import PDFView, RedirectView, DeleteView, FormView
from openslides.utils.utils import template, permission_required, \
render_to_forbitten, del_confirm_form, gen_confirm_form
from openslides.utils.template import Tab
from openslides.config.models import config
from openslides.projector.projector import Widget
from openslides.poll.views import PollFormView
from openslides.participant.models import Profile
from openslides.participant.api import gen_username, gen_password
from openslides.participant.models import Profile
from openslides.agenda.models import Item
from openslides.application.models import Application, AVersion, ApplicationPoll
from openslides.application.forms import (
ApplicationForm,
ApplicationFormTrivialChanges,
ApplicationManagerForm,
ApplicationManagerFormSupporter,
ApplicationImportForm,
ConfigForm,
)
from openslides.application.forms import (ApplicationForm,
ApplicationFormTrivialChanges, ApplicationManagerForm,
ApplicationManagerFormSupporter, ApplicationImportForm, ConfigForm)
@permission_required('application.can_see_application')
@ -194,8 +189,8 @@ def edit(request, application_id=None):
actions = None
formclass = ApplicationFormTrivialChanges \
if config['application_allow_trivial_change'] and application_id \
else ApplicationForm
if config['application_allow_trivial_change'] and application_id \
else ApplicationForm
managerformclass = ApplicationManagerFormSupporter \
if config['application_min_supporters'] \