From 48e3f88b878635faf4a33c5dc4e903258d90bf35 Mon Sep 17 00:00:00 2001 From: Skia Date: Thu, 26 Nov 2015 16:32:56 +0100 Subject: [PATCH] Improve user views --- core/models.py | 6 +++ core/templates/core/base.html | 2 +- core/templates/core/user.html | 32 -------------- core/templates/core/user_detail.html | 26 ++++++++++++ core/templates/core/user_edit.html | 14 +++++++ core/templates/core/user_groups.html | 14 +++++++ core/templates/core/user_list.html | 15 +++++++ core/urls.py | 7 ++-- core/views/forms.py | 37 ++++------------- core/views/user.py | 62 ++++++++++++++-------------- 10 files changed, 117 insertions(+), 98 deletions(-) delete mode 100644 core/templates/core/user.html create mode 100644 core/templates/core/user_detail.html create mode 100644 core/templates/core/user_edit.html create mode 100644 core/templates/core/user_groups.html create mode 100644 core/templates/core/user_list.html diff --git a/core/models.py b/core/models.py index 18abe694..373fbfb4 100644 --- a/core/models.py +++ b/core/models.py @@ -63,6 +63,12 @@ class User(AbstractBaseUser, PermissionsMixin): verbose_name = _('user') verbose_name_plural = _('users') + def get_absolute_url(self): + """ + This is needed for black magic powered UpdateView's children + """ + return reverse('core:user_profile', kwargs={'user_id': self.pk}) + def __str__(self): return self.username diff --git a/core/templates/core/base.html b/core/templates/core/base.html index d7ff9f2a..cbb7b8a2 100644 --- a/core/templates/core/base.html +++ b/core/templates/core/base.html @@ -10,7 +10,7 @@ {% block header %} {% if user.is_authenticated %}Hello, {{ user.username }}!{% endif %}