Implement better handling of click-through contracts
authorMagnus Hagander <magnus@hagander.net>
Wed, 26 Feb 2025 17:18:42 +0000 (18:18 +0100)
committerMagnus Hagander <magnus@hagander.net>
Mon, 28 Apr 2025 20:53:23 +0000 (22:53 +0200)
This generates an actual contract for click-through ("instantbuy with
contract") levels, replacing the signature with a static text saying
"Click-through agreement".

postgresqleu/confsponsor/util.py
postgresqleu/confsponsor/views.py
template.jinja/confsponsor/mail/sponsor_contract_instant.txt [new file with mode: 0644]
template/confsponsor/admin_sponsor_details.html
template/confsponsor/sponsor.html

index d37dd85592a39c04b5617c983d106429f3ea597c..c88d87e1f60f06a309d6dba298f865e623207d66 100644 (file)
@@ -174,5 +174,9 @@ def get_pdf_fields_for_conference(conference, sponsor=None, overrides={}):
         fields.append(
             ('static:euvat', sponsor.vatnumber if sponsor else overrides.get('static:euvat', 'Sponsor EU VAT number')),
         )
+    fields.extend([
+        ('static:clickthrough', overrides.get('static:clickthrough', 'Click-through agreement')),
+        ('static:clickthroughdate', str(sponsor.signupat.date()) if sponsor else overrides.get('static:clickthroughdate', 'Click-through date')),
+    ])
 
     return fields
index 4a52186ad53f6b0a504b2c3e70a468d2c33cee11..8106964805d3e4b2ae05d255755cd9b1d89f1a62 100644 (file)
@@ -218,7 +218,25 @@ def sponsor_view_mail(request, sponsorid, mailid):
 def sponsor_contractview(request, sponsorid):
     sponsor, is_admin = _get_sponsor_and_admin(sponsorid, request)
 
-    if not sponsor.contract.completed:
+    if not sponsor.level.contract:
+        # Should not happen
+        raise Http404("No contract at this level")
+
+    if sponsor.level.instantbuy:
+        # Click-through contract
+
+        resp = HttpResponse(content_type='application/pdf')
+        resp['Content-disposition'] = 'filename="%s.pdf"' % sponsor.name
+        resp.write(fill_pdf_fields(
+            sponsor.level.contract.contractpdf,
+            get_pdf_fields_for_conference(sponsor.conference, sponsor),
+            sponsor.level.contract.fieldjson,
+        ))
+        return resp
+
+    # Regular contract
+
+    if not (sponsor.contract and sponsor.contract.completed):
         raise Http404("Contract not completed")
 
     resp = HttpResponse(content_type='application/pdf')
@@ -368,7 +386,7 @@ def _generate_and_send_sponsor_contract(sponsor):
         send_sponsor_manager_email(
             sponsor,
             'Your contract for {}'.format(conference.conferencename),
-            'confsponsor/mail/sponsor_contract_manual.txt',
+            'confsponsor/mail/{}.txt'.format('sponsor_contract_instant' if level.instantbuy else 'sponsor_contract_manual'),
             {
                 'conference': conference,
                 'sponsor': sponsor,
@@ -517,6 +535,11 @@ def sponsor_signup(request, confurlname, levelurlname):
                 error = None
 
                 if level.instantbuy:
+                    if sponsor.level.contract:
+                        # Instantbuy levels that has a contract should get an implicit contract
+                        # attached to an email.
+                        _generate_and_send_sponsor_contract(sponsor)
+
                     mailstr += "Level does not require a signed contract. Verify the details and approve\nthe sponsorship using:\n\n{0}/events/sponsor/admin/{1}/{2}/".format(
                         settings.SITEBASE, conference.urlname, sponsor.id)
                 else:
@@ -922,6 +945,8 @@ def sponsor_contract_preview(request, contractid):
                 get_pdf_fields_for_conference(contract.conference, overrides={
                     'static:sponsor': 'PREVIEW ONLY - sponsor company name',
                     'static:euvat': 'PREVIEW ONLY - do not sign this contract',
+                    'static:clickthrough': 'PREVIEW ONLY - no signature',
+                    'static:clickthrougdate': 'PREVIEW ONLY',
                 }),
                 contract.fieldjson,
             )
diff --git a/template.jinja/confsponsor/mail/sponsor_contract_instant.txt b/template.jinja/confsponsor/mail/sponsor_contract_instant.txt
new file mode 100644 (file)
index 0000000..79f78f0
--- /dev/null
@@ -0,0 +1,10 @@
+Hello!
+
+You have signed up to be a sponsor of
+{{conference.conferencename}}
+for sponsorship level {{sponsor.level}}.
+
+This level uses a click-through contract model. Attached is a
+copy of the contract you agreed to by signing up.
+
+Thank you for your support of {{conference.conferencename}}!
index dc3c88d1270aae78bdbf930907be0ecd9a6749f7..371c3148ec91502fdc26910e4f9dcbe0d5367159 100644 (file)
     <th>Contract:</th>
     <td>
       {%if sponsor.level.instantbuy %}
-       No contract needed, level is "instant buy". <form class="inline-block-form" method="post" action="resendcontract/">{% csrf_token %}<input type="submit" class="btn btn-sm btn-default confirm-btn" value="Re-send contract anyway" data-confirm="Are you sure you want to re-send a new contract to this sponsor?{%if sponsor.signmethod == 0%} {{conference.contractprovider.implementation.resendprompt}}{%endif%} Note that the level is instant buy, instructions may be confusing!"></form>
+      {%if sponsor.level.contract %}
+      Click-through contract completed. <form class="inline-block-form" method="post" action="resendcontract/">{% csrf_token %}<input type="submit" class="btn btn-sm btn-default confirm-btn" value="Re-send contract anyway" data-confirm="Are you sure you want to re-send a new contract to this sponsor?{%if sponsor.signmethod == 0%} {{conference.contractprovider.implementation.resendprompt}}{%endif%}"></form>
+      {%else%}
+      No contract needed for this level.
+      {%endif%}
       {%else%}
        {%if sponsor.signmethod == 0%}
        Digital contract.<br/>
index 3bb92aaf1d6ea05f2f8e7aa238aa7dcc84f6fca3..da8f878eab14ef3c25e1b51680af4454745ff469 100644 (file)
     <th>Status:</th>
     <td>{%if sponsor.confirmed%}Confirmed ({{sponsor.confirmedat}}){%else%}<i>Awaiting confirmation</i>{%endif%}</td>
   </tr>
-{% if sponsor.confirmed %}
+{% if sponsor.confirmed and sponsor.level.contract %}
   <tr>
     <th>Contract:</th>
-    <td>{%if sponsor.signmethod == 0%}
+    <td>
+{% if sponsor.level.instantbuy %}
+      Click-through contract agreed to. <a href="contractview/" class="btn btn-outline-dark btn-sm">View copy of contract</a>
+{% else %}
+{%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 %}
+Manual contract.
+{% endif %}
+{% endif %}
 </td>
   </tr>
 {% endif %}