mirror of
http://git.carcosa.net/jmcbray/brutaldon.git
synced 2024-11-23 07:13:52 -05:00
Add posting support
This commit is contained in:
parent
3ce20bd91c
commit
2f448242f8
@ -26,14 +26,23 @@ class PostForm(forms.Form):
|
||||
sensitive=False, visibility=None, spoiler_text=None):"""
|
||||
status = forms.CharField(label="Toot", max_length=500, widget=forms.Textarea)
|
||||
visibility = forms.ChoiceField(label="Toot visibility", choices=PRIVACY_CHOICES)
|
||||
spoiler_text = forms.CharField(label="CW or Subject", max_length=500)
|
||||
media_file_1 = forms.FileField(label = "Media attachment 1")
|
||||
media_text_1 = forms.CharField(label="Describe media attachment 1.", max_length=500)
|
||||
media_file_2 = forms.FileField(label = "Media attachment 2")
|
||||
media_text_2 = forms.CharField(label="Describe media attachment 2.", max_length=500)
|
||||
media_file_3 = forms.FileField(label = "Media attachment 3")
|
||||
media_text_3 = forms.CharField(label="Describe media attachment 3.", max_length=500)
|
||||
media_file_4 = forms.FileField(label = "Media attachment 4")
|
||||
media_text_4 = forms.CharField(label="Describe media attachment 4.", max_length=500)
|
||||
media_rensitive = forms.BooleanField(label="Sensitive media?", required=False)
|
||||
spoiler_text = forms.CharField(label="CW or Subject", max_length=500,
|
||||
required=False)
|
||||
media_file_1 = forms.FileField(label = "Media attachment 1",
|
||||
required=False)
|
||||
media_text_1 = forms.CharField(label="Describe media attachment 1.", max_length=500,
|
||||
required=False)
|
||||
media_file_2 = forms.FileField(label = "Media attachment 2",
|
||||
required=False)
|
||||
media_text_2 = forms.CharField(label="Describe media attachment 2.", max_length=500,
|
||||
required=False)
|
||||
media_file_3 = forms.FileField(label = "Media attachment 3",
|
||||
required=False)
|
||||
media_text_3 = forms.CharField(label="Describe media attachment 3.", max_length=500,
|
||||
required=False)
|
||||
media_file_4 = forms.FileField(label = "Media attachment 4",
|
||||
required=False)
|
||||
media_text_4 = forms.CharField(label="Describe media attachment 4.", max_length=500,
|
||||
required=False)
|
||||
media_sensitive = forms.BooleanField(label="Sensitive media?", required=False)
|
||||
|
||||
|
10
brutaldon/templates/main/post.html
Normal file
10
brutaldon/templates/main/post.html
Normal file
@ -0,0 +1,10 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %} Brutaldon - toot {% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1 class="title" >Toot!</h1>
|
||||
<div class="box">
|
||||
{% include "main/post_partial.html" %}
|
||||
</div>
|
||||
{% endblock %}
|
32
brutaldon/templates/main/post_partial.html
Normal file
32
brutaldon/templates/main/post_partial.html
Normal file
@ -0,0 +1,32 @@
|
||||
{% load widget_tweaks %}
|
||||
|
||||
<form method="post" action="{% url "toot" %}">
|
||||
{% csrf_token %}
|
||||
|
||||
<div class="field" >
|
||||
<label class="label" >{{ form.status.label }}</label>
|
||||
<div class="control">
|
||||
{% render_field form.status class+="textarea is-primary" rows="4" %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="field">
|
||||
<label class="label" > {{ form.visibility.label }}</label>
|
||||
<div class="control">
|
||||
<div class="select">
|
||||
{% render_field form.visibility class+="select"%}
|
||||
<span class="icon is-small is-left" >
|
||||
<i class="fa address-card"></i>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% if form.errors %}
|
||||
<div> {{ form.errors }} </div>
|
||||
{% endif %}
|
||||
|
||||
|
||||
|
||||
<input type="submit" class="button is-primary"
|
||||
name="toot" value="Toot">
|
||||
</form>
|
@ -6,6 +6,12 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<h1 class="title">Post</h1>
|
||||
<div class="box">
|
||||
{% include "main/post_partial.html" %}
|
||||
</div>
|
||||
<hr class="is-hidden">
|
||||
|
||||
<h1 class="title">Your {{ timeline }} timeline</h1>
|
||||
{% for toot in toots %}
|
||||
<div class="box">
|
||||
|
@ -28,5 +28,6 @@ urlpatterns = [
|
||||
path('fed', views.fed, name='fed'),
|
||||
path('settings', views.settings, name='settings'),
|
||||
path('thread/<int:id>', views.thread, name='thread'),
|
||||
path('toot', views.toot, name="toot"),
|
||||
path('', views.home),
|
||||
]
|
||||
|
@ -41,8 +41,9 @@ def timeline(request, timeline='home', timeline_name='Home'):
|
||||
except NotLoggedInException:
|
||||
return redirect(login)
|
||||
data = mastodon.timeline(timeline)
|
||||
form = PostForm()
|
||||
return render(request, 'main/timeline.html',
|
||||
{'toots': data, 'timeline': timeline_name,
|
||||
{'toots': data, 'form': form, 'timeline': timeline_name,
|
||||
'fullbrutalism': fullbrutalism_p(request)})
|
||||
|
||||
def home(request):
|
||||
@ -146,7 +147,7 @@ def settings(request):
|
||||
def toot(request):
|
||||
if request.method == 'GET':
|
||||
form = PostForm()
|
||||
return render(request, 'main/toot.html',
|
||||
return render(request, 'main/post.html',
|
||||
{'form': form,
|
||||
'fullbrutalism': fullbrutalism_p(request)})
|
||||
elif request.method == 'POST':
|
||||
@ -159,7 +160,7 @@ def toot(request):
|
||||
spoiler_text=form.cleaned_data['spoiler_text'])
|
||||
return redirect(home)
|
||||
else:
|
||||
return render(request, 'main/toot.html',
|
||||
return render(request, 'main/post.html',
|
||||
{'form': form,
|
||||
'fullbrutalism': fullbrutalism_p(request)})
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user