mirror of
http://git.carcosa.net/jmcbray/brutaldon.git
synced 2024-11-23 15:23:52 -05:00
Update settings view a bit; still in progress
This commit is contained in:
parent
b3444772fc
commit
12bce6638b
@ -6,7 +6,7 @@ from django.views.decorators.cache import never_cache, cache_page
|
||||
from django.urls import reverse
|
||||
from django.core.files.uploadhandler import TemporaryFileUploadHandler
|
||||
from brutaldon.forms import LoginForm, OAuthLoginForm, SettingsForm, PostForm
|
||||
from brutaldon.models import Client, Account
|
||||
from brutaldon.models import Client, Account, Preference, Theme
|
||||
from mastodon import Mastodon, AttribAccessDict, MastodonError
|
||||
from urllib import parse
|
||||
from pdb import set_trace
|
||||
@ -369,26 +369,22 @@ def user(request, username, prev=None, next=None):
|
||||
@never_cache
|
||||
@br_login_required
|
||||
def settings(request):
|
||||
account = Account.objects.get(username=username, client_id=client.id)
|
||||
if request.method == 'POST':
|
||||
form = SettingsForm(request.POST)
|
||||
if form.is_valid():
|
||||
request.session['fullbrutalism'] = form.cleaned_data['fullbrutalism']
|
||||
request.session['filter_replies'] = form.cleaned_data['filter_replies']
|
||||
request.session['filter_boosts'] = form.cleaned_data['filter_boosts']
|
||||
request.session['timezone'] = form.cleaned_data['timezone']
|
||||
account.preferences.theme = Theme.objects.get(form.cleaned_data['theme'])
|
||||
account.preferences.filter_replies = form.cleaned_data['filter_replies']
|
||||
account.preferences.filter_boosts = form.cleaned_data['filter_boosts']
|
||||
account.preferences.timezone = form.cleaned_data['timezone']
|
||||
account.preferences.save()
|
||||
account.save()
|
||||
return redirect(home)
|
||||
else:
|
||||
return render(request, 'setup/settings.html',
|
||||
{'form' : form,
|
||||
'own_acct': request.session['user'],
|
||||
'fullbrutalism': fullbrutalism_p(request)})
|
||||
{'form' : form, 'account': account})
|
||||
else:
|
||||
form = SettingsForm(initial={
|
||||
"fullbrutalism": fullbrutalism_p(request),
|
||||
"filter_replies": request.session.get('filter_replies', False),
|
||||
"filter_boosts": request.session.get('filter_boosts', False),
|
||||
"timezone": request.session.get('timezone', 'UTC')
|
||||
})
|
||||
form = SettingsForm(account.preferences)
|
||||
return render(request, 'setup/settings.html',
|
||||
{ 'form': form,
|
||||
'own_acct': request.session['user'],
|
||||
|
Loading…
Reference in New Issue
Block a user