Skip to content

Commit

Permalink
chore: no longer create local var for user_for_learner_status
Browse files Browse the repository at this point in the history
  • Loading branch information
adamstankiewicz committed Oct 29, 2024
1 parent 1c3f741 commit 0dec5c8
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions enterprise/api/v1/views/default_enterprise_enrollments.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,22 +106,22 @@ def learner_status(self, request):

# Validate the user for learner status exists and is associated
# with the enterprise customer.
if not (user_for_learner_status := self.user_for_learner_status):
if not self.user_for_learner_status:
return Response(

Check warning on line 110 in enterprise/api/v1/views/default_enterprise_enrollments.py

View check run for this annotation

Codecov / codecov/patch

enterprise/api/v1/views/default_enterprise_enrollments.py#L110

Added line #L110 was not covered by tests
{'detail': f'User with lms_user_id {self.requested_lms_user_id} not found.'},
status=status.HTTP_400_BAD_REQUEST,
)

try:
enterprise_customer_user = models.EnterpriseCustomerUser.objects.get(
user_id=user_for_learner_status.id,
user_id=self.user_for_learner_status.id,
enterprise_customer=enterprise_customer_uuid,
)
except models.EnterpriseCustomerUser.DoesNotExist:
return Response(
{
'detail': (
f'User with lms_user_id {user_for_learner_status.id} is not associated with '
f'User with lms_user_id {self.user_for_learner_status.id} is not associated with '
f'the enterprise customer {enterprise_customer_uuid}.'
),
},
Expand All @@ -139,8 +139,8 @@ def learner_status(self, request):
)

serializer_data = {
'lms_user_id': user_for_learner_status.id,
'user_email': user_for_learner_status.email,
'lms_user_id': self.user_for_learner_status.id,
'user_email': self.user_for_learner_status.email,
'enterprise_customer_uuid': enterprise_customer_uuid,
}
serializer = serializers.DefaultEnterpriseEnrollmentIntentionLearnerStatusSerializer(
Expand Down

0 comments on commit 0dec5c8

Please sign in to comment.