Skip to content

Commit

Permalink
[#3573] Use SafeString for default values
Browse files Browse the repository at this point in the history
  • Loading branch information
Viicos authored and sergei-maertens committed Nov 16, 2023
1 parent 42ef697 commit 9718cb6
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ def uploaded_attachment_urls(context: template.Context) -> SafeString:


@register.simple_tag(takes_context=True)
def json_summary(context: template.Context) -> SafeString | dict:
def json_summary(context: template.Context) -> SafeString:
submission = context.get("_submission")
if not submission:
return {}
return SafeString({})

json_data = render_json(submission)

Expand All @@ -34,14 +34,14 @@ def json_summary(context: template.Context) -> SafeString | dict:


@register.simple_tag
def as_geo_json(value: list[float] | str) -> SafeString | dict:
def as_geo_json(value: list[float] | str) -> SafeString:
"""Output the ``value`` as a safe GeoJSON dumped string.
As of today, this only supports coordinates. This essentially does the same thing as
:func:`_transform_coordinates`, but for any map component.
"""
if not value:
return {}
return SafeString({})
data = {"type": "Point", "coordinates": [value[0], value[1]]}

return SafeString(json.dumps(data))

0 comments on commit 9718cb6

Please sign in to comment.