Reverted changset r281 from Default branch (because it's for

1.2-dev-branch only).
This commit is contained in:
Emanuel Schuetze 2012-03-28 15:17:50 +02:00
parent a06d20a8d8
commit c6a40f4dcb
21 changed files with 246 additions and 223 deletions

View File

@ -12,6 +12,7 @@
from django.contrib import admin from django.contrib import admin
from openslides.agenda.models import Item from openslides.agenda.models import Item, ItemText
admin.site.register(Item) admin.site.register(Item)
admin.site.register(ItemText)

View File

@ -15,7 +15,23 @@ from django.contrib import messages
from django.core.context_processors import csrf from django.core.context_processors import csrf
from openslides.system.api import config_get from openslides.system.api import config_get
from beamer.api import get_active_element
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)
def is_summary(): def is_summary():
@ -24,7 +40,7 @@ def is_summary():
""" """
from agenda.models import Item from agenda.models import Item
try: try:
get_active_element() get_active_item()
except Item.DoesNotExist: except Item.DoesNotExist:
return True return True
if config_get('summary', False): if config_get('summary', False):
@ -54,4 +70,4 @@ def del_confirm_form_for_items(request, object, name=None):
if object.children: if object.children:
gen_confirm_form_for_items(request, _('Do you really want to delete <b>%s</b>?') % name, object.get_absolute_url('delete'), False) gen_confirm_form_for_items(request, _('Do you really want to delete <b>%s</b>?') % name, object.get_absolute_url('delete'), False)
else: else:
gen_confirm_form_for_items(request, _('Do you really want to delete <b>%s</b>?') % name, object.get_absolute_url('delete'), True) gen_confirm_form_for_items(request, _('Do you really want to delete <b>%s</b>?') % name, object.get_absolute_url('delete'), True)

View File

@ -13,7 +13,8 @@
from django.forms import Form, ModelForm, IntegerField, ChoiceField, \ from django.forms import Form, ModelForm, IntegerField, ChoiceField, \
ModelChoiceField, HiddenInput, Select ModelChoiceField, HiddenInput, Select
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from openslides.agenda.models import Item, ItemText from openslides.agenda.models import Item, ItemText, ItemApplication, \
ItemAssignment
class ItemFormText(ModelForm): class ItemFormText(ModelForm):
error_css_class = 'error' error_css_class = 'error'
@ -25,6 +26,28 @@ class ItemFormText(ModelForm):
exclude = ('closed', 'weight') 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(): def genweightchoices():
l = [] l = []
for i in range(-50, 51): for i in range(-50, 51):
@ -38,3 +61,10 @@ class ElementOrderForm(Form):
label="") label="")
self = IntegerField(widget=HiddenInput(attrs={'class': 'menu-mlid'})) self = IntegerField(widget=HiddenInput(attrs={'class': 'menu-mlid'}))
parent = IntegerField(widget=HiddenInput(attrs={'class': 'menu-plid'})) parent = IntegerField(widget=HiddenInput(attrs={'class': 'menu-plid'}))
MODELFORM = {
'ItemText': ItemFormText,
'ItemApplication': ItemFormApplication,
'ItemAssignment': ItemFormAssignment,
}

View File

@ -18,45 +18,40 @@ except ImportError:
from django.db import models from django.db import models
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from beamer.models import Element from model_utils.models import InheritanceCastModel
from beamer.api import element_register
from system.api import config_set from openslides.agenda.api import get_active_item
from application.models import Application from openslides.system.api import config_set
from poll.models import Poll from openslides.application.models import Application
from assignment.models import Assignment from openslides.poll.models import Poll
from openslides.assignment.models import Assignment
class Item(models.Model, Element): class Item(InheritanceCastModel):
""" """
An Agenda Item The BasisItem.
Has all the attributes all Items need.
""" """
title = models.CharField(max_length=100, verbose_name=_("Title")) 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")) closed = models.BooleanField(default=False, verbose_name=_("Closed"))
weight = models.IntegerField(default=0, verbose_name=_("Weight")) weight = models.IntegerField(default=0, verbose_name=_("Weight"))
parent = models.ForeignKey('self', blank=True, null=True) parent = models.ForeignKey('self', blank=True, null=True)
hidden = models.BooleanField(default=False, hidden = models.BooleanField(default=False,
verbose_name=_("Hidden (visible for agenda manager only)")) verbose_name=_("Hidden (visible for agenda manager only)"))
prefix = 'item'
@property
def beamer(self): def active(self):
""" """
Return a map with all Data for the Beamer Return True, if the the item is the active one.
""" """
return { return True if get_active_item(only_id=True) == self.id else False
'item': self,
'title': self.title,
'template': 'beamer/AgendaText.html',
}
@property @property
def active_parent(self): def active_parent(self):
""" """
Return True if the item has a activ parent Return True if the item has a activ parent
""" """
if get_active_element(only_id=True) in \ if get_active_item(only_id=True) in \
[parent.id for parent in self.parents]: [parent.id for parent in self.parents]:
return True return True
return False return False
@ -65,7 +60,7 @@ class Item(models.Model, Element):
""" """
Appoint this item as the active one. Appoint this item as the active one.
""" """
Element.set_active(self) config_set("presentation", self.id)
if summary: if summary:
config_set("summary", True) config_set("summary", True)
else: else:
@ -187,8 +182,32 @@ class Item(models.Model, Element):
) )
ItemText = Item # ItemText is Depricated class ItemText(Item):
"""
An Item with a TextField.
"""
text = models.TextField(null=True, blank=True, verbose_name=_("Text"))
class Meta:
pass
class ItemApplication(Item):
"""
An Item which is connected to an application.
"""
application = models.ForeignKey(Application, verbose_name=_("Application"))
element_register(Item.prefix, Item)
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"))

View File

@ -8,7 +8,7 @@
<ul> <ul>
<li class="{% if request.path == url_itemoverview %}selected{% endif %}"><a href="{% url item_overview %}">{%trans "All items" %}</a></li> <li class="{% if request.path == url_itemoverview %}selected{% endif %}"><a href="{% url item_overview %}">{%trans "All items" %}</a></li>
{% if perms.agenda.can_manage_agenda %} {% if perms.agenda.can_manage_agenda %}
<li class="{% active request '/agenda/new/' %}"><a href="{% url item_new %}">{%trans "New item" %}</a></li> <li class="{% active request '/agenda/new/' %}"><a href="{% url item_new 'ItemText' %}">{%trans "New item" %}</a></li>
{% endif %} {% endif %}
{% if perms.agenda.can_see_projector %} {% if perms.agenda.can_see_projector %}
<li><a href="{% url beamer_show %}"><img src="/static/images/icons/video-projector.png"> {%trans 'Projector view' %}</a></li> <li><a href="{% url beamer_show %}"><img src="/static/images/icons/video-projector.png"> {%trans 'Projector view' %}</a></li>

View File

@ -40,9 +40,14 @@ urlpatterns = patterns('agenda.views',
url(r'^agenda/new/$', 'edit', url(r'^agenda/new/$', 'edit',
name='item_new_default'), name='item_new_default'),
url(r'^agenda/new$', 'edit', url(r'^agenda/new/(?P<form>ItemText|ItemApplication|ItemPoll|'
r'ItemAssignment)/$', 'edit',
name='item_new'), name='item_new'),
url(r'^agenda/new/(?P<form>ItemText|ItemApplication|ItemPoll|'
r'ItemAssignment)/(?P<default>\d+)/$', 'edit',
name='item_new_default'),
url(r'^agenda/(?P<item_id>\d+)/del/$', 'delete', url(r'^agenda/(?P<item_id>\d+)/del/$', 'delete',
name='item_delete'), name='item_delete'),

View File

@ -17,19 +17,18 @@ from django.core.urlresolvers import reverse
from django.contrib import messages from django.contrib import messages
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from beamer.api import get_active_element from openslides.agenda.models import Item
from agenda.models import Item from openslides.agenda.api import get_active_item, is_summary, children_list, \
from agenda.api import is_summary, children_list, \
del_confirm_form_for_items del_confirm_form_for_items
from agenda.forms import ElementOrderForm, ItemFormText from openslides.agenda.forms import ElementOrderForm, MODELFORM
from application.models import Application from openslides.application.models import Application
from assignment.models import Assignment from openslides.assignment.models import Assignment
from poll.models import Poll from openslides.poll.models import Poll
from system.api import config_set, config_get from openslides.system.api import config_set, config_get
from utils.template import render_block_to_string from openslides.utils.template import render_block_to_string
from utils.utils import template, permission_required, \ from openslides.utils.utils import template, permission_required, \
del_confirm_form, ajax_request del_confirm_form, ajax_request
from utils.pdf import print_agenda from openslides.utils.pdf import print_agenda
from poll.models import Poll, Option from poll.models import Poll, Option
def view(request, item_id): def view(request, item_id):
@ -70,7 +69,7 @@ def overview(request):
items = children_list(Item.objects.filter(parent=None).exclude(hidden=True).order_by('weight')) items = children_list(Item.objects.filter(parent=None).exclude(hidden=True).order_by('weight'))
items_hidden = children_list(Item.objects.filter(parent=None).exclude(hidden=False).order_by('weight')) items_hidden = children_list(Item.objects.filter(parent=None).exclude(hidden=False).order_by('weight'))
try: try:
overview = is_summary() and not get_active_element() overview = is_summary() and not get_active_item()
except Item.DoesNotExist: except Item.DoesNotExist:
overview = True overview = True
return { return {
@ -164,7 +163,25 @@ def edit(request, item_id=None, form='ItemText', default=None):
else: else:
messages.error(request, _('Please check the form for errors.')) messages.error(request, _('Please check the form for errors.'))
else: else:
form = ItemFormText() initial = {}
if default:
if form == "ItemAssignment":
assignment = Assignment.objects.get(pk=default)
initial = {
'assignment': assignment,
'title': assignment.name,
}
elif form == "ItemApplication":
application = Application.objects.get(pk=default)
initial = {
'application': application,
'title': application.title,
}
if item_id is None:
form = MODELFORM[form](initial=initial)
else:
form = item.edit_form()
return { 'form': form, return { 'form': form,
'item': item } 'item': item }

View File

@ -17,16 +17,12 @@ from django.db.models import Max
from django.contrib.auth.models import User from django.contrib.auth.models import User
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from beamer.api import element_register from openslides.participant.models import Profile
from beamer.models import Element from openslides.system.api import config_get
from openslides.utils.utils import _propper_unicode
from participant.models import Profile
from system.api import config_get
from utils.utils import _propper_unicode
class Application(models.Model, Element): class Application(models.Model):
prefix = "application"
STATUS = ( STATUS = (
('pub', _('Published')), ('pub', _('Published')),
('per', _('Permitted')), ('per', _('Permitted')),
@ -332,7 +328,7 @@ class Application(models.Model, Element):
actions.append("support") actions.append("support")
except Profile.DoesNotExist: except Profile.DoesNotExist:
pass pass
if self.status == "pub" and user in self.supporter.all(): if self.status == "pub" and user in self.supporter.all():
actions.append("unsupport") actions.append("unsupport")
@ -369,6 +365,12 @@ class Application(models.Model, Element):
actions.append("permitversion") actions.append("permitversion")
actions.append("rejectversion") actions.append("rejectversion")
if self.number:
if self.itemapplication_set.all():
actions.append("activateitem")
else:
actions.append("createitem")
return actions return actions
def delete(self, force=False): def delete(self, force=False):
@ -429,17 +431,7 @@ class Application(models.Model, Element):
if poll.votesinvalid != None and poll.votescast != None: if poll.votesinvalid != None and poll.votescast != None:
results.append([option.yes, option.no, option.undesided, poll.votesinvalidf, poll.votescastf]) results.append([option.yes, option.no, option.undesided, poll.votesinvalidf, poll.votescastf])
return results return results
def beamer(self):
"""
return the beamer dict
"""
data = super(Application, self).beamer()
data['application'] = self
data['title'] = self.title
data['template'] = 'beamer/Application.html'
return data
@models.permalink @models.permalink
def get_absolute_url(self, link='view'): def get_absolute_url(self, link='view'):
if link == 'view': if link == 'view':
@ -482,5 +474,3 @@ class AVersion(models.Model):
.filter(application=self.application) \ .filter(application=self.application) \
.filter(id__lte=self.id).count() .filter(id__lte=self.id).count()
return self._aid return self._aid
element_register(Application.prefix, Application)

View File

@ -154,10 +154,19 @@
</p> </p>
{% endif %} {% endif %}
<h4></h4> {% if "createitem" in actions %}
<a href='{% url application_activate_item application.id %}'> <h4></h4>
<span class="button"><span class="icon projector">{%trans 'Beam Application' %}</span></span> <a href='{% url item_new_default 'ItemApplication' application.id %}'>
</a> <span class="button"><span class="icon item">{%trans 'New agenda item' %}</span></span>
</a>
{% endif %}
{% if "activateitem" in actions %}
<h4></h4>
<a href='{% url application_activate_item application.id %}'>
<span class="button"><span class="icon projector">{%trans 'Show agenda item' %}</span></span>
</a>
{% endif %}
{% if "acc" in actions or "rej" in actions %} {% if "acc" in actions or "rej" in actions %}
<h4>{% trans "Result after vote" %}:</h4> <h4>{% trans "Result after vote" %}:</h4>

View File

@ -332,8 +332,8 @@ def unsupport(request, application_id):
@permission_required('application.can_manage_application') @permission_required('application.can_manage_application')
def set_active(request, application_id): def set_active(request, application_id):
application = Application.objects.get(pk=application_id) item = Item.objects.get(itemapplication__application__id=application_id)
application.set_active() item.set_active(False)
return redirect(reverse('application_view', args=[application_id])) return redirect(reverse('application_view', args=[application_id]))

View File

@ -15,12 +15,8 @@ from django.utils.translation import ugettext as _
from participant.models import Profile from participant.models import Profile
from beamer.models import Element
from beamer.api import element_register
class Assignment(models.Model):
class Assignment(models.Model, Element):
prefix = 'assignment'
STATUS = ( STATUS = (
('sea', _('Searching for candidates')), ('sea', _('Searching for candidates')),
('vot', _('Voting')), ('vot', _('Voting')),
@ -117,16 +113,6 @@ class Assignment(models.Model, Element):
poll.add_option(candidate) poll.add_option(candidate)
return poll return poll
def beamer(self):
"""
return the beamer dict
"""
data = super(Assignment, self).beamer()
data['assignment'] = self
data['title'] = self.name
data['template'] = 'beamer/Assignment.html'
return data
@models.permalink @models.permalink
def get_absolute_url(self, link='view'): def get_absolute_url(self, link='view'):
if link == 'view': if link == 'view':
@ -144,5 +130,3 @@ class Assignment(models.Model, Element):
('can_nominate_self', "Can nominate themselves"), ('can_nominate_self', "Can nominate themselves"),
('can_manage_assignment', "Can manage assignment"), ('can_manage_assignment', "Can manage assignment"),
) )
element_register(Assignment.prefix, Assignment)

View File

@ -36,14 +36,21 @@
</span> </span>
</a> </a>
{% if not assignment.itemassignment_set.all %}
<h4></h4>
<a href='{% url item_new_default 'ItemAssignment' assignment.id %}'>
<span class="button">
<span class="icon item">{%trans 'New agenda item' %}</span>
</span>
</a>
{% else %}
<h4></h4> <h4></h4>
<a href='{% url assignment_activate_item assignment.id %}'> <a href='{% url assignment_activate_item assignment.id %}'>
<span class="button"> <span class="button">
<span class="icon projector">{%trans 'Beam assignment' %}</span> <span class="icon projector">{%trans 'Show agenda item' %}</span>
</span> </span>
</a> </a>
{% endif %}
</div> </div>
{% endif %} {% endif %}

View File

@ -187,8 +187,8 @@ def delother(request, assignment_id, profile_id):
@permission_required('assignment.can_manage_application') @permission_required('assignment.can_manage_application')
def set_active(request, assignment_id): def set_active(request, assignment_id):
assignment = Assignment.objects.get(pk=assignment_id) item = Item.objects.get(itemassignment__assignment__id=assignment_id)
assignment.set_active() item.set_active(False)
return redirect(reverse('assignment_view', args=[assignment_id])) return redirect(reverse('assignment_view', args=[assignment_id]))
@permission_required('assignment.can_manage_assignment') @permission_required('assignment.can_manage_assignment')

View File

@ -1,35 +1,3 @@
from system.api import config_set, config_get
from beamer.models import ELEMENT
def get_element_from_eid(eid):
try:
model, id = eid.split()
except ValueError:
return None # We need a elementError hier
return ELEMENT[model].objects.get(pk=id)
def get_active_element(only_eid=False):
"""
Returns the active element. If no element is active, or it can not find an Item,
it raise Element.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 beamer.models import Element
eid = config_get("presentation", None)
if only_eid:
return eid
return get_element_from_eid(eid)
def element_register(prefix, model):
ELEMENT[prefix] = model
def assignment_votes(item): def assignment_votes(item):
votes = [] votes = []
if item.type == "ItemAssignment": if item.type == "ItemAssignment":

View File

@ -1,40 +1,3 @@
from django.db import models from django.db import models
from system.api import config_set, config_get # Create your models here.
ELEMENT = {}
class Element(object):
def beamer(self):
"""
Return a map with all Data for the Beamer
"""
return {
'element': self,
'title': 'dummy-title',
}
@property
def eid(self):
"""
Return the eid from this element
"""
for key, value in ELEMENT.iteritems():
if type(self) == value:
return "%s %d" % (key, self.id)
return None
@property
def active(self):
"""
Return True, if the the element is the active one.
"""
from beamer.api import get_active_element
return True if get_active_element(only_eid=True) == self.eid else False
def set_active(self):
"""
Appoint this item as the active one.
"""
config_set("presentation", "%s %d" % (self.prefix, self.id))

View File

@ -6,19 +6,19 @@
<div id="sidebar"> <div id="sidebar">
<div class="box"> <div class="box">
<p><b>{%trans "Status" %}:</b><br> <p><b>{%trans "Status" %}:</b><br>
{% if application.status != "pub" %} {% if item.application.status != "pub" %}
{%trans application.get_status_display %} {%trans item.application.get_status_display %}
<br> <br>
{% else %} {% else %}
{% for note in application.notes %} {% for note in item.application.notes %}
{{ note }} {{ note }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
</p> </p>
<p><b>{% trans "Submitter" %}:</b><br> <p><b>{% trans "Submitter" %}:</b><br>
{{ application.submitter.profile }}</p> {{ item.application.submitter.profile }}</p>
{% with application.poll_set.all as polls %} {% with item.application.poll_set.all as polls %}
{% if polls|length > 0 and polls.0.has_vote %} {% if polls|length > 0 and polls.0.has_vote %}
<p><b>{% trans "Poll result" %}:</b></p> <p><b>{% trans "Poll result" %}:</b></p>
{% for p in polls %} {% for p in polls %}
@ -47,14 +47,14 @@
</div> </div>
</div> </div>
<h1>{% trans "Application No." %} {{ application.number }}</h1> <h1>{% trans "Application No." %} {{ item.application.number }}</h1>
<b>{{ item.title }}</b> <b>{{ item.title }}</b>
<p> <p>
<div class="text">{{ application.public_version.text|linebreaks }}</div> <div class="text">{{ item.application.public_version.text|linebreaks }}</div>
{% if application.public_version.reason %} {% if item.application.public_version.reason %}
<br> <br>
<div class="reason"><p><b>{% trans "Reason" %}:</b></p> <div class="reason"><p><b>{% trans "Reason" %}:</b></p>
{{ application.public_version.reason|linebreaks }}</div> {{ item.application.public_version.reason|linebreaks }}</div>
{% endif %} {% endif %}
</p> </p>
{% endblock %} {% endblock %}

View File

@ -5,31 +5,31 @@
<script type="text/javascript" src="/static/javascript/assignment.js"></script> <script type="text/javascript" src="/static/javascript/assignment.js"></script>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<h1>{% trans "Election" %}: {{ assignment }}</h1> <h1>{% trans "Election" %}: {{ item.assignment }}</h1>
{% if assignment.status != "fin" %} {% if item.assignment.status != "fin" %}
<div id="sidebar"> <div id="sidebar">
<div class="box"> <div class="box">
<p><b>{% trans "Status" %}:</b><br> <p><b>{% trans "Status" %}:</b><br>
{% trans assignment.get_status_display %}</p> {% trans item.assignment.get_status_display %}</p>
{% if assignment.status == "sea" or assignment.status == "vot" %} {% if item.assignment.status == "sea" or item.assignment.status == "vot" %}
<p><b>{% trans "Number of available posts" %}:</b><br> <p><b>{% trans "Number of available posts" %}:</b><br>
{{ assignment.posts }}</p> {{ item.assignment.posts }}</p>
{% endif %} {% endif %}
</div> </div>
</div> </div>
{% endif %} {% endif %}
{% if not assignment.profile.exists %} {% if not item.assignment.profile.exists %}
<p> <p>
<div class="text">{{ assignment.description|linebreaks }}</div> <div class="text">{{ item.assignment.description|linebreaks }}</div>
</p> </p>
{% endif %} {% endif %}
{% if assignment.profile.exists and assignment.status != "fin" %} {% if item.assignment.profile.exists and item.assignment.status != "fin" %}
<h3>{% trans "Candidates" %}</h3> <h3>{% trans "Candidates" %}</h3>
<ol> <ol>
{% for profile in assignment.profile.all|dictsort:"user.first_name" %} {% for profile in item.assignment.profile.all|dictsort:"user.first_name" %}
<li>{{ profile }} </li> <li>{{ profile }} </li>
{% empty %} {% empty %}
<li style="list-style: none outside none;"> <li style="list-style: none outside none;">
@ -46,7 +46,7 @@
<table> <table>
<tr> <tr>
<th>{% trans "Candidates" %}</th> <th>{% trans "Candidates" %}</th>
{% for poll in assignment.poll_set.all %} {% for poll in item.assignment.poll_set.all %}
{% if poll.published %} {% if poll.published %}
<th><nobr>{{forloop.counter}}. {% trans "ballot" %}</nobr></th> <th><nobr>{{forloop.counter}}. {% trans "ballot" %}</nobr></th>
{% endif %} {% endif %}
@ -78,7 +78,7 @@
</tr> </tr>
{% empty %} {% empty %}
<tr> <tr>
<td {% if assignment.profile.exist %}colspan="2"{% endif %}><i>{% trans "No ballots available." %}</i></td> <td {% if item.assignment.profile.exist %}colspan="2"{% endif %}><i>{% trans "No ballots available." %}</i></td>
</tr> </tr>
{% endfor %} {% endfor %}
<tr> <tr>

View File

@ -0,0 +1,19 @@
{% extends "beamer.html" %}
{% block title %}{{ block.super }} - {{ item.title }}{% endblock %}
{% block content %}
{%trans "Poll about" %}:
<h1>{{ item.title }}</h1>
<table>
{% for option in item.poll.get_options %}
<tr>
<td>{{ option }}</td>
<td>{{ option.voteyes }}</td>
{% if item.poll.optiondecision %}
<td>{{ option.voteno }}</td>
<td>{{ option.voteundesided }}</td>
{% endif %}
</tr>
{% endfor %}
</table>
{% endblock %}

View File

@ -24,11 +24,11 @@ from utils.template import render_block_to_string
from system.api import config_set, config_get from system.api import config_set, config_get
from agenda.api import is_summary, children_list, \ from agenda.api import get_active_item, is_summary, children_list, \
del_confirm_form_for_items del_confirm_form_for_items
from agenda.models import Item from agenda.models import Item
from beamer.api import get_active_element, assignment_votes, assignment_polls from beamer.api import assignment_votes, assignment_polls
@permission_required('agenda.can_see_projector') @permission_required('agenda.can_see_projector')
@ -36,51 +36,46 @@ def beamer(request):
""" """
Shows the active Slide. Shows the active Slide.
""" """
data = {'ajax': 'on'}
template = ''
try: try:
element = get_active_element() item = get_active_item()
except Item.DoesNotExist: #TODO: It has to be an Element.DoesNotExist votes = assignment_votes(item)
element = None polls = assignment_polls(item)
if is_summary():
items = item.children.filter(hidden=False)
if element is None: data['items'] = items
data = {} data['title'] = item.title
else: template = 'beamer/overview.html'
data = element.beamer()
data['ajax'] = 'on'
if element is None or (type(element) == Item and is_summary()):
if element is None:
items = Item.objects.filter(parent=None) \
.filter(hidden=False).order_by('weight')
data['title'] = _("Agenda")
else: else:
items = element.children.filter(hidden=False) data['item'] = item.cast()
data['title'] = element.title data['title'] = item.title
data['votes'] = votes
data['polls'] = polls
template = 'beamer/%s.html' % (item.type)
except Item.DoesNotExist:
items = Item.objects.filter(parent=None).filter(hidden=False) \
.order_by('weight')
data['items'] = items data['items'] = items
data['template'] = 'beamer/AgendaSummary.html' data['title'] = _("Agenda")
template = 'beamer/overview.html'
if request.is_ajax(): if request.is_ajax():
content = render_block_to_string(data['template'], 'content', data) content = render_block_to_string(template, 'content', data)
jsondata = { jsondata = {'content': content,
'content': content, 'title': data['title'],
'title': data['title'], 'time': datetime.now().strftime('%H:%M'),
'time': datetime.now().strftime('%H:%M'), 'bigger': config_get('bigger'),
'bigger': config_get('bigger'), 'up': config_get('up'),
'up': config_get('up'), 'countdown_visible': config_get('countdown_visible'),
'countdown_visible': config_get('countdown_visible'), 'countdown_time': config_get('agenda_countdown_time'),
'countdown_time': config_get('agenda_countdown_time'), 'countdown_control': config_get('countdown_control'),
'countdown_control': config_get('countdown_control'), }
}
return ajax_request(jsondata) return ajax_request(jsondata)
else: else:
return render_to_response( return render_to_response(template,
data['template'], data,
data, context_instance=RequestContext(request))
context_instance=RequestContext(request)
)
@permission_required('agenda.can_manage_agenda') @permission_required('agenda.can_manage_agenda')