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()