From 361bc40821f52336cf502ed1a3c01ec50960ca95 Mon Sep 17 00:00:00 2001 From: Oskar Hahn Date: Sun, 15 Apr 2012 09:55:21 +0200 Subject: [PATCH] view for Agenda.item --- .../agenda/templates/agenda/item_row.html | 3 +-- openslides/agenda/templates/agenda/view.html | 11 +++++++++ openslides/agenda/views.py | 23 ++++++++----------- openslides/utils/views.py | 7 ++++++ 4 files changed, 28 insertions(+), 16 deletions(-) create mode 100644 openslides/agenda/templates/agenda/view.html diff --git a/openslides/agenda/templates/agenda/item_row.html b/openslides/agenda/templates/agenda/item_row.html index e2b44dd95..09dc44907 100644 --- a/openslides/agenda/templates/agenda/item_row.html +++ b/openslides/agenda/templates/agenda/item_row.html @@ -15,11 +15,10 @@ {% if perms.agenda.can_manage_agenda %}
{% endif %} - {{ item }} + {{ item }} - {% if perms.agenda.can_manage_agenda %} diff --git a/openslides/agenda/templates/agenda/view.html b/openslides/agenda/templates/agenda/view.html new file mode 100644 index 000000000..a264d50b3 --- /dev/null +++ b/openslides/agenda/templates/agenda/view.html @@ -0,0 +1,11 @@ +{% extends "agenda/base_agenda.html" %} + +{% load i18n %} + +{% block title %}{{ block.super }} – {{ item.title }}{% endblock %} + +{% block content %} +

{{ item.title }}

+ {{ item.text }} + +{% endblock %} diff --git a/openslides/agenda/views.py b/openslides/agenda/views.py index c74667829..338f93951 100644 --- a/openslides/agenda/views.py +++ b/openslides/agenda/views.py @@ -18,7 +18,8 @@ from django.core.context_processors import csrf from django.views.generic.detail import SingleObjectMixin from utils.pdf import stylesheet -from utils.views import TemplateView, RedirectView, UpdateView, CreateView, DeleteView, PDFView, FormView +from utils.views import (TemplateView, RedirectView, UpdateView, CreateView, + DeleteView, PDFView, FormView, DetailView) from utils.template import Tab from config.models import config @@ -30,19 +31,6 @@ from agenda.api import is_summary from agenda.forms import ItemOrderForm, ItemForm, ConfigForm -class View(TemplateView): - permission_required = 'agenda.can_see_projector' - template_name = 'projector/AgendaText.html' - - def get_context_data(self, **kwargs): - context = super(View, self).get_context_data(**kwargs) - context.update({ - 'item': Item.objects.get(pk=kwargs['pk']), - 'ajax': 'off', - }) - return context - - class Overview(TemplateView): permission_required = 'agenda.can_see_agenda' template_name = 'agenda/overview.html' @@ -73,6 +61,13 @@ class Overview(TemplateView): return self.render_to_response(context) +class View(DetailView): + permission_required = 'agenda.can_see_agenda' + template_name = 'agenda/view.html' + model = Item + context_object_name = 'item' + + class SetActive(RedirectView, SingleObjectMixin): """ Set an Item as the active one. diff --git a/openslides/utils/views.py b/openslides/utils/views.py index 692cd1b8a..b4dc4de1b 100644 --- a/openslides/utils/views.py +++ b/openslides/utils/views.py @@ -203,6 +203,13 @@ class DeleteView(RedirectView, SingleObjectMixin): messages.warning(request, '%s
' % (message, url, csrf(request)['csrf_token'], _("Yes"), _("No"))) +class DetailView(SingleObjectMixin, TemplateView): + def get(self, request, *args, **kwargs): + self.object = self.get_object() + context = self.get_context_data(object=self.object) + return TemplateView.get(self, request, *args, **kwargs) + + class PDFView(PermissionMixin, View): filename = _('undefined-filename') top_space = 3