mirror of
https://github.com/jfmcbrayer/brutaldon
synced 2024-12-22 21:27:58 +01:00
Add replies
This commit is contained in:
parent
2f448242f8
commit
d6fe609b29
@ -1,6 +1,10 @@
|
||||
{% load widget_tweaks %}
|
||||
|
||||
{% if reply %}
|
||||
<form method="post" action="{% url "reply" toot.id %}">
|
||||
{% else %}
|
||||
<form method="post" action="{% url "toot" %}">
|
||||
{% endif %}
|
||||
{% csrf_token %}
|
||||
|
||||
<div class="field" >
|
||||
@ -21,10 +25,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if form.errors %}
|
||||
<div> {{ form.errors }} </div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
<input type="submit" class="button is-primary"
|
||||
|
24
brutaldon/templates/main/reply.html
Normal file
24
brutaldon/templates/main/reply.html
Normal file
@ -0,0 +1,24 @@
|
||||
{% extends "base.html" %}
|
||||
{% load humanize %}
|
||||
|
||||
{% block title %}
|
||||
Brutaldon - reply
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1 class="title">Thread</h1>
|
||||
{% for ancestor in context.ancestors %}
|
||||
<div class="box">
|
||||
{% include "main/toot_partial.html" with toot=ancestor %}
|
||||
</div>
|
||||
<hr class="is-hidden">
|
||||
{% endfor %}
|
||||
<div class="box active_context">
|
||||
{% include "main/toot_partial.html" with toot=toot %}
|
||||
</div>
|
||||
<hr class="is-hidden">
|
||||
<div class="box">
|
||||
{% include "main/post_partial.html" %}
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
@ -63,7 +63,7 @@
|
||||
<p class="is-hidden"></p>
|
||||
<nav class="level is-mobile">
|
||||
<div class="level-left">
|
||||
<a class="level-item">
|
||||
<a class="level-item" href="{% url "reply" toot.id %}">
|
||||
<span class="icon is-small"><i class="fa fa-reply">
|
||||
<span class="is-invisible">Reply</span>
|
||||
</i></span>
|
||||
|
@ -29,5 +29,6 @@ urlpatterns = [
|
||||
path('settings', views.settings, name='settings'),
|
||||
path('thread/<int:id>', views.thread, name='thread'),
|
||||
path('toot', views.toot, name="toot"),
|
||||
path('reply/<int:id>', views.reply, name='reply'),
|
||||
path('', views.home),
|
||||
]
|
||||
|
@ -165,3 +165,32 @@ def toot(request):
|
||||
'fullbrutalism': fullbrutalism_p(request)})
|
||||
else:
|
||||
return redirect(toot)
|
||||
|
||||
def reply(request, id):
|
||||
if request.method == 'GET':
|
||||
mastodon = get_mastodon(request)
|
||||
toot = mastodon.status(id)
|
||||
context = mastodon.status_context(id)
|
||||
initial_text = '@' + toot.account.acct + " "
|
||||
for mention in toot.mentions:
|
||||
initial_text.append('@' + mention.acct + " ")
|
||||
form = PostForm({'status': initial_text})
|
||||
return render(request, 'main/reply.html',
|
||||
{'context': context, 'toot': toot, 'form': form, 'reply':True,
|
||||
'fullbrutalism': fullbrutalism_p(request)})
|
||||
elif request.method == 'POST':
|
||||
form = PostForm(request.POST, request.FILES)
|
||||
if form.is_valid():
|
||||
# create media objects
|
||||
mastodon = get_mastodon(request)
|
||||
mastodon.status_post(status=form.cleaned_data['status'],
|
||||
visibility=form.cleaned_data['visibility'],
|
||||
spoiler_text=form.cleaned_data['spoiler_text'],
|
||||
in_reply_to_id=id)
|
||||
return redirect(thread, id)
|
||||
else:
|
||||
return render(request, 'main/reply.html',
|
||||
{'context': context, 'toot': toot, 'form': form, 'reply': True,
|
||||
'fullbrutalism': fullbrutalism_p(request)})
|
||||
else:
|
||||
return redirect(reply, id)
|
||||
|
Loading…
Reference in New Issue
Block a user