Added PDF document title.
This commit is contained in:
parent
e84861211a
commit
4abd79e7b5
@ -11,7 +11,7 @@
|
||||
"""
|
||||
|
||||
from django.conf.urls.defaults import *
|
||||
from agenda.views import Overview, View, SetActive, SetClosed, ItemUpdate, ItemCreate, ItemDelete, ItemPDF
|
||||
from agenda.views import Overview, View, SetActive, SetClosed, ItemUpdate, ItemCreate, ItemDelete, AgendaPDF
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$',
|
||||
@ -64,7 +64,7 @@ urlpatterns = patterns('',
|
||||
),
|
||||
|
||||
url(r'^print/$',
|
||||
ItemPDF.as_view(),
|
||||
AgendaPDF.as_view(),
|
||||
name='print_agenda',
|
||||
),
|
||||
)
|
||||
|
@ -185,9 +185,10 @@ class ItemDelete(DeleteView):
|
||||
self.gen_confirm_form(request, _('Do you really want to delete <b>%s</b>?') % name, object.get_absolute_url('delete'), True)
|
||||
|
||||
|
||||
class ItemPDF(PDFView):
|
||||
class AgendaPDF(PDFView):
|
||||
permission_required = 'agenda.can_see_agenda'
|
||||
filename = _('Agenda')
|
||||
document_title = _('Agenda')
|
||||
|
||||
def append_to_pdf(self, story):
|
||||
for item in Item.objects.all():
|
||||
|
@ -608,6 +608,7 @@ class ApplicationPDF(PDFView):
|
||||
permission_required = 'application.can_manage_application'
|
||||
filename = u'filename=%s.pdf;' % _("Applications")
|
||||
top_space = 0
|
||||
document_title = ''
|
||||
|
||||
def append_to_pdf(self, story):
|
||||
try:
|
||||
|
@ -203,12 +203,16 @@ class DeleteView(RedirectView, SingleObjectMixin):
|
||||
|
||||
|
||||
class PDFView(PermissionMixin, View):
|
||||
filename = 'No_Name'
|
||||
filename = _('No name')
|
||||
top_space = 3
|
||||
document_title = _('No title')
|
||||
|
||||
def get_top_space(self):
|
||||
return self.top_space
|
||||
|
||||
def get_document_title(self):
|
||||
return self.document_title
|
||||
|
||||
def render_to_response(self, filename):
|
||||
response = HttpResponse(mimetype='application/pdf')
|
||||
filename = u'filename=%s.pdf;' % filename
|
||||
@ -216,6 +220,7 @@ class PDFView(PermissionMixin, View):
|
||||
|
||||
buffer = StringIO()
|
||||
pdf_document = SimpleDocTemplate(buffer)
|
||||
pdf_document.title = self.get_document_title()
|
||||
story = [Spacer(1, self.get_top_space()*cm)]
|
||||
|
||||
self.append_to_pdf(story)
|
||||
|
Loading…
Reference in New Issue
Block a user