Skip to content

fix: show staff tag for global staff in discussion forum#181

Closed
Alam-2U wants to merge 0 commit intorelease-ulmofrom
ealam/COSMO2-842
Closed

fix: show staff tag for global staff in discussion forum#181
Alam-2U wants to merge 0 commit intorelease-ulmofrom
ealam/COSMO2-842

Conversation

@Alam-2U
Copy link
Copy Markdown

@Alam-2U Alam-2U commented Mar 13, 2026

Description

Global staff users were being displayed as learners in the discussion forum, and the staff tag was not shown.

Issue :

The course staff check was overriding the global staff check. As a result, if a user was not marked as course staff, they were displayed as a learner even if they had global staff privileges.

Ticket :

COSMO2-842

Copilot AI review requested due to automatic review settings March 13, 2026 10:33
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes discussion forum author labeling so platform-wide staff users (Django is_staff=True) display the “Staff” tag even when they don’t hold a course-specific forum role.

Changes:

  • Add global staff fallback checks when computing author_label / user labels.
  • Add serializer test coverage for global staff author labeling (anonymous vs non-anonymous).
  • Extend deleted-content labeling helper to also recognize platform-wide staff.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
lms/djangoapps/discussion/rest_api/tests/test_serializers.py Adds a test ensuring is_staff authors receive “Staff” unless anonymous.
lms/djangoapps/discussion/rest_api/serializers.py Updates _get_user_label to fall back to user.is_staff when not course staff.
lms/djangoapps/discussion/rest_api/api.py Updates deleted-content user label helper to also return “Staff” for is_staff users.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 279 to 288

# Check if user is a platform-wide staff member
if not is_staff:
try:
User = get_user_model()
user = User.objects.get(id=user_id)
is_staff = user.is_staff
except ObjectDoesNotExist:
pass

Comment thread lms/djangoapps/discussion/rest_api/api.py Outdated
Comment thread lms/djangoapps/discussion/rest_api/api.py Outdated
# Make author a platform-wide staff member
self.author.is_staff = True
self.author.save()

Copilot AI review requested due to automatic review settings March 16, 2026 07:49
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes discussion author labeling so platform-wide staff (global is_staff=True) are shown with the “Staff” tag instead of being treated as learners when they lack a course-specific staff role.

Changes:

  • Add a serializer test covering global staff author labeling (including anonymous content behavior).
  • Update discussion serializers to treat global staff as “Staff” when computing author_label.
  • Update API user-label helper to fall back to global staff (is_staff=True) for label resolution.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.

File Description
lms/djangoapps/discussion/rest_api/tests/test_serializers.py Adds coverage ensuring global staff users receive the “Staff” author label when not anonymous.
lms/djangoapps/discussion/rest_api/serializers.py Extends label resolution to include platform-wide staff; introduces global staff ID preloading in serializer context.
lms/djangoapps/discussion/rest_api/api.py Extends label resolution to include platform-wide staff via DB lookup when not course staff/mod/TA.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +278 to +289
is_staff = user_id in self.context["course_staff_user_ids"] or user_id in self.context["global_staff_user_ids"]
is_moderator = user_id in self.context["moderator_user_ids"]
is_ta = user_id in self.context["ta_user_ids"]

# Check if user is a platform-wide staff member
if not is_staff:
try:
user = User.objects.get(id=user_id)
is_staff = user.is_staff
except ObjectDoesNotExist:
pass

Comment on lines +2424 to +2429
try:
user = User.objects.get(id=user_id_int)
if user.is_staff:
return "Staff"
except User.DoesNotExist:
pass
Comment on lines +2419 to +2427
return "Moderator"
elif user_id_int in ta_user_ids:
return "Community TA"
else:
# Check if user is a platform-wide staff member
try:
user = User.objects.get(id=user_id_int)
if user.is_staff:
return "Staff"
Comment on lines 83 to 87
course_staff_user_ids = get_course_staff_users_list(course.id)
moderator_user_ids = get_moderator_users_list(course.id)
ta_user_ids = get_course_ta_users_list(course.id)
global_staff_user_ids = list(User.objects.filter(is_staff=True).values_list('id', flat=True))
requester = request.user
Copilot AI review requested due to automatic review settings March 16, 2026 11:13
@Alam-2U Alam-2U closed this Mar 16, 2026
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot wasn't able to review any files in this pull request.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants