mirror of
http://git.carcosa.net/jmcbray/brutaldon.git
synced 2024-11-27 09:10:08 -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):"""
|
sensitive=False, visibility=None, spoiler_text=None):"""
|
||||||
status = forms.CharField(label="Toot", max_length=500, widget=forms.Textarea)
|
status = forms.CharField(label="Toot", max_length=500, widget=forms.Textarea)
|
||||||
visibility = forms.ChoiceField(label="Toot visibility", choices=PRIVACY_CHOICES)
|
visibility = forms.ChoiceField(label="Toot visibility", choices=PRIVACY_CHOICES)
|
||||||
spoiler_text = forms.CharField(label="CW or Subject", max_length=500)
|
spoiler_text = forms.CharField(label="CW or Subject", max_length=500,
|
||||||
media_file_1 = forms.FileField(label = "Media attachment 1")
|
required=False)
|
||||||
media_text_1 = forms.CharField(label="Describe media attachment 1.", max_length=500)
|
media_file_1 = forms.FileField(label = "Media attachment 1",
|
||||||
media_file_2 = forms.FileField(label = "Media attachment 2")
|
required=False)
|
||||||
media_text_2 = forms.CharField(label="Describe media attachment 2.", max_length=500)
|
media_text_1 = forms.CharField(label="Describe media attachment 1.", max_length=500,
|
||||||
media_file_3 = forms.FileField(label = "Media attachment 3")
|
required=False)
|
||||||
media_text_3 = forms.CharField(label="Describe media attachment 3.", max_length=500)
|
media_file_2 = forms.FileField(label = "Media attachment 2",
|
||||||
media_file_4 = forms.FileField(label = "Media attachment 4")
|
required=False)
|
||||||
media_text_4 = forms.CharField(label="Describe media attachment 4.", max_length=500)
|
media_text_2 = forms.CharField(label="Describe media attachment 2.", max_length=500,
|
||||||
media_rensitive = forms.BooleanField(label="Sensitive media?", required=False)
|
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 %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% 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>
|
<h1 class="title">Your {{ timeline }} timeline</h1>
|
||||||
{% for toot in toots %}
|
{% for toot in toots %}
|
||||||
<div class="box">
|
<div class="box">
|
||||||
|
@ -28,5 +28,6 @@ urlpatterns = [
|
|||||||
path('fed', views.fed, name='fed'),
|
path('fed', views.fed, name='fed'),
|
||||||
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('', views.home),
|
path('', views.home),
|
||||||
]
|
]
|
||||||
|
@ -41,8 +41,9 @@ def timeline(request, timeline='home', timeline_name='Home'):
|
|||||||
except NotLoggedInException:
|
except NotLoggedInException:
|
||||||
return redirect(login)
|
return redirect(login)
|
||||||
data = mastodon.timeline(timeline)
|
data = mastodon.timeline(timeline)
|
||||||
|
form = PostForm()
|
||||||
return render(request, 'main/timeline.html',
|
return render(request, 'main/timeline.html',
|
||||||
{'toots': data, 'timeline': timeline_name,
|
{'toots': data, 'form': form, 'timeline': timeline_name,
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'fullbrutalism': fullbrutalism_p(request)})
|
||||||
|
|
||||||
def home(request):
|
def home(request):
|
||||||
@ -146,7 +147,7 @@ def settings(request):
|
|||||||
def toot(request):
|
def toot(request):
|
||||||
if request.method == 'GET':
|
if request.method == 'GET':
|
||||||
form = PostForm()
|
form = PostForm()
|
||||||
return render(request, 'main/toot.html',
|
return render(request, 'main/post.html',
|
||||||
{'form': form,
|
{'form': form,
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'fullbrutalism': fullbrutalism_p(request)})
|
||||||
elif request.method == 'POST':
|
elif request.method == 'POST':
|
||||||
@ -159,7 +160,7 @@ def toot(request):
|
|||||||
spoiler_text=form.cleaned_data['spoiler_text'])
|
spoiler_text=form.cleaned_data['spoiler_text'])
|
||||||
return redirect(home)
|
return redirect(home)
|
||||||
else:
|
else:
|
||||||
return render(request, 'main/toot.html',
|
return render(request, 'main/post.html',
|
||||||
{'form': form,
|
{'form': form,
|
||||||
'fullbrutalism': fullbrutalism_p(request)})
|
'fullbrutalism': fullbrutalism_p(request)})
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user