put links in projector settings in categories

This commit is contained in:
Oskar Hahn 2012-03-03 10:47:32 +01:00
parent 654b101dac
commit a69ddffea5
4 changed files with 41 additions and 3 deletions

View File

@ -133,13 +133,13 @@ class Item(MPTTModel, SlideMixin):
order_insertion_by = ['weight', 'title'] order_insertion_by = ['weight', 'title']
register_slidemodel(Item) register_slidemodel(Item, category=_('Agenda'))
# TODO: put this in another file # TODO: put this in another file
from projector.api import register_slidefunc from projector.api import register_slidefunc
from agenda.slides import agenda_show from agenda.slides import agenda_show
register_slidefunc('agenda_show', agenda_show) register_slidefunc('agenda_show', agenda_show, category=_('Agenda'))

View File

@ -58,3 +58,13 @@ class Slide(object):
def get_items(self): def get_items(self):
return self.model.objects.all() return self.model.objects.all()
def get_dict(self):
return {
'key': self.key,
'category': self.category,
'model_slide': self.model_slide,
'func': self.func,
'model': self.model,
'self': self,
}

View File

@ -0,0 +1,23 @@
{% extends "base.html" %}
{% load tags %}
{% load i18n %}
{% block content %}
<h1>{% trans 'Projector' %}</h1>
<ul>
{% for category, slides in categories.items %}
<h2>{{ category }}</h2>
{% for slide in slides %}
{% if slide.model_slide %}
{% for item in slide.get_items %}
<li><a href="{% url projector_activate_slide item.sid %}">{{ item }}</a></li>
{% endfor %}
{% else %}
<li><a href="{% url projector_activate_slide slide.key %}">{{ slide.key }}</a></li>
{% endif %}
{% endfor %}
{% endfor %}
</ul>
{% endblock %}

View File

@ -34,8 +34,13 @@ class SettingView(TemplateView):
def get_context_data(self, **kwargs): def get_context_data(self, **kwargs):
context = super(SettingView, self).get_context_data(**kwargs) context = super(SettingView, self).get_context_data(**kwargs)
categories = {}
for slide in SLIDE.values():
if not categories.has_key(slide.category):
categories[slide.category] = []
categories[slide.category].append(slide)
context.update({ context.update({
'slides': SLIDE.values(), 'categories': categories,
}) })
return context return context