mirror of
http://git.carcosa.net/jmcbray/brutaldon.git
synced 2024-11-27 09:10:08 -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
|
||||
|
||||
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_boosts = models.BooleanField(default=False)
|
||||
timezone = models.CharField(max_length=80, blank=True, null=True,
|
||||
|
@ -2,40 +2,48 @@
|
||||
{% 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">
|
||||
<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 class="container">
|
||||
<h1 class="title">Settings</h1>
|
||||
<form method="post" action="{% url "settings" %}" >
|
||||
{% csrf_token %}
|
||||
</div>
|
||||
<div class="field">
|
||||
<label class="label" for="theme">{{ form.theme.label }}</label>
|
||||
<div class="control has-icons-left">
|
||||
<div class="select">
|
||||
{% render_field form.theme class+="select" %}
|
||||
<span class="icon is-small is-left">
|
||||
<span class="fa fa-clock-o"></span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="field">
|
||||
<input type="submit" name="submit"
|
||||
value="Save" class="button is-primary" >
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<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>
|
||||
<div class="field">
|
||||
<input type="submit" name="submit"
|
||||
value="Save" class="button is-primary" >
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
@ -355,7 +355,7 @@ def settings(request):
|
||||
if request.method == 'POST':
|
||||
form = PreferencesForm(request.POST)
|
||||
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_boosts = form.cleaned_data['filter_boosts']
|
||||
account.preferences.timezone = form.cleaned_data['timezone']
|
||||
@ -368,10 +368,11 @@ def settings(request):
|
||||
{'form' : form, 'account': account})
|
||||
else:
|
||||
request.session['timezone'] = account.preferences.timezone
|
||||
form = PreferencesForm(account.preferences)
|
||||
form = PreferencesForm(instance=account.preferences)
|
||||
return render(request, 'setup/settings.html',
|
||||
{ 'form': form,
|
||||
'account': account})
|
||||
'account': account,
|
||||
'preferences': account.preferences})
|
||||
|
||||
@never_cache
|
||||
@br_login_required
|
||||
|
Loading…
Reference in New Issue
Block a user