From a119cc122d1bd5bd9caf6fe3835f6728c5aa20a6 Mon Sep 17 00:00:00 2001 From: Daniel Egger Date: Mon, 7 Nov 2022 16:48:58 +0100 Subject: [PATCH] Add CourseSession admin model --- README.md | 5 +--- server/vbv_lernwelt/course/admin.py | 36 +++++++++++++++++++++++++++- server/vbv_lernwelt/course/models.py | 3 +++ 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 50685426..71693b77 100644 --- a/README.md +++ b/README.md @@ -12,9 +12,6 @@ cd client && npm run dev # reset db and run django dev server ./prepare_server.sh - -# run tailwind cli (for tailwind support on django templates) -cd client && npm run tailwind ``` ## Installation @@ -50,7 +47,7 @@ environment variables. It will also setup the tables for django and run the django development server. ```bash -# will initial`migrate` and `runserver` etc... +# will run `migrate` and `runserver` etc... ./prepare_server.sh # or async server diff --git a/server/vbv_lernwelt/course/admin.py b/server/vbv_lernwelt/course/admin.py index 8c38f3f3..59789610 100644 --- a/server/vbv_lernwelt/course/admin.py +++ b/server/vbv_lernwelt/course/admin.py @@ -1,3 +1,37 @@ from django.contrib import admin -# Register your models here. +from vbv_lernwelt.course.models import CourseSession, CourseSessionUser + + +@admin.register(CourseSession) +class CourseSessionAdmin(admin.ModelAdmin): + date_hierarchy = "created_at" + list_display = [ + "title", + "course", + "start_date", + "end_date", + "created_at", + "updated_at", + ] + + +@admin.register(CourseSessionUser) +class CourseSessionUserAdmin(admin.ModelAdmin): + date_hierarchy = "created_at" + list_display = [ + "course_session", + "user", + "created_at", + "updated_at", + ] + search_fields = [ + "user__first_name", + "user__last_name", + "user__email", + "course_session__title", + ] + list_filter = [ + "course_session__course", + "course_session", + ] diff --git a/server/vbv_lernwelt/course/models.py b/server/vbv_lernwelt/course/models.py index e0ed641b..bcc93401 100644 --- a/server/vbv_lernwelt/course/models.py +++ b/server/vbv_lernwelt/course/models.py @@ -182,6 +182,9 @@ class CourseSession(models.Model): additional_json_data = models.JSONField(default=dict) + def __str__(self): + return f"{self.title}" + class CourseSessionUser(models.Model): """