From 9151e93a5a5a298660ed81f3ba6b96b36866d8b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Bedna=C5=99=C3=ADk?= <jan.bednarik@gmail.com> Date: Tue, 5 May 2020 00:43:50 +0200 Subject: [PATCH] Fix expected behavior of User model --- pirates/models.py | 19 +++++++++++++++++++ setup.py | 2 +- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/pirates/models.py b/pirates/models.py index bceae18..651d15e 100644 --- a/pirates/models.py +++ b/pirates/models.py @@ -35,6 +35,9 @@ class AbstractUser(PermissionsMixin): ) date_joined = models.DateTimeField(_("date joined"), default=timezone.now) + USERNAME_FIELD = "sso_id" + REQUIRED_FIELDS = [] + class Meta: abstract = True verbose_name = _("user") @@ -49,6 +52,22 @@ class AbstractUser(PermissionsMixin): """Return the short name for the user.""" return self.first_name + @property + def is_anonymous(self): + """ + Always return False. This is a way of comparing User objects to + anonymous users. + """ + return False + + @property + def is_authenticated(self): + """ + Always return True. This is a way to tell if the user has been + authenticated in templates. + """ + return True + class AbstractTeam(models.Model): name = models.CharField(max_length=250, unique=True) diff --git a/setup.py b/setup.py index ea21acf..94bf339 100755 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ def read(fname): setup( name="pirates", - version="0.2.1", + version="0.3.0", license="MIT", description="Django app for users, teamds and groups.", long_description=read("README.md"), -- GitLab