some small code design changes

This commit is contained in:
Oskar Hahn 2013-02-18 18:56:37 +01:00
parent a591e4f547
commit 4f3f917812
5 changed files with 30 additions and 29 deletions

View File

@ -17,7 +17,7 @@ from django.utils.translation import ugettext_lazy as _
from mptt.forms import TreeNodeChoiceField
from openslides.utils.forms import CssClassMixin
from openslides.agenda.models import Item
from .models import Item
class ItemForm(forms.ModelForm, CssClassMixin):
@ -32,8 +32,7 @@ class ItemForm(forms.ModelForm, CssClassMixin):
error_message=_("Invalid format. Hours from 0 to 99 and minutes from 00 to 59"),
max_length=5,
required=False,
label=_("Duration (hh:mm)")
)
label=_("Duration (hh:mm)"))
class Meta:
model = Item
@ -53,19 +52,15 @@ class ItemOrderForm(forms.Form, CssClassMixin):
"""
weight = forms.ChoiceField(
choices=gen_weight_choices(),
widget=forms.Select(attrs={'class': 'menu-weight'}),
)
widget=forms.Select(attrs={'class': 'menu-weight'}))
self = forms.IntegerField(
widget=forms.HiddenInput(attrs={'class': 'menu-mlid'}),
)
widget=forms.HiddenInput(attrs={'class': 'menu-mlid'}))
parent = forms.IntegerField(
widget=forms.HiddenInput(attrs={'class': 'menu-plid'}),
)
widget=forms.HiddenInput(attrs={'class': 'menu-plid'}))
class ConfigForm(CssClassMixin, forms.Form):
agenda_start_event_date_time = forms.CharField(
widget=forms.DateTimeInput(format='%d.%m.%Y %H:%M'),
required=False,
label=_("Begin of event")
)
label=_("Begin of event"))

View File

@ -20,7 +20,7 @@ from openslides.config.models import config
from openslides.projector.projector import SlideMixin
from openslides.projector.api import (
register_slidemodel, get_slide_from_sid, register_slidefunc)
from openslides.agenda.slides import agenda_show
from .slides import agenda_show
class Item(MPTTModel, SlideMixin):
@ -36,8 +36,7 @@ class Item(MPTTModel, SlideMixin):
ITEM_TYPE = (
(AGENDA_ITEM, _('Agenda item')),
(ORGANIZATIONAL_ITEM, _('Organizational item')),
)
(ORGANIZATIONAL_ITEM, _('Organizational item')))
title = models.CharField(null=True, max_length=255, verbose_name=_("Title"))
text = models.TextField(null=True, blank=True, verbose_name=_("Text"))

View File

@ -19,35 +19,43 @@ urlpatterns = patterns(
'',
url(r'^$',
Overview.as_view(),
name='item_overview', ),
name='item_overview',
),
url(r'^(?P<pk>\d+)/$',
View.as_view(),
name='item_view', ),
name='item_view',
),
url(r'^(?P<pk>\d+)/close/$',
SetClosed.as_view(),
{'closed': True},
name='item_close', ),
name='item_close',
),
url(r'^(?P<pk>\d+)/open/$',
SetClosed.as_view(),
{'closed': False},
name='item_open', ),
name='item_open',
),
url(r'^(?P<pk>\d+)/edit/$',
ItemUpdate.as_view(),
name='item_edit', ),
name='item_edit',
),
url(r'^new/$',
ItemCreate.as_view(),
name='item_new', ),
name='item_new',
),
url(r'^(?P<pk>\d+)/del/$',
ItemDelete.as_view(),
name='item_delete', ),
name='item_delete',
),
url(r'^print/$',
AgendaPDF.as_view(),
name='print_agenda', ),
name='print_agenda',
),
)

View File

@ -11,6 +11,7 @@
"""
from reportlab.platypus import Paragraph
from datetime import datetime, timedelta
from django.core.urlresolvers import reverse
from django.contrib import messages
@ -31,7 +32,6 @@ from openslides.projector.api import get_active_slide
from openslides.projector.projector import Widget, SLIDE
from .models import Item
from .forms import ItemOrderForm, ItemForm
from datetime import datetime, timedelta
class Overview(TemplateView):
@ -71,15 +71,16 @@ class Overview(TemplateView):
else:
end = start + duration
duration = u'%d:%02d' % ((duration.days * 24 + duration.seconds / 3600), (duration.seconds / 60 % 60))
duration = u'%d:%02d' % (
(duration.days * 24 + duration.seconds / 3600.0),
(duration.seconds / 60.0 % 60))
context.update({
'items': items,
'active_sid': get_active_slide(only_sid=True),
'duration': duration,
'start': start,
'end': end,
})
'end': end})
return context
@transaction.commit_manually
@ -140,8 +141,7 @@ class SetClosed(RedirectView, SingleObjectMixin):
link = reverse('item_close', args=[self.object.id])
context.update({
'closed': kwargs['closed'],
'link': link,
})
'link': link})
return context
def pre_redirect(self, request, *args, **kwargs):

View File

@ -182,7 +182,6 @@ class ViewTest(TestCase):
data = {'title': 'newitem1', 'text': 'item1-text', 'weight': '0',
'type': 1}
response = c.post('/agenda/%d/edit/' % self.item1.id, data)
print response
self.assertEqual(response.status_code, 302)
self.refreshItems()
self.assertEqual(self.item1.title, 'newitem1')