From 2297fe133d1907092f1ea59670a92acdc702e032 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Fri, 12 Feb 2021 11:52:05 -0800 Subject: [PATCH] Uses template for generating goal status --- bookwyrm/templates/snippets/generated_status/goal.html | 1 + bookwyrm/views/goal.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 bookwyrm/templates/snippets/generated_status/goal.html diff --git a/bookwyrm/templates/snippets/generated_status/goal.html b/bookwyrm/templates/snippets/generated_status/goal.html new file mode 100644 index 000000000..3b4d0de4f --- /dev/null +++ b/bookwyrm/templates/snippets/generated_status/goal.html @@ -0,0 +1 @@ +{% load humanize %}set a goal to read {{ goal.goal | intcomma }} book{{ goal.goal | pluralize }} in {{ goal.year }} diff --git a/bookwyrm/views/goal.py b/bookwyrm/views/goal.py index 87404b100..4f2d1b6f4 100644 --- a/bookwyrm/views/goal.py +++ b/bookwyrm/views/goal.py @@ -2,6 +2,7 @@ from django.contrib.auth.decorators import login_required from django.http import HttpResponseNotFound from django.shortcuts import redirect +from django.template.loader import get_template from django.template.response import TemplateResponse from django.utils.decorators import method_decorator from django.views import View @@ -62,9 +63,10 @@ class Goal(View): if request.POST.get('post-status'): # create status, if appropraite + template = get_template('snippets/generated_status/goal.html') create_generated_note( request.user, - 'set a goal to read %d books in %d' % (goal.goal, goal.year), + template.render({'goal': goal, 'user': request.user}).strip(), privacy=goal.privacy )