added signals for template-context-manipulation

This commit is contained in:
Oskar Hahn 2012-03-06 12:16:03 +01:00
parent 50360dde96
commit 062e9bd4cb
7 changed files with 29 additions and 6 deletions

View File

@ -1,8 +1,7 @@
from django.utils.translation import ugettext as _
from agenda.models import Item
def agenda_show():
from agenda.models import Item
data = {}
items = Item.objects.filter(parent=None)
data['title'] = _("Agenda")

View File

@ -23,7 +23,6 @@ from projector.models import SlideMixin
from participant.models import Profile
from system import config
from utils.utils import _propper_unicode
from poll import ChoicePoll
from poll.models import BaseOption, BasePoll, CountVotesCast, CountInvalid, Vote

View File

@ -42,6 +42,7 @@
<td>{{ pollform.votescast.errors }}{{ pollform.votescast }}</td>
</tr>
</table>
{{ post_form }}
<button class="button" type="submit">
<span class="icon ok">{%trans 'Save' %}</span>
</button>

View File

@ -1,7 +1,9 @@
from django.views.generic import TemplateView
from django.http import HttpResponseRedirect
from django.forms.models import modelform_factory
from utils.views import TemplateView
class PollFormView(TemplateView):
template_name = 'poll/poll.html'
poll_argument = 'poll_id'

View File

@ -35,8 +35,10 @@ def set_active_slide(sid):
config["presentation"] = sid
def register_slidemodel(model, category=None, model_name=''):
def register_slidemodel(model, category=None, model_name=None):
#TODO: Warn if there already is a slide with this prefix
if model_name is None:
model_name = model.prefix
SLIDE[model.prefix] = Slide(
model_slide=True,
model=model,

View File

@ -0,0 +1,15 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
openslides.utils.signals
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Defines Signals for the openslides-project.
:copyright: 2011 by the OpenSlides team, see AUTHORS.
:license: GNU GPL, see LICENSE for more details.
"""
from django.dispatch import Signal
template_manipulation = Signal(providing_args=['context'])

View File

@ -26,6 +26,7 @@ from django.views.generic import (TemplateView as _TemplateView,
from django.views.generic.detail import SingleObjectMixin
from utils import render_to_forbitten
from openslides.utils.signals import template_manipulation
from pdf import firstPage, laterPages
FREE_TO_GO = 'free to go'
@ -55,8 +56,12 @@ class PermissionMixin(object):
return super(LoginMixin, self).dispatch(request, *args, **kwargs)
class TemplateView(_TemplateView, PermissionMixin):
pass
def get_context_data(self, **kwargs):
context = super(TemplateView, self).get_context_data(**kwargs)
template_manipulation.send(sender=self, context=context, blub=True)
return context
class RedirectView(_RedirectView, PermissionMixin):