Verified Commit f3e8ac40 authored by Jakob Moser's avatar Jakob Moser
Browse files

Upgrade to latest version of pdf-generator

parent c1eeac68
Loading
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -55,9 +55,8 @@ coliverter examples/certification_aktiver_fachschaftler.json Robby_McRobotface_C

You can add new types of commitment certifications by completing the following steps:

1. Add a new class in the [`coliverter.certifications`](./src/coliverter/certifications) package.
2. Reference the class in [`coliverter.certifications.from_dict`](./src/coliverter/certifications/from_dict.py) in the `type ColiCertification` declaration (separated with `|`).
3. Add a new template in the [`coliverter.resources.templates.commitment_certification`](./src/coliverter/resources/templates/commitment_certification) package.
1. Add a new template in the [`coliverter.resources.templates.commitment_certification`](./src/coliverter/resources/templates/commitment_certification) package.
2. Reference the template in [`coliverter.certifications.ColiCertification`](./src/coliverter/certifications/ColiCertification.py).

For more details, you can roughly follow the [documentation of Schwalbe PDF generator](https://gitlab.com/schwalbe-hd/pdf-generator/-/blob/master/docs/add_certification_type.md?ref_type=heads) (you will need to adapt paths, but other than that, the documentation should be mostly applicable to the Coliverter as well).

+4 −4
Original line number Diff line number Diff line
[project]
name = "coliverter"
version = "0.5.1"
version = "0.5.2"
authors = [
  { name="Jakob Moser", email="moser@cl.uni-heidelberg.de" },
]
@@ -25,11 +25,11 @@ Issues = "https://gitlab.cl.uni-heidelberg.de/fachschaft/coliverter/-/issues"
requires = ["hatchling >= 1.26"]
build-backend = "hatchling.build"

[tool.uv.sources]
pdf-generator = { git = "https://gitlab.com/schwalbe-hd/pdf-generator.git" }

[dependency-groups]
dev = [
    "coverage>=7.12.0",
    "pytest>=9.0.2",
]

[tool.uv.sources]
pdf-generator = { git = "https://gitlab.com/schwalbe-hd/pdf-generator.git" }
+0 −20
Original line number Diff line number Diff line
from dataclasses import dataclass
from typing import ClassVar

from pdf_generator.commitment_certification.Certification import Certification
from pdf_generator.jinja.templates import fill_template
from babel.core import Locale

from coliverter.resources.templates.get_template import get_template


@dataclass(frozen=True)
class AwarenessCertification(Certification):
    required_office_kind_name: ClassVar[str] = "Awareness"

    def html(self, locale: Locale) -> str:
        return fill_template(
            get_template("commitment_certification/awareness", locale),
            locale,
            certification=self,
        )
+17 −0
Original line number Diff line number Diff line
from dataclasses import dataclass

from pdf_generator.commitment_certification.Certification import Certification


@dataclass(frozen=True)
class ColiCertification(Certification):

    @classmethod
    def get_template_name(cls, office_name: str, office_kind_name: str) -> str | None:
        match office_kind_name:
            case "Awareness":
                return "commitment_certification/awareness"
            case "Fachschaft":
                return "commitment_certification/fachschaft"

        return super().get_template_name(office_name, office_kind_name)
+0 −20
Original line number Diff line number Diff line
from dataclasses import dataclass
from typing import ClassVar

from pdf_generator.commitment_certification.Certification import Certification
from pdf_generator.jinja.templates import fill_template
from babel.core import Locale

from coliverter.resources.templates.get_template import get_template


@dataclass(frozen=True)
class FachschaftCertification(Certification):
    required_office_kind_name: ClassVar[str] = "Fachschaft"

    def html(self, locale: Locale) -> str:
        return fill_template(
            get_template("commitment_certification/fachschaft", locale),
            locale,
            certification=self,
        )
Loading