mirror of
https://gitlab.com/brutaldon/brutaldon.git
synced 2024-12-04 14:46:24 -05:00
Fix up settings view, form, and model
This commit is contained in:
parent
26cb87b73e
commit
6bb4a428d7
@ -25,7 +25,7 @@ class Theme(models.Model):
|
|||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
class Preference(models.Model):
|
class Preference(models.Model):
|
||||||
theme = models.ForeignKey(Theme, models.SET_NULL, null=True)
|
theme = models.ForeignKey(Theme, models.CASCADE, null=False, default=1)
|
||||||
filter_replies = models.BooleanField(default=False)
|
filter_replies = models.BooleanField(default=False)
|
||||||
filter_boosts = models.BooleanField(default=False)
|
filter_boosts = models.BooleanField(default=False)
|
||||||
timezone = models.CharField(max_length=80, blank=True, null=True,
|
timezone = models.CharField(max_length=80, blank=True, null=True,
|
||||||
|
@ -2,40 +2,48 @@
|
|||||||
{% load widget_tweaks %}
|
{% load widget_tweaks %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h1 class="title">Settings</h1>
|
<div class="container">
|
||||||
<form method="post" action="{% url "settings" %}" >
|
<h1 class="title">Settings</h1>
|
||||||
{% csrf_token %}
|
<form method="post" action="{% url "settings" %}" >
|
||||||
<div class="field">
|
{% csrf_token %}
|
||||||
<label class="label checkbox">
|
</div>
|
||||||
{% render_field form.fullbrutalism %}
|
<div class="field">
|
||||||
{{ form.fullbrutalism.label }}
|
<label class="label" for="theme">{{ form.theme.label }}</label>
|
||||||
</label>
|
<div class="control has-icons-left">
|
||||||
</div>
|
<div class="select">
|
||||||
<div class="field">
|
{% render_field form.theme class+="select" %}
|
||||||
<label class="label checkbox">
|
<span class="icon is-small is-left">
|
||||||
{% render_field form.filter_replies %}
|
<span class="fa fa-clock-o"></span>
|
||||||
{{ form.filter_replies.label }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<label class="label checkbox"">
|
|
||||||
{% render_field form.filter_boosts %}
|
|
||||||
{{ form.filter_boosts.label }}
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="field">
|
|
||||||
<label class="label" for="timezone">{{ form.timezone.label }}</label>
|
|
||||||
<div class="control has-icons-left">
|
|
||||||
<div class="select">
|
|
||||||
{% render_field form.timezone class+="select" %}
|
|
||||||
<span class="icon is-small is-left">
|
|
||||||
<span class="fa fa-clock-o"></span>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="field">
|
</div>
|
||||||
<input type="submit" name="submit"
|
|
||||||
value="Save" class="button is-primary" >
|
<div class="field">
|
||||||
|
<label class="label checkbox">
|
||||||
|
{% render_field form.filter_replies %}
|
||||||
|
{{ form.filter_replies.label }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label class="label checkbox"">
|
||||||
|
{% render_field form.filter_boosts %}
|
||||||
|
{{ form.filter_boosts.label }}
|
||||||
|
</label>
|
||||||
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<label class="label" for="timezone">{{ form.timezone.label }}</label>
|
||||||
|
<div class="control has-icons-left">
|
||||||
|
<div class="select">
|
||||||
|
{% render_field form.timezone class+="select" %}
|
||||||
|
<span class="icon is-small is-left">
|
||||||
|
<span class="fa fa-clock-o"></span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</div>
|
||||||
|
<div class="field">
|
||||||
|
<input type="submit" name="submit"
|
||||||
|
value="Save" class="button is-primary" >
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
@ -355,7 +355,7 @@ def settings(request):
|
|||||||
if request.method == 'POST':
|
if request.method == 'POST':
|
||||||
form = PreferencesForm(request.POST)
|
form = PreferencesForm(request.POST)
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
account.preferences.theme = Theme.objects.get(form.cleaned_data['theme'])
|
account.preferences.theme =form.cleaned_data['theme']
|
||||||
account.preferences.filter_replies = form.cleaned_data['filter_replies']
|
account.preferences.filter_replies = form.cleaned_data['filter_replies']
|
||||||
account.preferences.filter_boosts = form.cleaned_data['filter_boosts']
|
account.preferences.filter_boosts = form.cleaned_data['filter_boosts']
|
||||||
account.preferences.timezone = form.cleaned_data['timezone']
|
account.preferences.timezone = form.cleaned_data['timezone']
|
||||||
@ -368,10 +368,11 @@ def settings(request):
|
|||||||
{'form' : form, 'account': account})
|
{'form' : form, 'account': account})
|
||||||
else:
|
else:
|
||||||
request.session['timezone'] = account.preferences.timezone
|
request.session['timezone'] = account.preferences.timezone
|
||||||
form = PreferencesForm(account.preferences)
|
form = PreferencesForm(instance=account.preferences)
|
||||||
return render(request, 'setup/settings.html',
|
return render(request, 'setup/settings.html',
|
||||||
{ 'form': form,
|
{ 'form': form,
|
||||||
'account': account})
|
'account': account,
|
||||||
|
'preferences': account.preferences})
|
||||||
|
|
||||||
@never_cache
|
@never_cache
|
||||||
@br_login_required
|
@br_login_required
|
||||||
|
Loading…
Reference in New Issue
Block a user