mirror of
https://github.com/bookwyrm-social/bookwyrm.git
synced 2025-01-03 13:58:43 +00:00
Post status about goal
This commit is contained in:
parent
f3f6592e72
commit
ec79b10088
1 changed files with 18 additions and 0 deletions
|
@ -7,6 +7,8 @@ from django.utils.decorators import method_decorator
|
||||||
from django.views import View
|
from django.views import View
|
||||||
|
|
||||||
from bookwyrm import forms, models
|
from bookwyrm import forms, models
|
||||||
|
from bookwyrm.broadcast import broadcast
|
||||||
|
from bookwyrm.status import create_generated_note
|
||||||
from .helpers import get_user_from_username, object_visible_to_user
|
from .helpers import get_user_from_username, object_visible_to_user
|
||||||
|
|
||||||
|
|
||||||
|
@ -58,4 +60,20 @@ class Goal(View):
|
||||||
return TemplateResponse(request, 'goal.html', data)
|
return TemplateResponse(request, 'goal.html', data)
|
||||||
form.save()
|
form.save()
|
||||||
|
|
||||||
|
if request.POST.get('post-status'):
|
||||||
|
# create status, if appropraite
|
||||||
|
status = create_generated_note(
|
||||||
|
request.user,
|
||||||
|
'set a goal to read %d books in %d' % (goal.goal, goal.year),
|
||||||
|
privacy=goal.privacy
|
||||||
|
)
|
||||||
|
broadcast(
|
||||||
|
request.user,
|
||||||
|
status.to_create_activity(request.user),
|
||||||
|
software='bookwyrm')
|
||||||
|
|
||||||
|
# re-format the activity for non-bookwyrm servers
|
||||||
|
remote_activity = status.to_create_activity(request.user, pure=True)
|
||||||
|
broadcast(request.user, remote_activity, software='other')
|
||||||
|
|
||||||
return redirect(request.headers.get('Referer', '/'))
|
return redirect(request.headers.get('Referer', '/'))
|
||||||
|
|
Loading…
Reference in a new issue