mirror of https://gitlab.com/brutaldon/brutaldon
Add replies
This commit is contained in:
parent
2f448242f8
commit
d6fe609b29
|
@ -1,6 +1,10 @@
|
||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
|
{% if reply %}
|
||||||
|
<form method="post" action="{% url "reply" toot.id %}">
|
||||||
|
{% else %}
|
||||||
<form method="post" action="{% url "toot" %}">
|
<form method="post" action="{% url "toot" %}">
|
||||||
|
{% endif %}
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
|
|
||||||
<div class="field" >
|
<div class="field" >
|
||||||
|
@ -21,10 +25,6 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{% if form.errors %}
|
|
||||||
<div> {{ form.errors }} </div>
|
|
||||||
{% endif %}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<input type="submit" class="button is-primary"
|
<input type="submit" class="button is-primary"
|
||||||
|
|
|
@ -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 %}
|
|
@ -11,7 +11,7 @@
|
||||||
{% include "main/post_partial.html" %}
|
{% include "main/post_partial.html" %}
|
||||||
</div>
|
</div>
|
||||||
<hr class="is-hidden">
|
<hr class="is-hidden">
|
||||||
|
|
||||||
<h1 class="title">Your {{ timeline }} timeline</h1>
|
<h1 class="title">Your {{ timeline }} timeline</h1>
|
||||||
{% for toot in toots %}
|
{% for toot in toots %}
|
||||||
<div class="box">
|
<div class="box">
|
||||||
|
|
|
@ -63,7 +63,7 @@
|
||||||
<p class="is-hidden"></p>
|
<p class="is-hidden"></p>
|
||||||
<nav class="level is-mobile">
|
<nav class="level is-mobile">
|
||||||
<div class="level-left">
|
<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="icon is-small"><i class="fa fa-reply">
|
||||||
<span class="is-invisible">Reply</span>
|
<span class="is-invisible">Reply</span>
|
||||||
</i></span>
|
</i></span>
|
||||||
|
|
|
@ -29,5 +29,6 @@ urlpatterns = [
|
||||||
path('settings', views.settings, name='settings'),
|
path('settings', views.settings, name='settings'),
|
||||||
path('thread/<int:id>', views.thread, name='thread'),
|
path('thread/<int:id>', views.thread, name='thread'),
|
||||||
path('toot', views.toot, name="toot"),
|
path('toot', views.toot, name="toot"),
|
||||||
|
path('reply/<int:id>', views.reply, name='reply'),
|
||||||
path('', views.home),
|
path('', views.home),
|
||||||
]
|
]
|
||||||
|
|
|
@ -165,3 +165,32 @@ def toot(request):
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'fullbrutalism': fullbrutalism_p(request)})
|
||||||
else:
|
else:
|
||||||
return redirect(toot)
|
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