From 40018ca577c5fe09e8d372bd5748c85f10c3cdb0 Mon Sep 17 00:00:00 2001 From: Alan Zhu <2025azhu@tjhsst.edu> Date: Tue, 17 Sep 2024 11:47:55 -0400 Subject: [PATCH] chore: add student_id to profile API for teachers --- intranet/apps/users/api.py | 3 +++ intranet/apps/users/serializers.py | 2 ++ 2 files changed, 5 insertions(+) diff --git a/intranet/apps/users/api.py b/intranet/apps/users/api.py index aa26af6e502..3bb1d030c32 100644 --- a/intranet/apps/users/api.py +++ b/intranet/apps/users/api.py @@ -51,6 +51,9 @@ def retrieve(self, request, *args, **kwargs): "websites", "is_announcements_admin", ] + if not (request.user.is_teacher or request.user.is_eighth_admin): + fields_to_remove.append("student_id") + for field in fields_to_remove: data.pop(field) diff --git a/intranet/apps/users/serializers.py b/intranet/apps/users/serializers.py index 2abe1f207f5..ad8b2efa780 100644 --- a/intranet/apps/users/serializers.py +++ b/intranet/apps/users/serializers.py @@ -69,6 +69,7 @@ class UserSerializer(serializers.ModelSerializer): user_type = serializers.CharField(max_length=100) graduation_year = serializers.IntegerField() tj_email = serializers.StringRelatedField() + student_id = serializers.IntegerField() emails = serializers.StringRelatedField(many=True) phones = serializers.StringRelatedField(many=True) websites = serializers.StringRelatedField(many=True) @@ -91,6 +92,7 @@ class Meta: "last_name", "nickname", "tj_email", + "student_id", "emails", "grade", "graduation_year",