diff options
author | luxagraf <sng@luxagraf.net> | 2021-08-14 09:39:08 -0400 |
---|---|---|
committer | luxagraf <sng@luxagraf.net> | 2021-08-14 09:39:08 -0400 |
commit | 9327e01c60b114286f5a142552aae60843029a48 (patch) | |
tree | 7f353f4299d50013c3b90f7b749fc6ab211b32d4 /app/accounts/views.py | |
parent | 0feb366b10cf422f12d18fa753e5d876120f4195 (diff) |
initial commit
Diffstat (limited to 'app/accounts/views.py')
-rw-r--r-- | app/accounts/views.py | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/app/accounts/views.py b/app/accounts/views.py new file mode 100644 index 0000000..75bb933 --- /dev/null +++ b/app/accounts/views.py @@ -0,0 +1,32 @@ +from django.views.generic import UpdateView, DetailView +from django.utils.decorators import method_decorator +from django.contrib.auth.decorators import login_required + +from .models import UserProfile +from .forms import ProfileForm + + +@method_decorator(login_required, name='dispatch') +class UpdateViewWithUser(UpdateView): + + def get_form_kwargs(self, **kwargs): + kwargs = super().get_form_kwargs(**kwargs) + kwargs.update({'user': self.request.user}) + return kwargs + + +class ProfileView(UpdateViewWithUser): + model = UserProfile + form_class = ProfileForm + template_name = "accounts/change-settings.html" + + def get_object(self): + return self.request.user.profile + + +class SettingsListView(DetailView): + model = UserProfile + template_name = "accounts/profile.html" + + def get_object(self): + return self.request.user.profile |