While the admin can't really be used for anything yet, #70 will introduce the
need for an interface to create and modify events. By utilizing the Django
admin, we get that pretty much for free.
In order to make this happen, though, a few changes are required. First, we need
a way to distinguish admins from other users. This is being handled through a
new User.is_staff attribute. Next, we need to use a custom user manager class.
CustomUserManager.create_user and CustomUserManager.create_superuser are
being added to handle registering new users. And some authorization-related
attributes and methods are being added to User. For now, authorization is
determined solely by whether or not the user is an admin.
After these changes, the password validators are being removed to simplify using
the createsuperuser management command (which is being
exposed through tox). The command will still require providing a password, but
removing the validators will allow the user to enter a simpler password (since
it's just going to be thrown away).
Finally, the URL for the admin's login page is being redirected to the magic
link-based login view we're using in the public portion of the site.
While the admin can't really be used for anything yet, #70 will introduce the need for an interface to create and modify events. By utilizing the Django admin, we get that pretty much for free.
In order to make this happen, though, a few changes are required. First, we need a way to distinguish admins from other users. This is being handled through a new
User.is_staff
attribute. Next, we need to use a custom user manager class.CustomUserManager.create_user
andCustomUserManager.create_superuser
are being added to handle registering new users. And some authorization-related attributes and methods are being added toUser
. For now, authorization is determined solely by whether or not the user is an admin.After these changes, the password validators are being removed to simplify using the
createsuperuser
management command (which is being exposed through tox). The command will still require providing a password, but removing the validators will allow the user to enter a simpler password (since it's just going to be thrown away).Finally, the URL for the admin's login page is being redirected to the magic link-based
login
view we're using in the public portion of the site.