feat(authentication): add last modified, redo admin interface

This commit is contained in:
Ethan Nguyen 2021-04-23 20:00:19 -04:00
parent 0ebfb59bb7
commit 899017c01a
No known key found for this signature in database
GPG Key ID: B4CA5339AF911920
3 changed files with 54 additions and 0 deletions

View File

@ -5,6 +5,40 @@ from .models import User
class UserAdmin(admin.ModelAdmin):
search_fields = ["username", "first_name", "last_name"]
list_display = ["username", "last_name", "first_name", "last_modified"]
list_filter = ["is_senior", "accepted_terms", "is_student"]
fieldsets = (
(
None,
{
"fields": (
"username",
"first_name",
"last_name",
"email",
"password",
"accepted_terms",
"is_staff",
"is_superuser",
"is_senior",
"graduation_year",
"is_student",
"last_modified",
"last_login",
)
},
),
(
"Senior information",
{"fields": ("biography", "attending_decision", "publish_data")},
),
)
readonly_fields = (
"last_modified",
"last_login",
)
admin.site.register(User, UserAdmin)

View File

@ -0,0 +1,18 @@
# Generated by Django 3.2 on 2021-04-23 17:52
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
("authentication", "0008_alter_user_biography"),
]
operations = [
migrations.AddField(
model_name="user",
name="last_modified",
field=models.DateTimeField(auto_now=True),
),
]

View File

@ -31,5 +31,7 @@ class User(AbstractUser):
help_text="Can't see your college? Make sure you've added a decision with an admit status.",
)
last_modified = models.DateTimeField(auto_now=True)
def __str__(self):
return f"{self.first_name} {self.last_name}"