Skip to content

Commit

Permalink
fix: resolve lint issues
Browse files Browse the repository at this point in the history
  • Loading branch information
hajorg committed Feb 29, 2024
1 parent c18c9de commit 45648c9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 18 deletions.
15 changes: 7 additions & 8 deletions lms/djangoapps/support/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -2359,10 +2359,7 @@ def setUp(self):
course_id=self.course.id,
user=self.user
)
CourseResetCourseOptIn.objects.create(
course_id=self.course_id,
active=True
)
self.opt_in = CourseResetCourseOptInFactory.create(course_id=self.course.id)

self.other_course = CourseFactory.create(
org='x',
Expand Down Expand Up @@ -2422,7 +2419,9 @@ def test_course_reset_failed(self):
self.assertEqual(response.status_code, 200)

def test_course_reset_dupe(self):
response = self.client.post(self._url(username=self.user.username), data={'course_id': self.course_id})
self.assertEqual(response.status_code, 201)
resp = self.client.post(self._url(username=self.user.username), data={'course_id': self.course_id})
self.assertEqual(resp.status_code, 204)
CourseResetAuditFactory.create(
course=self.opt_in,
course_enrollment=self.enrollment,
)
response2 = self.client.post(self._url(username=self.user.username), data={'course_id': self.course_id})
self.assertEqual(response2.status_code, 204)
21 changes: 11 additions & 10 deletions lms/djangoapps/support/views/course_reset.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def get(self, request, username_or_email):
})
return Response(result)


@method_decorator(require_support_permission)
def post(self, request, username_or_email):
"""
Expand Down Expand Up @@ -126,22 +125,25 @@ def post(self, request, username_or_email):
course_overview = enrollment.course_overview
course_reset_audit = CourseResetAudit.objects.filter(course_enrollment=enrollment).first()

if course_reset_audit and course_reset_audit.status == CourseResetAudit.CourseResetStatus.FAILED and not user_passed:
if course_reset_audit and (
course_reset_audit.status == CourseResetAudit.CourseResetStatus.FAILED
and not user_passed
):
course_reset_audit.status = CourseResetAudit.CourseResetStatus.ENQUEUED
course_reset_audit.save()
status = f"In progress - Started on {course_reset_audit.modified} by {course_reset_audit.reset_by.username}"
# Call celery task
resp = {
'course_id': course_id,
'status': status,
'status': course_reset_audit.status_message(),
'can_reset': False,
'display_name': course_overview.display_name
}
return Response(resp, status=200)

elif course_reset_audit and \
(course_reset_audit.status == CourseResetAudit.CourseResetStatus.IN_PROGRESS or
course_reset_audit.status == CourseResetAudit.CourseResetStatus.ENQUEUED):
elif course_reset_audit and course_reset_audit.status in (
CourseResetAudit.CourseResetStatus.IN_PROGRESS,
CourseResetAudit.CourseResetStatus.ENQUEUED
):
return Response(None, status=204)

if enrollment and opt_in_course and not user_passed:
Expand All @@ -150,15 +152,14 @@ def post(self, request, username_or_email):
course_enrollment=enrollment,
reset_by=request.user,
)
status = f"In progress - Started on {course_reset_audit.modified} by {course_reset_audit.reset_by.username}"
resp = {
'course_id': course_id,
'status': status,
'status': course_reset_audit.status_message(),
'can_reset': False,
'display_name': course_overview.display_name
}
# Call celery task

# Call celery task
return Response(resp, status=201)
else:
return Response(None, status=400)

0 comments on commit 45648c9

Please sign in to comment.