Skip to content

Commit

Permalink
Merge pull request #349 from edx/andya/fix-pylint
Browse files Browse the repository at this point in the history
Fix quality failures with new edx-lint version
  • Loading branch information
andy-armstrong authored May 9, 2017
2 parents fa622bc + b4d1069 commit 99c3deb
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 35 deletions.
25 changes: 10 additions & 15 deletions edx_proctoring/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,7 @@ def queryset(self, request, queryset):
return queryset.filter(reviewed_by__isnull=True)
elif self.value() == 'all_unreviewed_failures':
return queryset.filter(reviewed_by__isnull=True, review_status='Suspicious')
else:
return queryset
return queryset


class ProctoredExamListFilter(admin.SimpleListFilter):
Expand Down Expand Up @@ -252,25 +251,22 @@ def course_id_for_review(self, obj):
"""Return course_id associated with review"""
if obj.exam:
return obj.exam.course_id
else:
exam = self._get_exam_from_attempt_code(obj.attempt_code)
return exam.exam_name if exam else '(none)'
exam = self._get_exam_from_attempt_code(obj.attempt_code)
return exam.exam_name if exam else '(none)'

def exam_name_for_review(self, obj):
"""Return course_id associated with review"""
if obj.exam:
return obj.exam.exam_name
else:
exam = self._get_exam_from_attempt_code(obj.attempt_code)
return exam.exam_name if exam else '(none)'
exam = self._get_exam_from_attempt_code(obj.attempt_code)
return exam.exam_name if exam else '(none)'

def student_username_for_review(self, obj):
"""Return username of student who took the test"""
if obj.student:
return obj.student.username
else:
(attempt_obj, __) = locate_attempt_by_attempt_code(obj.attempt_code)
return attempt_obj.user.username if attempt_obj else '(None)'
(attempt_obj, __) = locate_attempt_by_attempt_code(obj.attempt_code)
return attempt_obj.user.username if attempt_obj else '(None)'

list_display = [
'course_id_for_review',
Expand All @@ -290,7 +286,7 @@ def has_delete_permission(self, request, obj=None):
""" Allow deletes """
return True

def save_model(self, request, review, form, change):
def save_model(self, request, review, form, change): # pylint: disable=arguments-differ
"""
Override callback so that we can inject the user_id that made the change
"""
Expand All @@ -306,7 +302,7 @@ def get_form(self, request, obj=None, **kwargs):
del form.base_fields['video_url']
return form

def lookup_allowed(self, key, value):
def lookup_allowed(self, key, value): # pylint: disable=arguments-differ
if key == 'exam__course_id':
return True
return super(ProctoredExamSoftwareSecureReviewAdmin, self).lookup_allowed(key, value)
Expand Down Expand Up @@ -363,8 +359,7 @@ def queryset(self, request, queryset):
"""
if self.value():
return queryset.filter(proctored_exam__course_id=self.value())
else:
return queryset
return queryset


class ProctoredExamAttemptForm(forms.ModelForm):
Expand Down
7 changes: 4 additions & 3 deletions edx_proctoring/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@

SHOW_EXPIRY_MESSAGE_DURATION = 1 * 60 # duration within which expiry message is shown for a timed-out exam

APPROVED_STATUS = 'approved'


def create_exam(course_id, content_id, exam_name, time_limit_mins, due_date=None,
is_proctored=True, is_practice_exam=False, external_id=None, is_active=True, hide_after_due=False):
Expand Down Expand Up @@ -1762,7 +1764,7 @@ def _get_proctored_exam_view(exam, context, exam_id, user_id, course_id):
return None
elif attempt_status in [ProctoredExamStudentAttemptStatus.created,
ProctoredExamStudentAttemptStatus.download_software_clicked]:
if context.get('verification_status') is not 'approved':
if context.get('verification_status') is not APPROVED_STATUS:
# if the user has not id verified yet, show them the page that requires them to do so
student_view_template = 'proctored_exam/id_verification.html'
else:
Expand Down Expand Up @@ -1879,5 +1881,4 @@ def get_student_view(user_id, course_id, content_id,

if sub_view_func:
return sub_view_func(exam, context, exam_id, user_id, course_id)
else:
return None
return None
2 changes: 2 additions & 0 deletions edx_proctoring/backends/tests/test_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
from edx_proctoring.backends.null import NullBackendProvider
from edx_proctoring.backends.mock import MockProctoringBackendProvider

# pragma pylint: disable=useless-super-delegation


class TestBackendProvider(ProctoringBackendProvider):
"""
Expand Down
4 changes: 2 additions & 2 deletions edx_proctoring/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ class Meta:
db_table = 'proctoring_proctoredexamreviewpolicyhistory'
verbose_name = 'proctored exam review policy history'

def delete(self, *args, **kwargs):
def delete(self, *args, **kwargs): # pylint: disable=arguments-differ
"""
Don't allow deletions!
"""
Expand Down Expand Up @@ -747,7 +747,7 @@ def add_allowance_for_user(cls, exam_id, user_info, key, value):
user_id = None

# see if key is a tuple, if it is, then the first element is the key
if isinstance(key, tuple) and len(key) > 0:
if isinstance(key, tuple) and len(key) > 0: # pylint: disable=len-as-condition
key = key[0]

if not cls.is_allowance_value_valid(key, value):
Expand Down
2 changes: 2 additions & 0 deletions edx_proctoring/tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
LoggedInTestCase
)

# pragma pylint: disable=useless-super-delegation


class ProctoredExamModelTests(LoggedInTestCase):
"""
Expand Down
27 changes: 12 additions & 15 deletions edx_proctoring/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ def require_staff(func):
def wrapped(request, *args, **kwargs): # pylint: disable=missing-docstring
if request.user.is_staff:
return func(request, *args, **kwargs)
else:
return Response(
status=status.HTTP_403_FORBIDDEN,
data={"detail": "Must be a Staff User to Perform this request."}
)
return Response(
status=status.HTTP_403_FORBIDDEN,
data={"detail": "Must be a Staff User to Perform this request."}
)
return wrapped


Expand Down Expand Up @@ -96,11 +95,10 @@ def wrapped(request, *args, **kwargs): # pylint: disable=missing-docstring
)
if instructor_service.is_course_staff(request.user, course_id):
return func(request, *args, **kwargs)
else:
return Response(
status=status.HTTP_403_FORBIDDEN,
data={"detail": _("Must be a Staff User to Perform this request.")}
)
return Response(
status=status.HTTP_403_FORBIDDEN,
data={"detail": _("Must be a Staff User to Perform this request.")}
)

return wrapped

Expand Down Expand Up @@ -191,11 +189,10 @@ def post(self, request):
hide_after_due=request.data.get('hide_after_due', None),
)
return Response({'exam_id': exam_id})
else:
return Response(
status=status.HTTP_400_BAD_REQUEST,
data=serializer.errors
)
return Response(
status=status.HTTP_400_BAD_REQUEST,
data=serializer.errors
)

@method_decorator(require_staff)
def put(self, request):
Expand Down

0 comments on commit 99c3deb

Please sign in to comment.