2011-07-31 10:46:29 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
"""
|
|
|
|
openslides.agenda.forms
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
Forms for the agenda app.
|
|
|
|
|
|
|
|
:copyright: 2011 by the OpenSlides team, see AUTHORS.
|
|
|
|
:license: GNU GPL, see LICENSE for more details.
|
|
|
|
"""
|
|
|
|
|
|
|
|
from django.forms import Form, ModelForm, IntegerField, ChoiceField, \
|
|
|
|
ModelChoiceField, HiddenInput, Select
|
|
|
|
from django.utils.translation import ugettext as _
|
|
|
|
from openslides.agenda.models import Item, ItemText, ItemApplication, ItemPoll, \
|
|
|
|
ItemAssignment
|
|
|
|
|
|
|
|
class ItemFormText(ModelForm):
|
|
|
|
error_css_class = 'error'
|
|
|
|
required_css_class = 'required'
|
|
|
|
items = Item.objects.all().filter(parent=None).order_by('weight')
|
2011-08-02 21:40:08 +02:00
|
|
|
parent = ModelChoiceField(queryset=items, label=_("Parent item"), required=False)
|
2011-07-31 10:46:29 +02:00
|
|
|
class Meta:
|
|
|
|
model = ItemText
|
2011-09-03 14:30:56 +02:00
|
|
|
exclude = ('closed', 'weight')
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ItemFormApplication(ModelForm):
|
|
|
|
error_css_class = 'error'
|
|
|
|
required_css_class = 'required'
|
|
|
|
items = Item.objects.all().filter(parent=None).order_by('weight')
|
2011-08-02 21:40:08 +02:00
|
|
|
parent = ModelChoiceField(queryset=items, label=_("Parent item"), required=False)
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = ItemApplication
|
2011-09-03 14:30:56 +02:00
|
|
|
exclude = ('closed', 'weight')
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ItemFormPoll(ModelForm):
|
|
|
|
error_css_class = 'error'
|
|
|
|
required_css_class = 'required'
|
|
|
|
items = Item.objects.all().filter(parent=None).order_by('weight')
|
2011-08-02 21:40:08 +02:00
|
|
|
parent = ModelChoiceField(queryset=items, label=_("Parent item"), required=False)
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = ItemPoll
|
2011-09-03 14:30:56 +02:00
|
|
|
exclude = ('closed', 'weight')
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
class ItemFormAssignment(ModelForm):
|
|
|
|
error_css_class = 'error'
|
|
|
|
required_css_class = 'required'
|
|
|
|
items = Item.objects.all().filter(parent=None).order_by('weight')
|
2011-08-02 21:40:08 +02:00
|
|
|
parent = ModelChoiceField(queryset=items, label=_("Parent item"), required=False)
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
|
|
class Meta:
|
|
|
|
model = ItemAssignment
|
2011-09-03 14:30:56 +02:00
|
|
|
exclude = ('closed', 'weight')
|
2011-07-31 10:46:29 +02:00
|
|
|
|
|
|
|
|
|
|
|
def genweightchoices():
|
|
|
|
l = []
|
|
|
|
for i in range(-50, 51):
|
|
|
|
l.append(('%d' % i, i))
|
|
|
|
return l
|
|
|
|
|
|
|
|
|
|
|
|
class ElementOrderForm(Form):
|
|
|
|
weight = ChoiceField(choices=genweightchoices(), \
|
|
|
|
widget=Select(attrs={'class': 'menu-weight'}),
|
|
|
|
label="")
|
|
|
|
self = IntegerField(widget=HiddenInput(attrs={'class': 'menu-mlid'}))
|
|
|
|
parent = IntegerField(widget=HiddenInput(attrs={'class': 'menu-plid'}))
|
|
|
|
|
|
|
|
|
|
|
|
MODELFORM = {
|
|
|
|
'ItemText': ItemFormText,
|
|
|
|
'ItemApplication': ItemFormApplication,
|
|
|
|
'ItemPoll': ItemFormPoll,
|
|
|
|
'ItemAssignment': ItemFormAssignment,
|
|
|
|
}
|