Skip to content
Snippets Groups Projects
Commit 16ea0857 authored by Todd Dembrey's avatar Todd Dembrey Committed by Fredrik Jonsson
Browse files

Add download link to simplified project page

parent 6933edce
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,12 @@
<span>{{ object.submission.round }}</span>
<span>Lead: {{ object.lead }}</span>
</h5>
<a
class="button button--primary simplified__button"
href="{% url "apply:projects:download" pk=object.pk %}"
>
Download PDF
</a>
</div>
</div>
......
......@@ -12,6 +12,7 @@ from .views import (
ProjectDetailView,
ProjectEditView,
ProjectListView,
ProjectDetailPDFView,
ProjectOverviewView,
ProjectPrivateMediaView,
ReportDetailView,
......@@ -31,6 +32,7 @@ urlpatterns = [
path('edit/', ProjectEditView.as_view(), name="edit"),
path('documents/<int:file_pk>/', ProjectPrivateMediaView.as_view(), name="document"),
path('contract/<int:file_pk>/', ContractPrivateMediaView.as_view(), name="contract"),
path('download/', ProjectDetailPDFView.as_view(), name='download'),
path('simplified/', ProjectDetailSimplifiedView.as_view(), name='simplified'),
path('request/', CreatePaymentRequestView.as_view(), name='request'),
])),
......
......@@ -6,7 +6,7 @@ from django.contrib.auth.mixins import UserPassesTestMixin
from django.core.exceptions import PermissionDenied
from django.db import transaction
from django.db.models import Count
from django.http import Http404
from django.http import FileResponse, Http404
from django.shortcuts import get_object_or_404, redirect
from django.urls import reverse, reverse_lazy
from django.utils import timezone
......@@ -14,6 +14,7 @@ from django.utils.decorators import method_decorator
from django.utils.functional import cached_property
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext_lazy as _
from django.views import View
from django.views.generic import (
CreateView,
DetailView,
......@@ -21,12 +22,14 @@ from django.views.generic import (
TemplateView,
UpdateView,
)
from django.views.generic.detail import SingleObjectMixin
from django_filters.views import FilterView
from django_tables2 import SingleTableMixin
from hypha.apply.activity.messaging import MESSAGES, messenger
from hypha.apply.activity.views import ActivityContextMixin, CommentFormView
from hypha.apply.users.decorators import approver_required, staff_required
from hypha.apply.utils.pdfs import make_pdf
from hypha.apply.utils.storage import PrivateMediaView
from hypha.apply.utils.views import DelegateableView, DelegatedViewMixin, ViewDispatcher
......@@ -518,6 +521,29 @@ class ProjectDetailSimplifiedView(DetailView):
template_name_suffix = '_simplified_detail'
@method_decorator(staff_required, name='dispatch')
class ProjectDetailPDFView(SingleObjectMixin, View):
model = Project
def get(self, request, *args, **kwargs):
self.object = self.get_object().submission
pdf = make_pdf(
title=self.object.title,
meta=[
self.object.stage,
self.object.page,
self.object.round,
f"Lead: { self.object.lead }",
],
content=self.object.output_text_answers()
)
return FileResponse(
pdf,
as_attachment=True,
filename=self.object.title + '.pdf',
)
class ProjectApprovalEditView(UpdateView):
form_class = ProjectApprovalForm
model = Project
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment