diff --git a/brutaldon/models.py b/brutaldon/models.py index 185aaf5..e0ff6e8 100644 --- a/brutaldon/models.py +++ b/brutaldon/models.py @@ -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, diff --git a/brutaldon/templates/setup/settings.html b/brutaldon/templates/setup/settings.html index 9205bad..eb8b79f 100644 --- a/brutaldon/templates/setup/settings.html +++ b/brutaldon/templates/setup/settings.html @@ -2,40 +2,48 @@ {% load widget_tweaks %} {% block content %} -

Settings

-
- {% csrf_token %} -
- -
-
- -
-
- -
-
- -
-
- {% render_field form.timezone class+="select" %} - - -
+
+

Settings

+ + {% csrf_token %} +
+
+ +
+
+ {% render_field form.theme class+="select" %} + +
-
-
-
- +
+ +
+ +
+
+ +
+
+ +
+
+ {% render_field form.timezone class+="select" %} + + +
+
+
+
+ +
+ +
{% endblock %} diff --git a/brutaldon/views.py b/brutaldon/views.py index 3231475..4ea1920 100644 --- a/brutaldon/views.py +++ b/brutaldon/views.py @@ -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