From 13d8e4fbf3f9b3a8e77bbd8058009ceb9ce2c4c2 Mon Sep 17 00:00:00 2001
From: "robinwilliam.hundt" <robinwilliam.hundt@stud.uni-goettingen.de>
Date: Sun, 5 Nov 2017 15:08:38 +0100
Subject: [PATCH] Changed UserAccount to provide access to Admin panel.

Added has_perm() and has_module_perm() to UserAccount model. Both return is_superuser . This allows superusers to access AdminPanel.

AdminPanel now displays usernames in User ListView.
---
 backend/core/admin.py  | 2 +-
 backend/core/models.py | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/backend/core/admin.py b/backend/core/admin.py
index 9302bfe2..9598b953 100644
--- a/backend/core/admin.py
+++ b/backend/core/admin.py
@@ -58,7 +58,7 @@ class UserAdmin(BaseUserAdmin):
     # The fields to be used in displaying the User model.
     # These override the definitions on the base UserAdmin
     # that reference specific fields on auth.User.
-    list_display = ('is_admin',)
+    list_display = ('username', 'is_admin',)
     list_filter = ('is_admin',)
     fieldsets = (
         (None, {'fields': ('password',)}),
diff --git a/backend/core/models.py b/backend/core/models.py
index f6913958..01218655 100644
--- a/backend/core/models.py
+++ b/backend/core/models.py
@@ -203,6 +203,12 @@ class UserAccount(AbstractBaseUser):
 
     USERNAME_FIELD = 'username'
 
+    def has_perm(self, *args):
+        return self.is_superuser
+
+    def has_module_perms(self, *args):
+        return self.is_superuser
+
     def get_associated_user(self):
         """ Returns the user type that is associated with this user obj """
         return \
-- 
GitLab