Compare commits

..

No commits in common. "f9f30e96c7749499de59a0377083c2b42633ea95" and "2bfff006ed2b3fbf80cdc750111c90869b1badc2" have entirely different histories.

6 changed files with 8 additions and 119 deletions

View File

@ -51,7 +51,6 @@ func GenerateCertificate(c *fiber.Ctx) error {
EventName: "Event name",
Footer: "Footer",
CurrencySymbol: "€",
Locale: certificateRequest.Locale,
}
result, err := generator.Execute(template, genConfig)

View File

@ -37,5 +37,4 @@ type CertificateTemplateOptions struct {
EventName string `json:"event_name"`
Footer string `json:"footer"`
CurrencySymbol string `json:"currency_symbol"`
Locale string `json:"locale"`
}

View File

@ -91,7 +91,7 @@ func (t *DefaultTemplater) SelectSponsorImage(id int) (string, error) {
return templates.GetImage(sponsors[id%len(sponsors)]), nil
}
func FormatUnit(unit string, locale string, amount int) (string, error) {
func FormatUnit(unit string, amount int) (string, error) {
var formatted string
switch unit {
case "kilometer":
@ -101,11 +101,7 @@ func FormatUnit(unit string, locale string, amount int) (string, error) {
default:
return "", errors.New("unknown unit")
}
if locale == "de" {
return strings.Replace(formatted, ".", ",", -1), nil
}
return formatted, nil
return strings.Replace(formatted, ".", ",", -1), nil
}
func (t *DefaultTemplater) StringToTemplate(templateString string) (*template.Template, error) {

View File

@ -56,7 +56,7 @@
{{ .MiddleName }} {{ .LastName }}
</p>
<p style="font-size: 1cm; margin-bottom: 0;">hat beim {{ $.EventName }}</p>
<p style="font-size: 2cm; font-weight: bold; margin-bottom: 0;">{{formatUnit "kilometer" $.Locale .Distance}}km</p>
<p style="font-size: 2cm; font-weight: bold; margin-bottom: 0;">{{formatUnit "kilometer" .Distance}}km</p>
<p style="font-size: 1cm;">für den guten Zweck zurückgelegt</p>
</main>
<footer class="certificate-footer">
@ -78,15 +78,15 @@
{{ range .DistanceDonations}}
<tr>
<td>{{ .Donor.FirstName }} {{ .Donor.MiddleName }} {{ .Donor.LastName }}</td>
<td>{{ formatUnit "euro" $.Locale .AmountPerDistance }} {{ $.CurrencySymbol }}</td>
<td>{{ formatUnit "euro" $.Locale .Amount }} {{ $.CurrencySymbol }}</td>
<td>{{ formatUnit "euro" .AmountPerDistance }} {{ $.CurrencySymbol }}</td>
<td>{{ formatUnit "euro" .Amount }} {{ $.CurrencySymbol }}</td>
</tr>
{{ end }}
</tbody>
<tfoot>
<td>Gesamt</td>
<td>{{ formatUnit "euro" $.Locale .TotalPerDistance }} {{ $.CurrencySymbol }}</td>
<td>{{ formatUnit "euro" $.Locale .TotalDonations }} {{ $.CurrencySymbol }}</td>
<td>{{ formatUnit "euro" .TotalPerDistance }} {{ $.CurrencySymbol }}</td>
<td>{{ formatUnit "euro" .TotalDonations }} {{ $.CurrencySymbol }}</td>
</tfoot>
</table>
</main>

File diff suppressed because one or more lines are too long

View File

@ -22,9 +22,6 @@ var ContractTemplateDe string
//go:embed certificate/de.html
var CertificateTemplateDe string
//go:embed certificate/en.html
var CertificateTemplateEn string
//go:embed images/sponsoringheader.base64
var ImageSponsoringHeaderBase64 string
@ -50,7 +47,7 @@ func GetTemplate(locale, templateName string) (string, error) {
case "certificate":
switch locale {
case "en":
return CertificateTemplateEn, nil
return ContractTemplateEn, nil
case "de":
return CertificateTemplateDe, nil
}