Add a settings page, controlling whether FULLBRUTALISM is used

This commit is contained in:
Jason McBrayer 2018-04-25 16:45:46 -04:00
parent ba3cc9bbd9
commit 0594fda487
6 changed files with 52 additions and 1 deletions

View File

@ -7,3 +7,11 @@ class LoginForm(forms.Form):
max_length=256) max_length=256)
password = forms.CharField(widget=forms.PasswordInput()) password = forms.CharField(widget=forms.PasswordInput())
class SettingsForm(forms.Form):
fullbrutalism = forms.BooleanField(label="Use FULLBRUTALISM mode?",
required=False,
help_text=
"""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.""")

View File

@ -172,11 +172,21 @@ img {
.title { .title {
font-size: 3ex; font-size: 3ex;
font-weight: bold; font-weight: bold;
margin-top: 1ex;
margin-bottom: 1ex;
} }
.subtitle { .subtitle {
font-size: 1.5ex; font-size: 1.5ex;
font-weight: bold; font-weight: bold;
margin-top: 0.25ex;
margin-bottom: 0.25ex;
} }
.toot { .toot {
clear: both; clear: both;
} }
.box {
padding: 4px;
margin: 4px;
border: 8px ridge #CCC;
}

View File

@ -36,6 +36,7 @@
<a class="navbar-item" href="{% url "fed" %}">Federated</a> <a class="navbar-item" href="{% url "fed" %}">Federated</a>
</div> </div>
<div class="navbar-end" > <div class="navbar-end" >
<a class="navbar-item" href="{% url "settings" %}">Settings</a>
<a class="navbar-item" href="{% url "logout" %}">Log out</a> <a class="navbar-item" href="{% url "logout" %}">Log out</a>
</div> </div>
</div> </div>

View File

@ -0,0 +1,19 @@
{% extends "base.html" %}
{% load widget_tweaks %}
{% block content %}
<h1 class="title">Settings</h1>
<form method="post" action="{% url "settings" %}" >
{% csrf_token %}
<div class="field">
<label class="label checkbox">
{% render_field form.fullbrutalism %}
{{ form.fullbrutalism.label }}
</label>
</div>
<div class="field">
<input type="submit" name="submit"
value="Save" class="button is-primary" >
</div>
</form>
{% endblock %}

View File

@ -26,5 +26,6 @@ urlpatterns = [
path('note', views.note, name='note'), path('note', views.note, name='note'),
path('local', views.local, name='local'), path('local', views.local, name='local'),
path('fed', views.fed, name='fed'), path('fed', views.fed, name='fed'),
path('settings', views.settings, name='settings'),
path('', views.home), path('', views.home),
] ]

View File

@ -1,6 +1,6 @@
from django.http import HttpResponse from django.http import HttpResponse
from django.shortcuts import render, redirect from django.shortcuts import render, redirect
from brutaldon.forms import LoginForm from brutaldon.forms import LoginForm, SettingsForm
from brutaldon.models import Client, Account from brutaldon.models import Client, Account
from mastodon import Mastodon from mastodon import Mastodon
import datetime import datetime
@ -105,3 +105,15 @@ def local(request):
def fed(request): def fed(request):
return render(request, 'main/timeline.html', {'timeline': 'Federated'}) return render(request, 'main/timeline.html', {'timeline': 'Federated'})
def settings(request):
if request.method == 'POST':
form = SettingsForm(request.POST)
if form.is_valid():
request.session['fullbrutalism'] = form.cleaned_data['fullbrutalism']
return redirect(home)
else:
return render(request, 'setup/settings.html', {'form' : form })
else:
form = SettingsForm(request.session)
return render(request, 'setup/settings.html', { 'form': form })