mirror of
http://git.carcosa.net/jmcbray/brutaldon.git
synced 2024-11-23 15:23:52 -05:00
Form and view for plain tooting.
Does not include media yet, although the form does.
This commit is contained in:
parent
bf3af37003
commit
3ce20bd91c
@ -1,5 +1,11 @@
|
||||
from django import forms
|
||||
|
||||
PRIVACY_CHOICES = (('public', 'Public'),
|
||||
('unlisted', 'Unlisted'),
|
||||
('private', 'Private'),
|
||||
('direct', 'Direct'))
|
||||
|
||||
|
||||
class LoginForm(forms.Form):
|
||||
instance = forms.CharField(label="Instance",
|
||||
max_length=256)
|
||||
@ -14,4 +20,20 @@ class SettingsForm(forms.Form):
|
||||
"""FULLBRUTALISM mode strips away most of the niceties of modern web design when
|
||||
brutaldon is viewed in a graphical browser. It has no effect in text-only browsers.""")
|
||||
|
||||
|
||||
|
||||
class PostForm(forms.Form):
|
||||
"""def status_post(self, status, in_reply_to_id=None, media_ids=None,
|
||||
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)
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from django.http import HttpResponse
|
||||
from django.shortcuts import render, redirect
|
||||
from brutaldon.forms import LoginForm, SettingsForm
|
||||
from brutaldon.forms import LoginForm, SettingsForm, PostForm
|
||||
from brutaldon.models import Client, Account
|
||||
from mastodon import Mastodon
|
||||
from urllib import parse
|
||||
@ -143,3 +143,24 @@ def settings(request):
|
||||
return render(request, 'setup/settings.html',
|
||||
{ 'form': form, 'fullbrutalism': fullbrutalism_p(request)})
|
||||
|
||||
def toot(request):
|
||||
if request.method == 'GET':
|
||||
form = PostForm()
|
||||
return render(request, 'main/toot.html',
|
||||
{'form': form,
|
||||
'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'])
|
||||
return redirect(home)
|
||||
else:
|
||||
return render(request, 'main/toot.html',
|
||||
{'form': form,
|
||||
'fullbrutalism': fullbrutalism_p(request)})
|
||||
else:
|
||||
return redirect(toot)
|
||||
|
Loading…
Reference in New Issue
Block a user