Item type changed from CharField to IntegerField. Constant type names added.

This commit is contained in:
Stefan Frauenknecht 2013-02-01 15:13:40 +01:00
parent 9f3dae8059
commit 7f03e02e9a
5 changed files with 13 additions and 10 deletions

View File

@ -31,10 +31,13 @@ class Item(MPTTModel, SlideMixin):
"""
prefix = 'item'
AGENDA_ITEM = 1
ORGANIZATIONAL_ITEM = 2
ITEM_TYPE = (
('agd', _('Agenda item')),
('org', _('Organizational item')),
)
(AGENDA_ITEM, _('Agenda 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"))
@ -43,8 +46,8 @@ class Item(MPTTModel, SlideMixin):
weight = models.IntegerField(default=0, verbose_name=_("Weight"))
parent = TreeForeignKey('self', null=True, blank=True,
related_name='children')
type = models.CharField(max_length=3, choices=ITEM_TYPE,
default='agd', verbose_name=_("Type"))
type = models.IntegerField(max_length=1, choices=ITEM_TYPE,
default=AGENDA_ITEM, verbose_name=_("Type"))
duration = models.TimeField(blank=True, null=True, verbose_name=_("Duration (hh:mm)"));

View File

@ -16,7 +16,7 @@ from django.utils.translation import ugettext as _
def agenda_show():
from openslides.agenda.models import Item
data = {}
items = Item.objects.filter(parent=None, type__exact='agd')
items = Item.objects.filter(parent=None, type__exact=Item.AGENDA_ITEM)
data['title'] = _("Agenda")
data['items'] = items
data['template'] = 'projector/AgendaSummary.html'

View File

@ -20,7 +20,7 @@
{% if perms.agenda.can_manage_agenda %}
<div class="dragcell"></div>
{% endif %}
<a href="{% model_url item 'view' %}">{% if item.type == "org" %}<i>[{% endif %}{{ item }}{% if item.type == "org" %}]</i>{% endif %}</a>
<a href="{% model_url item 'view' %}">{% if item.type == item.ORGANIZATIONAL_ITEM %}<i>[{% endif %}{{ item }}{% if item.type == item.ORGANIZATIONAL_ITEM %}]</i>{% endif %}</a>
{{ item.get_title_supplement|safe }}
</td>
{% if perms.agenda.can_manage_agenda %}

View File

@ -39,7 +39,7 @@
{% for p in item.get_ancestors %}
<span class="indentation">&nbsp;</span>
{% endfor %}
<a href="{% model_url item 'view' %}">{% if item.type == "org" %}<i>[{% endif %}{{ item }}{% if item.type == "org" %}]</i>{% endif %}</a>
<a href="{% model_url item 'view' %}">{% if item.type == item.ORGANIZATIONAL_ITEM %}<i>[{% endif %}{{ item }}{% if item.type == item.ORGANIZATIONAL_ITEM %}]</i>{% endif %}</a>
{{ item.get_title_supplement|safe }}
</li>
{% empty %}

View File

@ -47,7 +47,7 @@ class Overview(TemplateView):
if self.request.user.has_perm('agenda.can_see_orga_items'):
items = Item.objects.all()
else:
items = Item.objects.filter(type__exact = 'agd')
items = Item.objects.filter(type__exact=Item.AGENDA_ITEM)
duration = timedelta()
@ -220,7 +220,7 @@ class AgendaPDF(PDFView):
document_title = ugettext_lazy('Agenda')
def append_to_pdf(self, story):
for item in Item.objects.filter(type__exact = 'agd'):
for item in Item.objects.filter(type__exact=Item.AGENDA_ITEM):
ancestors = item.get_ancestors()
if ancestors:
space = "&nbsp;" * 6 * ancestors.count()