#103: Set application filename.
This commit is contained in:
parent
67db762575
commit
3812b5ebd1
@ -109,6 +109,7 @@ urlpatterns = patterns('application.views',
|
||||
|
||||
url(r'^print/$',
|
||||
ApplicationPDF.as_view(),
|
||||
{'application_id': None},
|
||||
name='print_applications',
|
||||
),
|
||||
|
||||
|
@ -593,15 +593,23 @@ def application_import(request):
|
||||
|
||||
class ApplicationPDF(PDFView):
|
||||
permission_required = 'application.can_manage_application'
|
||||
filename = u'filename=%s.pdf;' % _("Applications")
|
||||
top_space = 0
|
||||
|
||||
def append_to_pdf(self, story):
|
||||
try:
|
||||
def get_filename(self):
|
||||
application_id = self.kwargs['application_id']
|
||||
except KeyError:
|
||||
application_id = None
|
||||
if application_id is None:
|
||||
filename = _("Applications")
|
||||
else:
|
||||
application = Application.objects.get(id=application_id)
|
||||
if application.number:
|
||||
number = application.number
|
||||
else:
|
||||
number = ""
|
||||
filename = u'%s%s' % (_("Application"), str(number))
|
||||
return filename
|
||||
|
||||
def append_to_pdf(self, story):
|
||||
application_id = self.kwargs['application_id']
|
||||
if application_id is None: #print all applications
|
||||
title = config["application_pdf_title"]
|
||||
story.append(Paragraph(title, stylesheet['Heading1']))
|
||||
@ -621,11 +629,6 @@ class ApplicationPDF(PDFView):
|
||||
story = self.get_application(application, story)
|
||||
else: # print selected application
|
||||
application = Application.objects.get(id=application_id)
|
||||
if application.number:
|
||||
number = application.number
|
||||
else:
|
||||
number = ""
|
||||
filename = u'filename=%s%s.pdf;' % (_("Application"), str(number))
|
||||
story = self.get_application(application, story)
|
||||
|
||||
def get_application(self, application, story):
|
||||
|
@ -232,7 +232,7 @@ class PDFView(PermissionMixin, View):
|
||||
|
||||
def render_to_response(self, filename):
|
||||
response = HttpResponse(mimetype='application/pdf')
|
||||
filename = u'filename=%s.pdf;' % filename
|
||||
filename = u'filename=%s.pdf;' % self.get_filename()
|
||||
response['Content-Disposition'] = filename.encode('utf-8')
|
||||
|
||||
buffer = StringIO()
|
||||
|
Loading…
Reference in New Issue
Block a user