Skip to content

Commit

Permalink
Merge branch 'release/v4.6.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
pbanaszkiewicz committed Feb 8, 2025
2 parents ca4148a + f8e5104 commit 765dcd4
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 7 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ Then paste output from that script here.

-----------------------------------------------------------------

## v4.6.3 - 2025-02-08

### Bugfixes
* [Email] Fix: Pretty-Print Python data instead of JSON - [#2754](https://github.com/carpentries/amy/pull/2754) by @pbanaszkiewicz


## v4.6.2 - 2025-02-04

### Bugfixes
Expand Down
2 changes: 1 addition & 1 deletion amy/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "v4.6.2"
__version__ = "v4.6.3"
2 changes: 1 addition & 1 deletion amy/emails/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def map_single_api_uri_to_serialized_model(uri: str) -> dict[str, Any]:
model_class = find_model_class(model_name)
model_instance = find_model_instance(model_class, int(id_))
serializer = ModelToSerializerMapper[model_class]
return serializer(model_instance).data
return dict(serializer(model_instance).data)
except ValueError as exc:
raise ValueError(f"Failed to parse URI {uri!r}.") from exc

Expand Down
2 changes: 1 addition & 1 deletion amy/static/css/prism.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion amy/static/prism.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions amy/templates/emails/scheduled_email_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ <h1>
</tr>
<tr>
<th>Rendered context JSON:</th>
<td colspan="2"><pre><code class="language-json">{{ rendered_context|indent_json }}</code></pre></td>
<td colspan="2"><pre><code class="language-python">{{ rendered_context|pprint_py }}</code></pre></td>
</tr>
<tr>
<th>"To" header context JSON:</th>
<td colspan="2"><pre><code class="language-json">{{ scheduled_email.to_header_context_json|indent_json }}</code></pre></td>
</tr>
<tr>
<th>Rendered "To" header context JSON:</th>
<td colspan="2"><pre><code class="language-json">{{ rendered_to_header_context|indent_json }}</code></pre></td>
<td colspan="2"><pre><code class="language-python">{{ rendered_to_header_context|pprint_py }}</code></pre></td>
</tr>
</table>

Expand Down
7 changes: 7 additions & 0 deletions amy/workshops/templatetags/pprint.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import json
import pprint as stdlib_pprint
from typing import Any

from django import template
Expand All @@ -10,3 +11,9 @@
def indent_json(value: Any, indent: int = 2) -> str:
"""Indent string containing JSON."""
return json.dumps(value, sort_keys=True, indent=indent)


@register.filter
def pprint_py(value: Any) -> str:
"""Indent Python dict."""
return stdlib_pprint.pformat(value, width=40)
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "amy",
"version": "v4.6.2",
"version": "v4.6.3",
"description": "A web-based workshop administration application for The Carpentries",
"main": "index.js",
"repository": "git@github.com:carpentries/amy.git",
Expand Down

0 comments on commit 765dcd4

Please sign in to comment.