Merge pull request #619 from mouse-reeve/goal-status-template

Uses template for generating goal status
This commit is contained in:
Mouse Reeve 2021-02-12 16:18:24 -08:00 committed by GitHub
commit c702e92b7d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 1 deletions

View file

@ -0,0 +1 @@
{% load humanize %}set a goal to read {{ goal.goal | intcomma }} book{{ goal.goal | pluralize }} in {{ goal.year }}

View file

@ -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
)