Make it possible for a sponsor to view signed contract
authorMagnus Hagander <magnus@hagander.net>
Wed, 26 Feb 2025 15:32:10 +0000 (16:32 +0100)
committerMagnus Hagander <magnus@hagander.net>
Fri, 11 Apr 2025 08:51:03 +0000 (10:51 +0200)
Once a contract is digitally sign we normally (unless something goes
wrong) store a copy of the PDF of the signed contract. This was already
visible on the admin page, but there is no reason not to let the sponsor
view their own contract as well.

Fixes #173

postgresqleu/confsponsor/urls.py
postgresqleu/confsponsor/views.py
template/confsponsor/sponsor.html

index fda5f266948883a652102be81555f1999960ce42..8a507aa51ebcbb0155db88a730a85f05aeca5a83 100644 (file)
@@ -18,6 +18,7 @@ urlpatterns = [
     re_path(r'^(\d+)/shipments/(\d+)/$', views.sponsor_shipment),
     re_path(r'^(\d+)/scanning/$', scanning.sponsor_scanning),
     re_path(r'^(\d+)/scanning/download.csv/$', scanning.sponsor_scanning_download),
+    re_path(r'^(\d+)/contractview/$', views.sponsor_contractview),
     re_path(r'^scanning/([a-z0-9]{64})/$', scanning.scanning_page),
     re_path(r'^scanning/([a-z0-9]{64})/api/(\w+)/$', scanning.scanning_api),
     re_path(r'^scanning-test/$', scanning.testcode),
index 48fc2fe8f7c65e0af52bc9af0926cea9978a9f0d..4a52186ad53f6b0a504b2c3e70a468d2c33cee11 100644 (file)
@@ -214,6 +214,19 @@ def sponsor_view_mail(request, sponsorid, mailid):
         })
 
 
+@login_required
+def sponsor_contractview(request, sponsorid):
+    sponsor, is_admin = _get_sponsor_and_admin(sponsorid, request)
+
+    if not sponsor.contract.completed:
+        raise Http404("Contract not completed")
+
+    resp = HttpResponse(content_type='application/pdf')
+    resp['Content-disposition'] = 'filename="%s.pdf"' % sponsor.name
+    resp.write(sponsor.contract.digisigncompleteddocument.completedpdf)
+    return resp
+
+
 @login_required
 @transaction.atomic
 def sponsor_purchase_voucher(request, sponsorid):
index d9bcf1ebc4c17bea6f5b80a01b165a4f5d1ced1f..3bb92aaf1d6ea05f2f8e7aa238aa7dcc84f6fca3 100644 (file)
     <th>Status:</th>
     <td>{%if sponsor.confirmed%}Confirmed ({{sponsor.confirmedat}}){%else%}<i>Awaiting confirmation</i>{%endif%}</td>
   </tr>
+{% if sponsor.confirmed %}
+  <tr>
+    <th>Contract:</th>
+    <td>{%if sponsor.signmethod == 0%}
+      Digital contract completed {{sponsor.contract.completed}}.
+{%if sponsor.contract.completed and sponsor.contract.has_completed_pdf %}<a href="contractview/" class="btn btn-outline-dark btn-sm">View signed contract</a>{%endif%}
+{% else %}
+Manual contract.{% endif %}
+</td>
+  </tr>
+{% endif %}
+  </tr>
 {%for name, handle in sponsor.social.items %}
   <tr>
     <th>{{name|title}}:</th>