From 1e8c57efaf7f7a7799e3c0365c0d0557f9d90672 Mon Sep 17 00:00:00 2001 From: Alexander-D-Karpov Date: Sun, 6 Nov 2022 11:13:42 +0300 Subject: [PATCH] minor changes --- image_markuper/dicom/api/views.py | 7 ++++++- image_markuper/dicom/models/base.py | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/image_markuper/dicom/api/views.py b/image_markuper/dicom/api/views.py index c3f2a79..a8def05 100644 --- a/image_markuper/dicom/api/views.py +++ b/image_markuper/dicom/api/views.py @@ -206,7 +206,12 @@ class ListUpdateDicomImageNumberApi(GenericAPIView): class ListCreateProjectApi(generics.ListCreateAPIView): - serializer_class = ListProjectSerializer + def get_serializer_class(self): + if self.request.user.is_staff: + s = ListProjectSerializer + s.Meta.fields.append("user_username") + return s + return ListProjectSerializer def get_queryset(self): if self.request.user.is_staff: diff --git a/image_markuper/dicom/models/base.py b/image_markuper/dicom/models/base.py index 1528854..fcea371 100644 --- a/image_markuper/dicom/models/base.py +++ b/image_markuper/dicom/models/base.py @@ -62,6 +62,10 @@ class Project(models.Model): def __str__(self): return f"{self.user.username}'s project" + @property + def user_username(self): + return self.user.username + class Dicom(models.Model): slug = models.SlugField()