Automated merge with ssh://openslides.de/openslides

This commit is contained in:
Oskar Hahn 2012-02-21 13:17:58 +01:00
commit e9299625ae
12 changed files with 197 additions and 145 deletions

View File

@ -31,6 +31,8 @@ from agenda.api import is_summary
class Item(MPTTModel, Slide): class Item(MPTTModel, Slide):
""" """
An Agenda Item An Agenda Item
MPTT-model. See http://django-mptt.github.com/django-mptt/
""" """
prefix = 'item' prefix = 'item'

View File

@ -10,28 +10,28 @@
<link type="text/css" rel="stylesheet" media="all" href="/static/styles/tabledrag.css" /> <link type="text/css" rel="stylesheet" media="all" href="/static/styles/tabledrag.css" />
<link type="text/css" rel="stylesheet" media="all" href="/static/styles/agenda.css" /> <link type="text/css" rel="stylesheet" media="all" href="/static/styles/agenda.css" />
{% if perms.agenda.can_manage_agenda %} {% if perms.agenda.can_manage_agenda %}
<script type="text/javascript" src="/static/javascript/jquery.once.js"></script> <script type="text/javascript" src="/static/javascript/jquery.once.js"></script>
<script type="text/javascript" src="/static/javascript/jquery.cookie.js"></script> <script type="text/javascript" src="/static/javascript/jquery.cookie.js"></script>
<script type="text/javascript" src="/static/javascript/jquery.tmpl.js"></script> <script type="text/javascript" src="/static/javascript/jquery.tmpl.js"></script>
<script type="text/javascript" src="/static/javascript/tabledrag.js"></script> <script type="text/javascript" src="/static/javascript/tabledrag.js"></script>
<script type="text/javascript" src="/static/javascript/agenda.js"></script> <script type="text/javascript" src="/static/javascript/agenda.js"></script>
<script type="text/javascript"> <script type="text/javascript">
<!--//--><![CDATA[//><!-- <!--//--><![CDATA[//><!--
//This is Drupal Code //This is Drupal Code
jQuery.extend( jQuery.extend(
Drupal.settings, Drupal.settings,
{ {
"tableDrag": "tableDrag":
{ "menu-overview": { "menu-overview":
{ "menu-plid": { "menu-plid":
[ { "target": "menu-plid", "source": "menu-mlid", "relationship": "parent", "action": "match", "hidden": true, "limit": 8 } ], [ { "target": "menu-plid", "source": "menu-mlid", "relationship": "parent", "action": "match", "hidden": true, "limit": 8 } ],
"menu-weight": "menu-weight":
[ { "target": "menu-weight", "source": "menu-weight", "relationship": "sibling", "action": "order", "hidden": true, "limit": 0 } ] [ { "target": "menu-weight", "source": "menu-weight", "relationship": "sibling", "action": "order", "hidden": true, "limit": 0 } ]
} }
} }
}); });
//--><!]]> //--><!]]>
</script> </script>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
@ -41,44 +41,60 @@
{% if items %} {% if items %}
<form action="/agenda/" method="post">{% csrf_token %} <form action="/agenda/" method="post">{% csrf_token %}
{% if perms.agenda.can_manage_agenda %} {% if perms.agenda.can_manage_agenda %}
<div id="changed-order-message" style="display:none" class="notification warning"> <div id="changed-order-message" style="display:none" class="notification warning">
<em>{% trans "Do you want to save the changed order of agenda items?" %}<br> <em>{% trans "Do you want to save the changed order of agenda items?" %}<br>
<input type="submit" value="{% trans 'Yes' %}"> <input type="submit" value="{% trans 'Yes' %}">
<input type="button" onclick="window.location.href='{% url item_overview %}';" value="{%trans 'No' %}"> <input type="button" onclick="window.location.href='{% url item_overview %}';" value="{%trans 'No' %}">
</em> </em>
</div> </div>
<div style="text-align: right; padding: 0 5px 5px 0; margin-top:-20px;"> <div style="text-align: right; padding: 0 5px 5px 0; margin-top:-20px;">
<!-- countdown --> <!-- countdown -->
<input type="checkbox" name="countdown" onchange="document.location='{% if countdown_visible == "True" %}{% url countdown_close %}{% else %}{% url countdown_open %}{% endif %}'" <input type="checkbox" name="countdown" onchange="document.location='{% if countdown_visible %}{% url countdown_close %}{% else %}{% url countdown_open %}{% endif %}'"{% if countdown_visible %} checked{% endif %}>
{% if countdown_visible == "True" %}checked{% endif %}> {% trans "Countdown" %} (<a href="{% url config_agenda %}">{{countdown_time}}{% trans "sec" %}</a>)
{% trans "Countdown" %} (<a href="{% url config_agenda %}">{{countdown_time}}{% trans "sec" %}</a>){% if countdown_visible == "True" %}: {% if countdown_visible == "True" %}:
<a class="projector_countdown" href="{% url countdown_reset countdown_time %}" title="{% trans 'Reset countdown' %}"><img src="/static/images/icons/media-skip-backward.png"></a> <a class="projector_countdown" href="{% url countdown_reset countdown_time %}" title="{% trans 'Reset countdown' %}">
<a class="projector_countdown" href="{% url countdown_start %}" title="{% trans 'Start countdown' %}"><img src="/static/images/icons/media-playback-start.png"></a> <img src="/static/images/icons/media-skip-backward.png" />
<a class="projector_countdown" href="{% url countdown_stop %}" title="{% trans 'Stop countdown' %}"><img src="/static/images/icons/media-playback-pause.png"></a> </a>
{% endif %} <a class="projector_countdown" href="{% url countdown_start %}" title="{% trans 'Start countdown' %}">
<p></p> <img src="/static/images/icons/media-playback-start.png" />
<!-- projector control --> </a>
{% trans "Adjust projector view" %}: <a class="projector_countdown" href="{% url countdown_stop %}" title="{% trans 'Stop countdown' %}">
<a class="projector_edit" href="{% url projector_bigger %}" title="{% trans 'Zoom in' %}"><img src="/static/images/icons/zoom-in.png"></a> <img src="/static/images/icons/media-playback-pause.png" />
<a class="projector_edit" href="{% url projector_smaller %}" title="{% trans 'Zoom out' %}"><img src="/static/images/icons/zoom-out.png"></a> </a>
<a class="projector_edit" href="{% url projector_up %}" title="{% trans 'Scroll text up' %}"><img src="/static/images/icons/go-up.png"></a> {% endif %}
<a class="projector_edit" href="{% url projector_down %}" title="{% trans 'Scroll text down' %}"><img src="/static/images/icons/go-down.png"></a> <p></p>
<a class="projector_edit" href="{% url projector_clean %}" title="{% trans 'Reset projector view' %}"><img src="/static/images/icons/view-restore.png"></a> <!-- projector control -->
</div> {% trans "Adjust projector view" %}:
<a class="projector_edit" href="{% url projector_bigger %}" title="{% trans 'Zoom in' %}">
<img src="/static/images/icons/zoom-in.png" />
</a>
<a class="projector_edit" href="{% url projector_smaller %}" title="{% trans 'Zoom out' %}">
<img src="/static/images/icons/zoom-out.png" />
</a>
<a class="projector_edit" href="{% url projector_up %}" title="{% trans 'Scroll text up' %}">
<img src="/static/images/icons/go-up.png" />
</a>
<a class="projector_edit" href="{% url projector_down %}" title="{% trans 'Scroll text down' %}">
<img src="/static/images/icons/go-down.png" />
</a>
<a class="projector_edit" href="{% url projector_clean %}" title="{% trans 'Reset projector view' %}">
<img src="/static/images/icons/view-restore.png" />
</a>
</div>
{% endif %} {% endif %}
<table id="menu-overview" class="agendatable"> <table id="menu-overview" class="agendatable">
<tr> <tr>
{% if perms.agenda.can_manage_agenda %} {% if perms.agenda.can_manage_agenda %}
<th style="width: 1px;">{% trans "Projector" %}</th> <th style="width: 1px;">{% trans "Projector" %}</th>
{% else %} {% else %}
<th style="width: 1px;">{% trans "Done" %}</th> <th style="width: 1px;">{% trans "Done" %}</th>
{% endif %} {% endif %}
<th>{% trans "Item" %}</th> <th>{% trans "Item" %}</th>
<th style="width: 1px;">{% if perms.agenda.can_manage_agenda %}{% trans "Actions" %}{% endif %}</th> <th style="width: 1px;">{% if perms.agenda.can_manage_agenda %}{% trans "Actions" %}{% endif %}</th>
{% if perms.agenda.can_manage_agenda %} {% if perms.agenda.can_manage_agenda %}
<th class="tabledrag-hide">{% trans "Weight" %}</th> <th class="tabledrag-hide">{% trans "Weight" %}</th>
{% endif %} {% endif %}
</tr> </tr>
<tr id="item_row_0" class="topline {% if overview %} activeline {% else %}{% if perms.agenda.can_manage_agenda %} inactiveline {% endif %}{% endif %}"> <tr id="item_row_0" class="topline {% if overview %} activeline {% else %}{% if perms.agenda.can_manage_agenda %} inactiveline {% endif %}{% endif %}">
@ -91,10 +107,13 @@
{% else %} {% else %}
<td></td> <td></td>
{% endif %} {% endif %}
<td><b>{% trans "Agenda" %} ({{ items|length }} {% trans "items" %}<span id="hiddencount"></span>)</b></td> <td>
<td><span id="action_field" style="width: 1px;white-space: nowrap;"> <b>{% trans "Agenda" %} ({{ items|length }} {% trans "items" %}<span id="hiddencount"></span>)</b>
<span></span> </td>
<a href="{% url print_agenda %}" title="{%trans 'Print agenda' %}"><img src="/static/images/icons/application-pdf.png"></a> <td>
<span id="action_field" style="width: 1px;white-space: nowrap;">
<span></span>
<a href="{% url print_agenda %}" title="{%trans 'Print agenda' %}"><img src="/static/images/icons/application-pdf.png"></a>
</span> </span>
</td> </td>
</tr> </tr>
@ -106,7 +125,7 @@
{% if perms.agenda.can_manage_agenda %} {% if perms.agenda.can_manage_agenda %}
<td class="select"> <td class="select">
<a id="activate_link_{{ item.id }}" class="activate_link" href="{% url item_activate item.id %}"> <a id="activate_link_{{ item.id }}" class="activate_link" href="{% url item_activate item.id %}">
<div></div> <div></div>
</a> </a>
</td> </td>
{% else %} {% else %}
@ -130,19 +149,19 @@
</td> </td>
<td> <td>
<span style="width: 1px;white-space: nowrap;"> <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="{{ item.get_absolute_url }}"><img src="/static/images/icons/document-preview.png" title="{% trans 'Show projector preview' %}"></a>
{% if perms.agenda.can_manage_agenda %} {% if perms.agenda.can_manage_agenda %}
<a href="{% url item_edit item.id %}"><img src="/static/images/icons/document-edit.png" title="{% trans 'Edit item' %}"></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 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 %}"> <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> <span></span>
</a> </a>
{% if item.children.exists %} {% 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> <a href="{% url item_activate_summary item.id %}"><img src="/static/images/icons/view-list-tree.png" title="{% trans 'Select item overview' %}"></a>
{% endif %}
{% endif %} {% endif %}
{% endif %}
</span> </span>
</td> </td>
{% if perms.agenda.can_manage_agenda %} {% if perms.agenda.can_manage_agenda %}
@ -157,7 +176,6 @@
</tr> </tr>
{% endfor %} {% endfor %}
</table> </table>
</form> </form>
{% else %} {% else %}
<i>{% trans "No items available." %}</i> <i>{% trans "No items available." %}</i>

View File

@ -1,5 +1,9 @@
{% extends "base-projector.html" %} {% extends "base-projector.html" %}
{% load i18n %}
{% block title %}{{ block.super }} - {{ item.title }}{% endblock %} {% block title %}{{ block.super }} - {{ item.title }}{% endblock %}
{% block content %} {% block content %}
{% if item.text %} {% if item.text %}
<h1>{{ item.title }}</h1> <h1>{{ item.title }}</h1>

View File

@ -11,7 +11,7 @@
""" """
from django.conf.urls.defaults import * from django.conf.urls.defaults import *
from agenda.views import Overview, View, SetActive, SetClosed, ItemUpdate, ItemCreate, ItemDelete from agenda.views import Overview, View, SetActive, SetClosed, ItemUpdate, ItemCreate, ItemDelete, ItemPDF
urlpatterns = patterns('agenda.views', urlpatterns = patterns('agenda.views',
url(r'^$', url(r'^$',
@ -64,7 +64,7 @@ urlpatterns = patterns('agenda.views',
), ),
url(r'^print/$', url(r'^print/$',
'print_agenda', ItemPDF.as_view(),
name='print_agenda', name='print_agenda',
), ),
) )

View File

@ -9,14 +9,16 @@
:copyright: 2011 by the OpenSlides team, see AUTHORS. :copyright: 2011 by the OpenSlides team, see AUTHORS.
:license: GNU GPL, see LICENSE for more details. :license: GNU GPL, see LICENSE for more details.
""" """
from reportlab.platypus import Paragraph
from django.core.urlresolvers import reverse 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 django.core.context_processors import csrf from django.core.context_processors import csrf
from django.views.generic.detail import SingleObjectMixin from django.views.generic.detail import SingleObjectMixin
from utils.pdf import print_agenda from utils.pdf import stylesheet
from utils.views import TemplateView, RedirectView, UpdateView, CreateView, DeleteView from utils.views import TemplateView, RedirectView, UpdateView, CreateView, DeleteView, PDFView
from system import config from system import config
@ -181,3 +183,17 @@ class ItemDelete(DeleteView):
self.gen_confirm_form(request, _('Do you really want to delete <b>%s</b>?') % name, object.get_absolute_url('delete'), False) self.gen_confirm_form(request, _('Do you really want to delete <b>%s</b>?') % name, object.get_absolute_url('delete'), False)
else: else:
self.gen_confirm_form(request, _('Do you really want to delete <b>%s</b>?') % name, object.get_absolute_url('delete'), True) self.gen_confirm_form(request, _('Do you really want to delete <b>%s</b>?') % name, object.get_absolute_url('delete'), True)
class ItemPDF(PDFView):
permission_required = 'agenda.can_see_agenda'
filename = _('Agenda')
def append_to_pdf(self, story):
for item in Item.objects.all():
ancestors = item.get_ancestors()
if ancestors:
space = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" * ancestors.count()
story.append(Paragraph("%s%s" % (space, item.title), stylesheet['Subitem']))
else:
story.append(Paragraph(item.title, stylesheet['Item']))

View File

@ -1,38 +1,39 @@
{% load tags %}
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
{% load tags %} <head>
<head> <link type="text/css" rel="stylesheet" href="/static/styles/projector.css">
<link type="text/css" rel="stylesheet" href="/static/styles/projector.css"> <link rel="shortcut icon" href="/static/images/favicon.png" type="image/png" />
<link rel="shortcut icon" href="/static/images/favicon.png" type="image/png" /> <script type="text/javascript" src="/static/javascript/jquery.js"></script>
<script type="text/javascript" src="/static/javascript/jquery.js"></script> <script type="text/javascript" src="/static/javascript/projector.js"></script>
<script type="text/javascript" src="/static/javascript/projector.js"></script> <title>{% block title %} {% get_config 'event_name' %} {% endblock %}</title>
<title>{% block title %} {% get_config 'event_name' %} {% endblock %}</title> {% block header %}
{% block header %} {% endblock %}
{% endblock %} </head>
</head> <body>
<body> <div id="config" style="display:none;">
<div id="config" style="display:none;"> <div id="ajax">{{ ajax }}</div>
<div id="ajax">{{ ajax }}</div> </div>
</div> <div id="ajaxswitcher"></div>
<div id="ajaxswitcher"></div>
<div id="header"> <div id="header">
<div id="logo"><img src="/static/images/logo-projector.png"></div> <div id="logo"><img src="/static/images/logo-projector.png"></div>
<div class="event_name">{% get_config 'event_name' %}</div> <div class="event_name">{% get_config 'event_name' %}</div>
<div class="event_description">{% get_config 'event_description' %}</div> <div class="event_description">{% get_config 'event_description' %}</div>
</div> </div>
<div id="currentTime"> <div id="currentTime">
{% now "H:i" %} {% now "H:i" %}
</div> </div>
<div id="countdown">0:00</div> <div id="countdown">0:00</div>
<div id="content"> <div id="content">
{% block content %} {% block content %}
{% endblock %} {% endblock %}
</div> </div>
</body> </body>
</html> </html>

View File

@ -16,33 +16,33 @@ urlpatterns = patterns('projector.views',
url(r'^$', 'active_slide', url(r'^$', 'active_slide',
name='projector_show'), name='projector_show'),
url(r'^bigger$', 'projector_edit', {'direction': 'bigger'}, url(r'^bigger/$', 'projector_edit', {'direction': 'bigger'},
name='projector_bigger'), name='projector_bigger'),
url(r'^smaller$', 'projector_edit', {'direction': 'smaller'}, url(r'^smaller/$', 'projector_edit', {'direction': 'smaller'},
name='projector_smaller'), name='projector_smaller'),
url(r'^up$', 'projector_edit', {'direction': 'up'}, url(r'^up/$', 'projector_edit', {'direction': 'up'},
name='projector_up'), name='projector_up'),
url(r'^projector/down$', 'projector_edit', {'direction': 'down'}, url(r'^down/$', 'projector_edit', {'direction': 'down'},
name='projector_down'), name='projector_down'),
url(r'^projector/clean$', 'projector_edit', {'direction': 'clean'}, url(r'^clean/$', 'projector_edit', {'direction': 'clean'},
name='projector_clean'), name='projector_clean'),
url(r'^projector/countdown/show$', 'projector_countdown', {'command': 'show'}, url(r'^countdown/show/$', 'projector_countdown', {'command': 'show'},
name='countdown_open'), name='countdown_open'),
url(r'^projector/countdown/hide$', 'projector_countdown', {'command': 'hide'}, url(r'^countdown/hide/$', 'projector_countdown', {'command': 'hide'},
name='countdown_close'), name='countdown_close'),
url(r'^projector/countdown/reset/(?P<time>\d+)$', 'projector_countdown', {'command': 'reset'}, url(r'^countdown/reset/(?P<time>\d+)/$', 'projector_countdown', {'command': 'reset'},
name='countdown_reset'), name='countdown_reset'),
url(r'^projector/countdown/start$', 'projector_countdown', {'command': 'start'}, url(r'^countdown/start/$', 'projector_countdown', {'command': 'start'},
name='countdown_start'), name='countdown_start'),
url(r'^projector/countdown/stop$', 'projector_countdown', {'command': 'stop'}, url(r'^countdown/stop/$', 'projector_countdown', {'command': 'stop'},
name='countdown_stop'), name='countdown_stop'),
) )

View File

@ -2,7 +2,7 @@ function presentation_reload() {
if ($('#config > #ajax').html() == 'on') { if ($('#config > #ajax').html() == 'on') {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: '/projector', url: '/projector/',
dataType: 'json', dataType: 'json',
data: '', data: '',
success: function(data) { success: function(data) {
@ -14,9 +14,10 @@ function presentation_reload() {
$('#content li').css({'font-size': data.bigger + '%'}, 200); $('#content li').css({'font-size': data.bigger + '%'}, 200);
$('#content #sidebar').css({'font-size': '16px'}, 0); $('#content #sidebar').css({'font-size': '16px'}, 0);
$('#content').animate({'margin-top': data.up + 'em'}, 200); $('#content').animate({'margin-top': data.up + 'em'}, 200);
if (data.countdown_visible == "True")
if (data.countdown_visible == true)
$('#countdown').slideDown(); $('#countdown').slideDown();
if (data.countdown_visible == "False") if (data.countdown_visible == false)
$('#countdown').slideUp(); $('#countdown').slideUp();
if (data.countdown_control == "reset") if (data.countdown_control == "reset")
resetTimer(data.countdown_time); resetTimer(data.countdown_time);

View File

@ -1,3 +1,3 @@
from system.models import Config from system.models import Config
# TODO: Test that this is not thead-save
config = Config() config = Config()

View File

@ -31,7 +31,7 @@ urlpatterns = patterns('',
(r'', include('participant.urls')), (r'', include('participant.urls')),
(r'', include('assignment.urls')), (r'', include('assignment.urls')),
(r'', include('system.urls')), (r'', include('system.urls')),
(r'projector', include('projector.urls')), (r'projector/', include('projector.urls')),
(r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_DOC_ROOT}), (r'^static/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.STATIC_DOC_ROOT}),
(r'^i18n/', include('django.conf.urls.i18n')), (r'^i18n/', include('django.conf.urls.i18n')),
) )

View File

@ -183,8 +183,6 @@ event_date = config["event_date"]
event_location = config["event_location"] event_location = config["event_location"]
event_organizer = config["event_organizer"] event_organizer = config["event_organizer"]
# set print time
time = datetime.now().strftime(str(_("%Y-%m-%d %H:%Mh")))
def firstPage(canvas, doc): def firstPage(canvas, doc):
@ -197,6 +195,7 @@ def firstPage(canvas, doc):
canvas.drawString(2.75*cm, 27.6*cm, "%s, %s" % (event_date, event_location)) canvas.drawString(2.75*cm, 27.6*cm, "%s, %s" % (event_date, event_location))
# time # time
canvas.setFont('Ubuntu',7) canvas.setFont('Ubuntu',7)
time = datetime.now().strftime(str(_("%Y-%m-%d %H:%Mh")))
canvas.drawString(15*cm, 28*cm, _("Printed")+": %s" % time) canvas.drawString(15*cm, 28*cm, _("Printed")+": %s" % time)
# title # title
if doc.title: if doc.title:
@ -217,36 +216,7 @@ def laterPages(canvas, doc):
canvas.setFont('Ubuntu',7) canvas.setFont('Ubuntu',7)
canvas.setFillGray(0.4) canvas.setFillGray(0.4)
canvas.drawString(10*cm, 1*cm, _("Page")+" %s" % doc.page) canvas.drawString(10*cm, 1*cm, _("Page")+" %s" % doc.page)
canvas.restoreState() canvas.restoreState()s
@permission_required('agenda.can_see_agenda')
def print_agenda(request):
response = HttpResponse(mimetype='application/pdf')
filename = u'filename=%s.pdf;' % _("Agenda")
response['Content-Disposition'] = filename.encode('utf-8')
doc = SimpleDocTemplate(response)
story = [Spacer(1,3*cm)]
doc.title = _("Agenda")
# print item list
items = Item.objects.all()
for item in items:
if item.hidden is False:
# print all items"
if item.parents:
space = ""
counter = 0
for p in item.parents:
if counter != 0:
space += "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
counter += 1
story.append(Paragraph(space+item.title, stylesheet['Subitem']))
else:
story.append(Paragraph(item.title, stylesheet['Item']))
doc.build(story, onFirstPage=firstPage, onLaterPages=laterPages)
return response
@permission_required('participant.can_see_participant') @permission_required('participant.can_see_participant')

View File

@ -3,6 +3,14 @@ try:
except ImportError: except ImportError:
import simplejson as json import simplejson as json
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
from reportlab.platypus import SimpleDocTemplate, Paragraph, Frame, PageBreak, Spacer, Table, LongTable, TableStyle, Image
from reportlab.lib.units import cm
from django.conf import settings from django.conf import settings
from django.http import HttpResponseServerError, HttpResponse from django.http import HttpResponseServerError, HttpResponse
from django.core.urlresolvers import reverse from django.core.urlresolvers import reverse
@ -13,10 +21,12 @@ from django.utils.decorators import method_decorator
from django.views.generic import (TemplateView as _TemplateView, from django.views.generic import (TemplateView as _TemplateView,
RedirectView as _RedirectView, RedirectView as _RedirectView,
UpdateView as _UpdateView, UpdateView as _UpdateView,
CreateView as _CreateView,) CreateView as _CreateView,
View,)
from django.views.generic.detail import SingleObjectMixin from django.views.generic.detail import SingleObjectMixin
from utils import render_to_forbitten from utils import render_to_forbitten
from pdf import firstPage, laterPages
FREE_TO_GO = 'free to go' FREE_TO_GO = 'free to go'
@ -98,6 +108,36 @@ class DeleteView(RedirectView, SingleObjectMixin):
def pre_post_redirect(self, request, *args, **kwargs): def pre_post_redirect(self, request, *args, **kwargs):
pass pass
class PDFView(View, PermissionMixin):
filename = 'No_Name'
def render_to_response(self, filename):
response = HttpResponse(mimetype='application/pdf')
filename = u'filename=%s.pdf;' % filename
response['Content-Disposition'] = filename.encode('utf-8')
buffer = StringIO()
pdf_document = SimpleDocTemplate(buffer)
story = [Spacer(1,3*cm)]
self.append_to_pdf(story)
pdf_document.build(story, onFirstPage=firstPage, onLaterPages=laterPages)
pdf = buffer.getvalue()
buffer.close()
response.write(pdf)
return response
def append_to_pdf(self, story):
pass
def get_filename(self):
return self.filename
def get(self, request, *args, **kwargs):
return self.render_to_response(self.get_filename())
def server_error(request, template_name='500.html'): def server_error(request, template_name='500.html'):
""" """