mirror of
https://gitlab.com/brutaldon/brutaldon.git
synced 2024-11-02 16:37:19 -04:00
Add long post validation also to reply and redraft
This commit is contained in:
parent
620394ac3f
commit
43d4b6a30d
@ -465,12 +465,19 @@ def redraft(request, id):
|
|||||||
None)))
|
None)))
|
||||||
if form.cleaned_data['visibility'] == '':
|
if form.cleaned_data['visibility'] == '':
|
||||||
form.cleaned_data['visibility'] = request.session['user'].source.privacy
|
form.cleaned_data['visibility'] = request.session['user'].source.privacy
|
||||||
|
try:
|
||||||
mastodon.status_post(status=form.cleaned_data['status'],
|
mastodon.status_post(status=form.cleaned_data['status'],
|
||||||
visibility=form.cleaned_data['visibility'],
|
visibility=form.cleaned_data['visibility'],
|
||||||
spoiler_text=form.cleaned_data['spoiler_text'],
|
spoiler_text=form.cleaned_data['spoiler_text'],
|
||||||
media_ids=media_objects,
|
media_ids=media_objects,
|
||||||
in_reply_to_id=toot.in_reply_to_id)
|
in_reply_to_id=toot.in_reply_to_id)
|
||||||
mastodon.status_delete(id)
|
mastodon.status_delete(id)
|
||||||
|
except MastodonAPIError as error:
|
||||||
|
form.add_error("", "%s" % error.args[-1])
|
||||||
|
return render(request, 'main/redraft.html',
|
||||||
|
{'toot': toot, 'form': form, 'redraft': True,
|
||||||
|
'own_acct': request.session['user'],
|
||||||
|
'preferences': account.preferences})
|
||||||
return redirect(home)
|
return redirect(home)
|
||||||
else:
|
else:
|
||||||
return render(request, 'main/redraft.html',
|
return render(request, 'main/redraft.html',
|
||||||
@ -516,6 +523,8 @@ def reply(request, id):
|
|||||||
elif request.method == 'POST':
|
elif request.method == 'POST':
|
||||||
form = PostForm(request.POST, request.FILES)
|
form = PostForm(request.POST, request.FILES)
|
||||||
account, mastodon = get_usercontext(request)
|
account, mastodon = get_usercontext(request)
|
||||||
|
toot = mastodon.status(id)
|
||||||
|
context = mastodon.status_context(id)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
# create media objects
|
# create media objects
|
||||||
media_objects = []
|
media_objects = []
|
||||||
@ -527,15 +536,20 @@ def reply(request, id):
|
|||||||
description=request.POST.get('media_text_'
|
description=request.POST.get('media_text_'
|
||||||
+str(index),
|
+str(index),
|
||||||
None)))
|
None)))
|
||||||
|
try:
|
||||||
mastodon.status_post(status=form.cleaned_data['status'],
|
mastodon.status_post(status=form.cleaned_data['status'],
|
||||||
visibility=form.cleaned_data['visibility'],
|
visibility=form.cleaned_data['visibility'],
|
||||||
spoiler_text=form.cleaned_data['spoiler_text'],
|
spoiler_text=form.cleaned_data['spoiler_text'],
|
||||||
media_ids=media_objects,
|
media_ids=media_objects,
|
||||||
in_reply_to_id=id)
|
in_reply_to_id=id)
|
||||||
|
except MastodonAPIError as error:
|
||||||
|
form.add_error("", "%s" % error.args[-1])
|
||||||
|
return render(request, 'main/reply.html',
|
||||||
|
{'context': context, 'toot': toot, 'form': form, 'reply': True,
|
||||||
|
'own_acct': request.session['user'],
|
||||||
|
'preferences': account.preferences})
|
||||||
return redirect(thread, id)
|
return redirect(thread, id)
|
||||||
else:
|
else:
|
||||||
toot = mastodon.status(id)
|
|
||||||
context = mastodon.status_context(id)
|
|
||||||
return render(request, 'main/reply.html',
|
return render(request, 'main/reply.html',
|
||||||
{'context': context, 'toot': toot, 'form': form, 'reply': True,
|
{'context': context, 'toot': toot, 'form': form, 'reply': True,
|
||||||
'own_acct': request.session['user'],
|
'own_acct': request.session['user'],
|
||||||
|
Loading…
Reference in New Issue
Block a user