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