Skip to content

Commit

Permalink
Indicate the number of overlays available for each template
Browse files Browse the repository at this point in the history
  • Loading branch information
jacebrowning committed Nov 28, 2021
1 parent 43b9598 commit 8036e38
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Expand Up @@ -3,6 +3,7 @@
## 10.1

- Added support for multiple overlays via comma-separated URLs in the `style` parameter.
- Added `overlays` count in `/templates` responses.

## 10.0

Expand Down
1 change: 1 addition & 0 deletions app/models/template.py
Expand Up @@ -99,6 +99,7 @@ def jsonify(self, request: Request) -> dict:
"id": self.id,
"name": self.name,
"lines": len(self.text),
"overlays": 0 if self.overlay == [Overlay()] else len(self.overlay),
"styles": self.styles,
"blank": request.app.url_for(
"Memes.blank",
Expand Down
1 change: 1 addition & 0 deletions app/tests/test_views_templates.py
Expand Up @@ -29,6 +29,7 @@ def it_includes_metadata(expect, client, slash):
"id": "iw",
"name": "Insanity Wolf",
"lines": 2,
"overlays": 1,
"styles": ["default"],
"blank": "http://localhost:5000/images/iw.png",
"example": {
Expand Down
3 changes: 2 additions & 1 deletion app/views/templates.py
Expand Up @@ -13,6 +13,7 @@
"id": str,
"name": str,
"lines": int,
"overlays": int,
"styles": doc.List(str),
"blank": str,
"example": {
Expand Down Expand Up @@ -61,7 +62,7 @@ async def index(request):
)
@doc.response(404, str, description="Template not found")
async def detail(request, id):
template = Template.objects.get_or_none(id)
template: Template = Template.objects.get_or_none(id)
if template:
return response.json(template.jsonify(request))
raise exceptions.NotFound(f"Template not found: {id}")
Expand Down

0 comments on commit 8036e38

Please sign in to comment.