Merge pull request 'Configurable sponsoring disclaimer feature/33-disclaimer' (#34) from feature/33-disclaimer into dev
All checks were successful
continuous-integration/drone/push Build is passing

Reviewed-on: #34
This commit is contained in:
Nicolai Ort 2021-02-20 15:18:55 +00:00
commit e9d3574599
4 changed files with 10 additions and 8 deletions

View File

@ -36,6 +36,7 @@ The basic generation mechanism makes the templates and routes interchangeable (i
| SPONSORING_RECEIPT_MINIMUM_AMOUNT | String | "10" | The mimimum total donation amount a sponsor has to donate to be able to receive a donation receipt - used to generate pdf text. | SPONSORING_RECEIPT_MINIMUM_AMOUNT | String | "10" | The mimimum total donation amount a sponsor has to donate to be able to receive a donation receipt - used to generate pdf text.
| SPONOR_LOGOS | Array<String> | Empty png | The sponsor images you want to loop through. You can provide them via http url, local file or base64-encoded image. | SPONOR_LOGOS | Array<String> | Empty png | The sponsor images you want to loop through. You can provide them via http url, local file or base64-encoded image.
| API_KEY | String(min length: 64) | Random generated string | The api key you want to use for auth (query-param `key`), has to be at least 64 chars long. | API_KEY | String(min length: 64) | Random generated string | The api key you want to use for auth (query-param `key`), has to be at least 64 chars long.
| DISCLAIMER_TEXT | String | N/A | A disclaimer that will get displayed on the bottom of each sponsoring contract. R/N You can only provide the disclaimer for one language.
## Templates ## Templates
> The document server uses html templates to generate various pdf documents. > The document server uses html templates to generate various pdf documents.

View File

@ -121,7 +121,7 @@ export class PdfCreator {
await i18next.changeLanguage(locale); await i18next.changeLanguage(locale);
const template_source = fs.readFileSync(`${this.templateDir}/sponsoring_contract.html`, 'utf8'); const template_source = fs.readFileSync(`${this.templateDir}/sponsoring_contract.html`, 'utf8');
const template = Handlebars.compile(template_source); const template = Handlebars.compile(template_source);
let result = template({ runners, codeformat }); let result = template({ runners, codeformat, disclaimer: config.disclaimer_text });
result = await awaitAsyncHandlebarHelpers(result); result = await awaitAsyncHandlebarHelpers(result);
const pdf = await this.renderPdf(result, { format: "A5", landscape: true }); const pdf = await this.renderPdf(result, { format: "A5", landscape: true });
return pdf return pdf

View File

@ -12,6 +12,7 @@ export const config = {
codeformat: process.env.CODEFORMAT || "qrcode", codeformat: process.env.CODEFORMAT || "qrcode",
sponor_logos: getSponsorLogos(), sponor_logos: getSponsorLogos(),
api_key: getApiKey(), api_key: getApiKey(),
disclaimer_text: process.env.DISCLAIMER_TEXT || "",
} }
let errors = 0 let errors = 0
if (typeof config.internal_port !== "number") { if (typeof config.internal_port !== "number") {

View File

@ -68,8 +68,8 @@
<p style="font-size: x-small; display: block;">{{__ "group"}}</p> <p style="font-size: x-small; display: block;">{{__ "group"}}</p>
</div> </div>
</div> </div>
<p>{{__ "sponsoring_amount_per_distance"}}</p> <p style="margin-top: -0.5rem">{{__ "sponsoring_amount_per_distance"}}</p>
<div class="columns"> <div class="columns" style="margin-top: -1rem;">
<div class="column is-6"> <div class="column is-6">
<span style="border-bottom: 1px solid; width: 100%; display: block;"></span> <span style="border-bottom: 1px solid; width: 100%; display: block;"></span>
<p style="font-size: x-small; display: block;">{{__ "lastname"}}</p> <p style="font-size: x-small; display: block;">{{__ "lastname"}}</p>
@ -79,9 +79,9 @@
<p style="font-size: x-small; display: block;">{{__ "firstname"}}</p> <p style="font-size: x-small; display: block;">{{__ "firstname"}}</p>
</div> </div>
</div> </div>
<p style="font-size: medium;">{{__ "address"}} ({{__ "sponsor"}})</p> <p style="font-size: medium; margin-top: -0.5rem;">{{__ "address"}} ({{__ "sponsor"}})</p>
<p style="font-size: x-small;">({{__ "sponsoring_address_condition"}})</p> <p style="font-size: x-small;">({{__ "sponsoring_address_condition"}})</p>
<div class="columns"> <div class="columns" style="margin-top: -1rem;">
<div class="column is-8"> <div class="column is-8">
<span style="border-bottom: 1px solid; width: 100%; display: block;"></span> <span style="border-bottom: 1px solid; width: 100%; display: block;"></span>
<p style="font-size: x-small; display: block;">{{__ "street"}}</p> <p style="font-size: x-small; display: block;">{{__ "street"}}</p>
@ -91,7 +91,7 @@
<p style="font-size: x-small; display: block;">{{__ "house_number"}}</p> <p style="font-size: x-small; display: block;">{{__ "house_number"}}</p>
</div> </div>
</div> </div>
<div class="columns"> <div class="columns" style="margin-top: -1rem;">
<div class="column is-4"> <div class="column is-4">
<span style="border-bottom: 1px solid; width: 100%; display: block;"></span> <span style="border-bottom: 1px solid; width: 100%; display: block;"></span>
<p style="font-size: x-small; display: block;">{{__ "postalcode"}}</p> <p style="font-size: x-small; display: block;">{{__ "postalcode"}}</p>
@ -101,8 +101,7 @@
<p style="font-size: x-small; display: block;">{{__ "city"}}</p> <p style="font-size: x-small; display: block;">{{__ "city"}}</p>
</div> </div>
</div> </div>
<br> <div class="columns" style="margin-top: -1rem;">
<div class="columns">
<div class="column is-7"> <div class="column is-7">
<span style="border-bottom: 1px solid; width: 100%; display: block;"></span> <span style="border-bottom: 1px solid; width: 100%; display: block;"></span>
<p style="font-size: x-small; display: block;">{{__ "location"}}, {{__ "date"}}</p> <p style="font-size: x-small; display: block;">{{__ "location"}}, {{__ "date"}}</p>
@ -112,6 +111,7 @@
<p style="font-size: x-small; display: block;">{{__ "signature"}}</p> <p style="font-size: x-small; display: block;">{{__ "signature"}}</p>
</div> </div>
</div> </div>
<p style="font-size: xx-small; overflow: hidden; height: 4rem; text-align: center;">{{../disclaimer}}</p>
</div> </div>
</div> </div>
{{/each}} {{/each}}