From fea88a541e8f4b867b36a32c55965d2c297a0c9e Mon Sep 17 00:00:00 2001 From: Jason McBrayer Date: Sun, 26 Aug 2018 18:11:03 -0400 Subject: [PATCH] Update settings view to use preferences system --- brutaldon/models.py | 2 +- brutaldon/views.py | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/brutaldon/models.py b/brutaldon/models.py index d150270..185aaf5 100644 --- a/brutaldon/models.py +++ b/brutaldon/models.py @@ -32,7 +32,7 @@ class Preference(models.Model): choices=timezones, default='UTC') class Account(models.Model): - username = models.EmailField() + username = models.EmailField(unique=True) email = models.EmailField(null=True, blank=True) django_user = models.ForeignKey(settings.AUTH_USER_MODEL, models.CASCADE, null=True) access_token = models.CharField(null=True, blank=True, max_length=2048) diff --git a/brutaldon/views.py b/brutaldon/views.py index 1ae5c65..c9ee772 100644 --- a/brutaldon/views.py +++ b/brutaldon/views.py @@ -350,7 +350,7 @@ 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) + account = Account.objects.get(username=request.session['username']) if request.method == 'POST': form = PreferencesForm(request.POST) if form.is_valid(): @@ -368,8 +368,7 @@ def settings(request): form = PreferencesForm(account.preferences) return render(request, 'setup/settings.html', { 'form': form, - 'own_acct': request.session['user'], - 'fullbrutalism': fullbrutalism_p(request)}) + 'account': account}) @never_cache @br_login_required