Import mission profiles and better format text fields

This commit is contained in:
2025-11-18 23:24:38 +01:00
parent 79d7333ca0
commit 9cae53a942
6 changed files with 83 additions and 7 deletions

View File

@@ -18,10 +18,10 @@ from ..custom.colortag import course_color
# Resource Class for Student data import
class StudentResource(ModelResource):
surname = fields.Field(attribute="surname", column_name="surname", widget=CharWidget())
name = fields.Field(attribute="name", column_name="name", widget=CharWidget())
email = fields.Field(attribute="email", column_name="email", widget=CharWidget())
phone = fields.Field(attribute="phone", column_name="phone", widget=CharWidget())
surname = fields.Field(attribute="surname", column_name="surname")
name = fields.Field(attribute="name", column_name="name")
email = fields.Field(attribute="email", column_name="email")
phone = fields.Field(attribute="phone", column_name="phone")
# Cleanup fields before entering
def before_import_row(self, row: dict[str, str], **kwargs) -> None:
@@ -42,7 +42,7 @@ class StudentResource(ModelResource):
class ChangeCourseForm(AdminActionForm):
course = forms.ModelChoiceField(queryset=Course.objects.all())
class StudentAdmin(ImportMixin, AdminActionFormsMixin, admin.ModelAdmin):
class StudentAdmin(ImportMixin, AdminActionFormsMixin, admin.ModelAdmin):
list_display = ("surname", "name", "course", "course_color", "email", "phone", "password", "active")
list_filter = ("course", "active")
actions = ("change_course", "disable_students")