From 5f6c96b3e888d7d1accf6287dcf1497a9dc59389 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Fri, 3 Feb 2012 23:12:28 +0100 Subject: [PATCH] assignment and application can be beamt without a item-element --- openslides/agenda/admin.py | 3 +- openslides/agenda/api.py | 22 +----- openslides/agenda/forms.py | 32 +------- openslides/agenda/models.py | 65 ++++++---------- .../agenda/templates/agenda/base_agenda.html | 2 +- .../templates/beamer/AgendaSummary.html} | 0 .../templates/beamer/AgendaText.html} | 0 openslides/agenda/urls.py | 7 +- openslides/agenda/views.py | 43 ++++------- openslides/application/models.py | 34 ++++++--- .../templates/application/view.html | 17 +---- .../templates/beamer/Application.html} | 18 ++--- openslides/application/views.py | 4 +- openslides/assignment/models.py | 18 ++++- .../assignment/templates/assignment/view.html | 13 +--- .../templates/beamer/Assignment.html} | 22 +++--- openslides/assignment/views.py | 4 +- openslides/beamer/api.py | 32 ++++++++ openslides/beamer/models.py | 39 +++++++++- .../beamer/templates/beamer/ItemPoll.html | 19 ----- openslides/beamer/views.py | 75 ++++++++++--------- 21 files changed, 223 insertions(+), 246 deletions(-) rename openslides/{beamer/templates/beamer/overview.html => agenda/templates/beamer/AgendaSummary.html} (100%) rename openslides/{beamer/templates/beamer/ItemText.html => agenda/templates/beamer/AgendaText.html} (100%) rename openslides/{beamer/templates/beamer/ItemApplication.html => application/templates/beamer/Application.html} (77%) rename openslides/{beamer/templates/beamer/ItemAssignment.html => assignment/templates/beamer/Assignment.html} (82%) delete mode 100644 openslides/beamer/templates/beamer/ItemPoll.html diff --git a/openslides/agenda/admin.py b/openslides/agenda/admin.py index 52fa6ef0b..bfab6d8f6 100644 --- a/openslides/agenda/admin.py +++ b/openslides/agenda/admin.py @@ -12,7 +12,6 @@ from django.contrib import admin -from openslides.agenda.models import Item, ItemText +from openslides.agenda.models import Item admin.site.register(Item) -admin.site.register(ItemText) diff --git a/openslides/agenda/api.py b/openslides/agenda/api.py index 3c0b86ba0..d07c306af 100644 --- a/openslides/agenda/api.py +++ b/openslides/agenda/api.py @@ -15,23 +15,7 @@ from django.contrib import messages from django.core.context_processors import csrf from openslides.system.api import config_get - - -def get_active_item(only_id=False): - """ - Returns the active Item. If no item is active, or it can not find an Item, - it raise Item.DoesNotExist - - if only_id is True, returns only the id of this item. Returns None if not Item - is active. Does not Raise Item.DoesNotExist - """ - from agenda.models import Item - id = config_get("presentation", None) - if only_id: - if id is None: - return None - return int(id) - return Item.objects.get(pk=id) +from beamer.api import get_active_element def is_summary(): @@ -40,7 +24,7 @@ def is_summary(): """ from agenda.models import Item try: - get_active_item() + get_active_element() except Item.DoesNotExist: return True if config_get('summary', False): @@ -70,4 +54,4 @@ def del_confirm_form_for_items(request, object, name=None): if object.children: gen_confirm_form_for_items(request, _('Do you really want to delete %s?') % name, object.get_absolute_url('delete'), False) else: - gen_confirm_form_for_items(request, _('Do you really want to delete %s?') % name, object.get_absolute_url('delete'), True) \ No newline at end of file + gen_confirm_form_for_items(request, _('Do you really want to delete %s?') % name, object.get_absolute_url('delete'), True) diff --git a/openslides/agenda/forms.py b/openslides/agenda/forms.py index 69f761e75..fdd5b9c2d 100644 --- a/openslides/agenda/forms.py +++ b/openslides/agenda/forms.py @@ -13,8 +13,7 @@ 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, \ - ItemAssignment +from openslides.agenda.models import Item, ItemText class ItemFormText(ModelForm): error_css_class = 'error' @@ -26,28 +25,6 @@ class ItemFormText(ModelForm): exclude = ('closed', 'weight') -class ItemFormApplication(ModelForm): - error_css_class = 'error' - required_css_class = 'required' - items = Item.objects.all().filter(parent=None).order_by('weight') - parent = ModelChoiceField(queryset=items, label=_("Parent item"), required=False) - - class Meta: - model = ItemApplication - exclude = ('closed', 'weight') - - -class ItemFormAssignment(ModelForm): - error_css_class = 'error' - required_css_class = 'required' - items = Item.objects.all().filter(parent=None).order_by('weight') - parent = ModelChoiceField(queryset=items, label=_("Parent item"), required=False) - - class Meta: - model = ItemAssignment - exclude = ('closed', 'weight') - - def genweightchoices(): l = [] for i in range(-50, 51): @@ -61,10 +38,3 @@ class ElementOrderForm(Form): label="") self = IntegerField(widget=HiddenInput(attrs={'class': 'menu-mlid'})) parent = IntegerField(widget=HiddenInput(attrs={'class': 'menu-plid'})) - - -MODELFORM = { - 'ItemText': ItemFormText, - 'ItemApplication': ItemFormApplication, - 'ItemAssignment': ItemFormAssignment, -} diff --git a/openslides/agenda/models.py b/openslides/agenda/models.py index 40bebf658..f0228ef53 100644 --- a/openslides/agenda/models.py +++ b/openslides/agenda/models.py @@ -18,40 +18,45 @@ except ImportError: from django.db import models from django.utils.translation import ugettext as _ -from model_utils.models import InheritanceCastModel - -from openslides.agenda.api import get_active_item -from openslides.system.api import config_set -from openslides.application.models import Application -from openslides.poll.models import Poll -from openslides.assignment.models import Assignment +from beamer.models import Element +from beamer.api import element_register +from system.api import config_set +from application.models import Application +from poll.models import Poll +from assignment.models import Assignment -class Item(InheritanceCastModel): +class Item(models.Model, Element): """ - The BasisItem. - Has all the attributes all Items need. + An Agenda Item """ title = models.CharField(max_length=100, verbose_name=_("Title")) + text = models.TextField(null=True, blank=True, verbose_name=_("Text")) + transcript = models.TextField(null=True, blank=True, verbose_name=_("Transcript")) closed = models.BooleanField(default=False, verbose_name=_("Closed")) weight = models.IntegerField(default=0, verbose_name=_("Weight")) parent = models.ForeignKey('self', blank=True, null=True) hidden = models.BooleanField(default=False, verbose_name=_("Hidden (visible for agenda manager only)")) + prefix = 'item' - @property - def active(self): + + def beamer(self): """ - Return True, if the the item is the active one. + Return a map with all Data for the Beamer """ - return True if get_active_item(only_id=True) == self.id else False + return { + 'item': self, + 'title': self.title, + 'template': 'beamer/AgendaText.html', + } @property def active_parent(self): """ Return True if the item has a activ parent """ - if get_active_item(only_id=True) in \ + if get_active_element(only_id=True) in \ [parent.id for parent in self.parents]: return True return False @@ -60,7 +65,7 @@ class Item(InheritanceCastModel): """ Appoint this item as the active one. """ - config_set("presentation", self.id) + Element.set_active(self) if summary: config_set("summary", True) else: @@ -182,32 +187,8 @@ class Item(InheritanceCastModel): ) -class ItemText(Item): - """ - An Item with a TextField. - """ - text = models.TextField(null=True, blank=True, verbose_name=_("Text")) - - class Meta: - pass +ItemText = Item # ItemText is Depricated -class ItemApplication(Item): - """ - An Item which is connected to an application. - """ - application = models.ForeignKey(Application, verbose_name=_("Application")) - -class ItemAssignment(Item): - """ - An Item which is connected to an assignment. - """ - assignment = models.ForeignKey(Assignment, verbose_name=_("Election")) - - -class ItemPoll(Item): - """ - An Item which is connected to a poll - """ - poll = models.ForeignKey(Poll, verbose_name=_("Poll")) +element_register(Item.prefix, Item) diff --git a/openslides/agenda/templates/agenda/base_agenda.html b/openslides/agenda/templates/agenda/base_agenda.html index 8b4f73db0..331f98d6f 100644 --- a/openslides/agenda/templates/agenda/base_agenda.html +++ b/openslides/agenda/templates/agenda/base_agenda.html @@ -8,7 +8,7 @@