register functions als slide

This commit is contained in:
Oskar Hahn 2012-02-09 01:46:58 +01:00
parent 8c27c731f8
commit 7808783145
9 changed files with 61 additions and 114 deletions

View File

@ -0,0 +1,4 @@
from projector.api import register_slidefunc
from agenda.slides import agenda_show
register_slidefunc('agenda_show', agenda_show)

View File

@ -22,11 +22,6 @@ def is_summary():
"""
True, if a summery shall be displayed
"""
from agenda.models import Item
try:
get_active_slide()
except Item.DoesNotExist:
return True
if config_get('summary', False):
return True
return False

View File

@ -24,6 +24,7 @@ from system.api import config_set
from application.models import Application
from poll.models import Poll
from assignment.models import Assignment
from agenda.api import is_summary
class Item(models.Model, Slide):
@ -45,12 +46,17 @@ class Item(models.Model, Slide):
"""
Return a map with all Data for the Slide
"""
return {
data = {
'item': self,
'title': self.title,
'template': 'projector/AgendaText.html',
}
if is_summary():
data['items'] = self.children.filter(hidden=False)
data['template'] = 'projector/AgendaSummary.html'
return data
@property
def active_parent(self):
"""
@ -189,6 +195,6 @@ class Item(models.Model, Slide):
ItemText = Item # ItemText is Depricated
register_slidemodel(Item)

View File

@ -0,0 +1,13 @@
from django.utils.translation import ugettext as _
from projector.api import register_slidefunc
from agenda.models import Item
def agenda_show():
data = {}
items = Item.objects.filter(parent=None) \
.filter(hidden=False).order_by('weight')
data['title'] = _("Agenda")
data['items'] = items
data['template'] = 'projector/AgendaSummary.html'
return data

View File

@ -34,10 +34,7 @@
{% block content %}
<h1>{% trans "Agenda" %}</h1>
{% if items_hidden and perms.agenda.can_manage_agenda %}
<a href="#hidden">{% trans "Go to hidden items" %}</a>
{% endif %}
{% if items or items_hidden %}
{% if items %}
<form action="/agenda/" method="post">{% csrf_token %}
{% if perms.agenda.can_manage_agenda %}
<div id="changed-order-message" style="display:none" class="notification warning">
@ -190,72 +187,6 @@
</tr>
{% endif %}
{% endfor %}
{% if perms.agenda.can_manage_agenda %}
<tr class="emptyline">
<td colspan="4"></td>
</tr>
<tr class="topline">
<td colspan="4"><a name="hidden"></a>{% trans "Hidden items:" %}</td>
</tr>
{% for item in items_hidden %}
<tr id="item_row_{{ item.id }}" class="draggable{% cycle ' odd' '' %}
{% if item.active %} activeline{% else %}
{% if item.parent.active and summary %} activesummarychildline{% endif %}
{% if perms.agenda.can_manage_agenda %} inactiveline{% endif %}
{% endif %}">
<td class="select">
<a id="activate_link_{{ item.id }}" class="activate_link" href="{% url item_activate item.id %}">
<div></div>
</a>
</td>
<td>
{% for p in item.parents %}
<div class="indentation">&nbsp;</div>
{% endfor %}
<div class="dragcell"></div>
{{ item }}
</td>
<td>
{% ifequal item.type 'ItemApplication' %}
<a href="{% url application_view item.cast.application.id %}">{% trans "Application" %} {{ item.cast.application.number }}</a>
{% endifequal %}
{% ifequal item.type 'ItemPoll' %}
{% if item.cast.poll.application %}
<a href="{% url poll_view item.cast.poll.id %}">{% trans "Poll of Application" %}</a>
{% endif %}
{% if item.cast.poll.assignment %}
<a href="{% url poll_view item.cast.poll.id %}">{% trans "Poll of Election" %}</a>
{% endif %}
{% endifequal %}
{% ifequal item.type 'ItemAssignment' %}
<a href="{% url assignment_view item.cast.assignment.id %}">{% trans "Election" %}</a>
{% endifequal %}
{% ifequal item.type 'ItemText' %}
Text
{% endifequal %}
</td>
<td><span style="width: 1px;white-space: nowrap;">
<a href="{{ item.get_absolute_url }}"><img src="/static/images/icons/document-preview.png" title="{% trans 'Show projector preview' %}"></a>
<a href="{% url item_edit item.id %}"><img src="/static/images/icons/document-edit.png" title="{% trans 'Edit item' %}"></a>
<a href="{% url item_delete item.id %}"><img src="/static/images/icons/edit-delete.png" title="{% trans 'Delete item' %}"></a>
<a class="close_link {% if item.closed %}closed{% else %}open{% endif %}" href="{% if item.closed %}{% url item_open item.id %}{% else %}{% url item_close item.id %}{% endif %}">
<span></span>
</a>
{% if item.children.exists %}
<a href="{% url item_activate_summary item.id %}"><img src="/static/images/icons/view-list-tree.png" title="{% trans 'Select item overview' %}"></a>
{% endif %}
</span>
</td>
<td class="tabledrag-hide">
{% with form=item.weight_form %}
{{ form.weight }}
{{ form.self }}
{{ form.parent }}
{% endwith %}
</td>
</tr>
{% endfor %}
{% endif %}
</table>
</form>

View File

@ -63,15 +63,13 @@ def overview(request):
item.weight = form.cleaned_data['weight']
item.save()
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'))
try:
overview = is_summary() and not get_active_slide()
except Item.DoesNotExist:
items = children_list(Item.objects.filter(parent=None).order_by('weight'))
if get_active_slide(only_sid=True) == 'agenda_show':
overview = True
else:
overview = False
return {
'items': items,
'items_hidden': items_hidden,
'overview': overview,
'summary': is_summary(),
'countdown_visible': config_get('countdown_visible'),
@ -85,7 +83,7 @@ def set_active(request, item_id, summary=False):
Set an Item as the active one.
"""
if item_id == "0":
config_set("presentation", "0")
config_set("presentation", "agenda_show")
else:
try:
item = Item.objects.get(id=item_id)

View File

@ -3,13 +3,17 @@ from projector.models import SLIDE
def get_slide_from_sid(sid):
try:
model, id = sid.split()
except ValueError:
return None # We need a slideError hier
except AttributeError:
return None
return SLIDE[model].objects.get(pk=id)
data = sid.split()
if len(data) == 2:
model = data[0]
id = data[1]
return SLIDE[model].objects.get(pk=id).slide()
if len(data) == 1:
try:
return SLIDE[data[0]]()
except KeyError:
return None
return None
def get_active_slide(only_sid=False):
@ -31,6 +35,12 @@ def register_slidemodel(model):
SLIDE[model.prefix] = model
def register_slidefunc(name, func):
if ' ' in name:
raise NameError('There can be no space in name')
SLIDE[name] = func
def assignment_votes(item):
votes = []
if item.type == "ItemAssignment":

View File

@ -0,0 +1,6 @@
{% extends "base-projector.html" %}
{% load tags %}
{% block content %}
<h1>{% get_config 'event_name' %}</h1>
{% get_config 'event_description' %}
{% endblock %}

View File

@ -37,31 +37,15 @@ def active_slide(request):
Shows the active Slide.
"""
try:
slide = get_active_slide()
except Item.DoesNotExist: #TODO: It has to be an Slide.DoesNotExist
slide = None
if slide is None:
data = {}
else:
data = slide.slide()
data = get_active_slide()
except AttributeError: #TODO: It has to be an Slide.DoesNotExist
data = {
'title': config_get('event_name'),
'template': 'projector/default.html',
}
data['ajax'] = 'on'
if slide is None or (type(slide) == Item and is_summary()):
if slide is None:
items = Item.objects.filter(parent=None) \
.filter(hidden=False).order_by('weight')
data['title'] = _("Agenda")
else:
items = slide.children.filter(hidden=False)
data['title'] = slide.title
data['items'] = items
data['template'] = 'projector/AgendaSummary.html'
if request.is_ajax():
content = render_block_to_string(data['template'], 'content', data)
jsondata = {