Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

{% with email_context=source.page.specific %}{{ email_context.confirmation_text_extra }}{% endwith %}

{% trans "Project Id" %}: {{ source.public_id|default:source.id }}
{% trans "Project ID" %}: {{ source.public_id|default:source.id }}
{% trans "Project name" %}: {{ source.title }}
{% trans "Contact name" %}: {{ source.user.get_full_name }}
{% trans "Contact email" %}: {{ source.user.email }}
Expand Down
2 changes: 1 addition & 1 deletion hypha/apply/funds/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1823,7 +1823,7 @@ def get_object(self, queryset=None):

def get(self, request, *args, **kwargs):
self.object = self.get_object()
pdf_page_settings = PDFPageSettings.for_request(request)
pdf_page_settings = PDFPageSettings.load(request_or_site=request)
content = draw_submission_content(self.object.output_text_answers())
pdf = make_pdf(
title=self.object.title,
Expand Down
96 changes: 53 additions & 43 deletions hypha/apply/projects/templates/application_projects/paf_export.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,32 +2,9 @@
{% load i18n %}

{% block content %}
<table id="page-width">
<!-- Project details in table format -->
<tr>
<td rowspan="4" align="left" class="align-left">
<p class="title"> <b>{{ org_name|upper }}</b> PROJECT FORM</p>
</td>
<td align="right" class="align-right">
<b>{% trans "Project title" %}</b>
</td>
</tr>
<tr>
<td align="right" class="align-right">
<a href="{{ project_link }}">{{ title }}</a>
</td>
</tr>
<tr>
<td align="right" class="align-right">
<b>{% trans "Project ID" %}</b>
</td>
</tr>
<tr>
<td align="right" class="align-right">
{{ id }}
</td>
</tr>
</table>
<h1>{{ org_name }} {% trans "Project Form" %}</h1>
<p><b>{% trans "Project title" %}</b>: <a href="{{ project_link }}">{{ title }}</a></p>
<p><b>{% trans "Project ID" %}</b>: {{ id }}</p>

<hr>

Expand All @@ -43,32 +20,65 @@
<p>{{ field_value|safe|default:"-" }}</p>
{% endfor %}

<!-- Approvers data in paragraph format-->
<p><b> Approvals </b></p>
<!-- Approvers data in list format -->
<h2>{% trans "Approvals" %}</h2>
{% if approvals %}
{% for approval in approvals %}
<p>{{ approval.paf_reviewer_role.label }} - {% if approval.approved %} Approved {% else %} Pending{% endif %}
{% if approval.user %}({{ approval.user }}){% endif %}</p>
{% endfor %}
<ul>
{% for approval in approvals %}
<li>{{ approval.paf_reviewer_role.label }} - {% if approval.approved %}{% trans "Approved" %} {% else %}{% trans "Pending" %} {% endif %}
{% if approval.user %}({{ approval.user }}){% endif %}</li>
{% endfor %}
</ul>
{% else %}
<p>-</p>
<p></p>
{% endif %}

<!-- Supporting Documents with links-->
<p>
<b>{% trans "Supporting Documents" %}</b>
</p>
<!-- Reviews with names and dates -->
<h2>{% trans "Reviews" %}</h2>
<p><b>{% trans "Submission lead" %}:</b> {{ submission.lead }}</p>

<p><b>{% trans "Staff reviewers" %}</b></p>
{% if submission.reviews.by_staff %}
<ul>
{% for review in submission.reviews.by_staff %}
<li>
{{ review.author }}
{% if review.author.role %}
{% trans "as" %} {{ review.author.role }}
{% endif %}
- {{ review.created_at|date:"DATE_FORMAT" }}
</li>
{% endfor %}
</ul>
{% else %}
<p>–</p>
{% endif %}

<p><b>{% trans "Advisory council" %}</b></p>
{% if submission.reviews.by_reviewers %}
<ul>
{% for review in submission.reviews.by_reviewers %}
<li>{{ review.author }} - {{ review.created_at|date:"DATE_FORMAT" }}</li>
{% endfor %}
</ul>
{% else %}
<p>–</p>
{% endif %}

<!-- Supporting Documents with links -->
<h2>{% trans "Supporting Documents" %}</h2>

{% if supporting_documents %}
{% for document, document_link in supporting_documents.items %}
<p><a href="{{ document_link }}">{{ document }}</a></p>
{% endfor %}
<ul>
{% for document, document_link in supporting_documents.items %}
<li><a href="{{ document_link }}">{{ document }}</a></li>
{% endfor %}
</ul>
{% else %}
<p>-</p>
<p></p>
{% endif %}

<!-- Submission title with link-->
<p><b>{% trans "Submission" %}</b></p>
<p><big><b>{% trans "Application" %}</b></big></p>
<p><a href="{{ submission_link }}">{{ submission }}</a></p>

{% endblock %}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ <h4 class="mb-2">{% trans "Approvals" %}</h4>
{% endfor %}
</div>

<h4 class="mb-2">{% trans "Review" %}</h4>
<h4 class="mb-2">{% trans "Reviews" %}</h4>
<div class="card card--solid">
<p class="mt-0 mb-0 font-bold">{% trans "Submission lead" %}</p>
<p class="mt-2 mb-0">{{ project.submission.lead }}</p>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
{% extends "base-pdf.html" %}
{% load i18n %}

{% block page_header %}
<h1 class="title">
{{ org_name }} (Scope of Work | <a href="{{ project_link }}">{{ title }}</a>)
</h1>
{% endblock %}

{% block content %}
<h1>{{ org_name }} {% trans "Scope of Work (SOW)" %}</h1>
<p><b>{% trans "Project title" %}</b>: <a href="{{ project_link }}">{{ title }}</a></p>
<p><b>{% trans "Project ID" %}</b>: {{ id }}</p>

<hr>

<!-- PAF fields data in paragraph format-->
<!-- SOW fields data in paragraph format-->
{% for field_name, field_value in sow_data.items %}
<p><b>{{ field_name }}</b></p>
<p>{{ field_value|safe|default:"-" }}</p>
Expand Down
7 changes: 6 additions & 1 deletion hypha/apply/projects/views/project.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
staff_required,
)
from hypha.apply.users.roles import CONTRACTING_GROUP_NAME
from hypha.apply.utils.models import PDFPageSettings
from hypha.apply.utils.pdfs import render_as_pdf
from hypha.apply.utils.storage import PrivateMediaView
from hypha.apply.utils.views import DelegateableView, DelegatedViewMixin, ViewDispatcher
Expand Down Expand Up @@ -1856,13 +1857,16 @@ def get(self, request, *args, **kwargs):
context = {}
context["sow_data"] = self.get_sow_data_with_field(self.object)
context["org_name"] = settings.ORG_LONG_NAME
context["id"] = self.object.id
context["title"] = self.object.title
context["project_link"] = self.request.build_absolute_uri(
reverse("apply:projects:detail", kwargs={"pk": self.object.id})
)
template_path = "application_projects/sow_export.html"

if export_type == "pdf":
pdf_page_settings = PDFPageSettings.load(request_or_site=request)
context["pagesize"] = pdf_page_settings.download_page_size
context["show_footer"] = True
return render_as_pdf(
request=request,
Expand Down Expand Up @@ -1927,6 +1931,8 @@ def get(self, request, *args, **kwargs):
template_path = "application_projects/paf_export.html"

if export_type == "pdf":
pdf_page_settings = PDFPageSettings.load(request_or_site=request)
context["pagesize"] = pdf_page_settings.download_page_size
context["show_footer"] = True
return render_as_pdf(
request=request,
Expand Down Expand Up @@ -1972,7 +1978,6 @@ def get_paf_download_context(self):

context["approvals"] = self.object.paf_approvals.all()
context["paf_data"] = self.get_paf_data_with_field(self.object)
context["sow_data"] = self.get_sow_data_with_field(self.object)
context["submission"] = self.object.submission
context["submission_link"] = self.request.build_absolute_uri(
reverse(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.17 on 2024-12-13 10:33

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("apply_utils", "0002_remove_pdfpagesettings_site"),
]

operations = [
migrations.AlterField(
model_name="pdfpagesettings",
name="download_page_size",
field=models.CharField(
choices=[("A4", "A4"), ("legal", "Legal"), ("letter", "Letter")],
default="A4",
help_text="Page size of downloadable Project and Submission PDFs",
max_length=6,
),
),
]
2 changes: 1 addition & 1 deletion hypha/apply/utils/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Meta:

download_page_size = models.CharField(
choices=PAGE_SIZES,
default=LEGAL,
default=A4,
max_length=6,
help_text=_("Page size of downloadable Project and Submission PDFs"),
)
Expand Down
4 changes: 2 additions & 2 deletions hypha/apply/utils/pdfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,8 +494,8 @@ def render_as_pdf(
)
"""
if "pagesize" not in context:
pdf_settings = PDFPageSettings.load(request_or_site=request)
context["pagesize"] = pdf_settings.download_page_size
pdf_page_settings = PDFPageSettings.load(request_or_site=request)
context["pagesize"] = pdf_page_settings.download_page_size

context.setdefault("export_date", timezone.now())
context.setdefault("export_user", request.user if request else None)
Expand Down
41 changes: 13 additions & 28 deletions hypha/templates/base-pdf.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,50 +13,36 @@
{% block layout_style %}
<style type="text/css">
@page {
size: {{ pagesize|default:"A4" }};
margin-left: 2cm;
size: {{ pagesize|default:"A4" }} portrait;
margin-top: 1.5cm;
margin-right: 2cm;
margin-top: 1cm;
margin-bottom: 2cm;

@frame header {
-pdf-frame-content: page-header;
margin-top: 3cm;
margin-right: 2mm;
margin-bottom: 2cm;
margin-left: 1.2cm;
}
margin-bottom: 1.5cm;
margin-left: 2cm;

@frame footer {
-pdf-frame-content: page-footer;
bottom: 0cm;
height: 1cm;
margin-left: 1cm;
margin-right: 1cm;
height: 1cm;
}
}
</style>
{% endblock %}

<style type="text/css">
.title {
text-align: center;
font-size: 22px;
h1 {
font-size: 24px;
}
p {
font-size: 16px;
h2 {
font-size: 20px;
}
#page-width {
width: 100%;
p,
li {
font-size: 16px;
}
.align-left {
display: inline-block;
padding-left: 100px;
}
.align-right {
display: inline-block;
padding-right: 100px;
#page-footer {
font-size: 14px;
}
</style>

Expand Down Expand Up @@ -84,5 +70,4 @@
</div>
{% endif %}
</body>

</html>
Loading