Org: Add possibility of adding year in holidays.#2593
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
| other_holidays = TextAreaField( | ||
| label=_('Other holidays'), | ||
| description=('31.10 - Halloween'), | ||
| description=('31.10 - Halloween / 31.10.2025 - Halloween'), |
There was a problem hiding this comment.
I would keep the old description intact, since this it was displayed as a placeholder and you can't have two entries on the same line.
If you want a more explanatory/verbose description, you're better off doing something like organisation_hierarchy where you give an example with a markdown code block. Long descriptions are rendered as markdown.
| for dt in self._other_dated: | ||
| if dt.year == year: | ||
| yield dt, self._other_dated[dt] | ||
|
|
There was a problem hiding this comment.
| for dt in self._other_dated: | |
| if dt.year == year: | |
| yield dt, self._other_dated[dt] | |
| for dt, descriptions in self._other_dated.items(): | |
| if dt.year == year: | |
| yield dt, descriptions | |
This is also true for the loop above, but we probably should just iterate through the items, instead of the keys
There was a problem hiding this comment.
Also this is kind of an edge-case, but if you define two holidays, one with a year and one without, that cover the same day of the year, you will now emit the same date twice, instead of one date that combines the description of the two. This is especially relevant if both variants have the same description.
In all we properly de-duplicate the dates, so this method should probably behave the same. It might then be also worth simplifying all by reusing other instead of duplicating those two loops, even if it is less efficient.
But we could also consider different ways to encode the same information, like changing _other to dict[tuple[int, int], dict[int | None, set[str]] (i.e. defaultdict(lambda: defaultdict(set))), you would then iterate through _other like before, but instead of directly getting descriptions you construct them for a given year by combining descriptions.get(None, set()) | descriptions.get(year, set()).
That way you retain the old single loop structure, you have to do a little bit of extra work to get the descriptions for a given year, but you have to do less work to de-duplicate the descriptions.
There was a problem hiding this comment.
Okay thanks I'll see what I can do.
Please fill in the commit message below and work through the checklist. You can delete parts that are not needed, e.g. the optional description, the link to a ticket or irrelevant options of the checklist.
Commit message
Org: Add possibility of adding year in holidays.
TYPE: Feature
LINK: OGC-2385
Checklist