Skip to content

Commit

Permalink
fix rundown title template date format handling (#2487)
Browse files Browse the repository at this point in the history
add support for extra formats.

SDESK-7069
  • Loading branch information
petrjasek authored Nov 9, 2023
1 parent 2364ab2 commit 7dc389f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion apps/rundowns/rundowns.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
from . import privileges, rundown_items, types, templates, shows


def get_date_format(_format: Optional[str] = None) -> str:
"""Convert client format to python format."""
if not _format:
_format = "DD.MM.YYYY"
return _format.replace("DD", "%d").replace("MM", "%m").replace("YYYY", "%Y")


class RundownsResource(superdesk.Resource):
resource_title = "rundowns"

Expand Down Expand Up @@ -169,7 +176,7 @@ def create_from_template(
[
title_template.get("prefix") or "",
title_template.get("separator", " ").strip(),
date.strftime(title_template.get("date_format", "%d.%m.%Y")),
date.strftime(get_date_format(title_template.get("date_format"))),
],
)
)
Expand Down
2 changes: 1 addition & 1 deletion features/rundowns.feature
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ Feature: Rundowns
"title_template": {
"prefix": "Marker",
"separator": "//",
"date_format": "%d.%m.%Y"
"date_format": "DD.MM.YYYY"
},
"items": [
{
Expand Down

0 comments on commit 7dc389f

Please sign in to comment.