quality fixes

This commit is contained in:
Awais Jibran
2021-01-06 20:23:16 +05:00
parent 7e20cf2215
commit 159031adc9
3 changed files with 14 additions and 8 deletions

View File

@@ -4,7 +4,6 @@ This module contains celery task functions for handling the sending of bulk emai
to a course.
"""
import json
import logging
import random
@@ -59,7 +58,6 @@ from common.djangoapps.util.string_utils import _has_non_ascii_characters
log = logging.getLogger('edx.celery.task')
# Errors that an individual email is failing to be sent, and should just
# be treated as a fail.
SINGLE_EMAIL_FAILURE_ERRORS = (

View File

@@ -6,7 +6,6 @@ JSON views which the instructor dashboard requests.
Many of these GETs may become PUTs in the future.
"""
import csv
import json
import logging
@@ -186,6 +185,7 @@ def require_post_params(*args, **kwargs):
required_params = []
required_params += [(arg, None) for arg in args]
required_params += [(key, kwargs[key]) for key in kwargs]
# required_params = e.g. [('action', 'enroll or unenroll'), ['emails', None]]
def decorator(func):
@@ -208,7 +208,9 @@ def require_post_params(*args, **kwargs):
return JsonResponse(error_response_data, status=400)
else:
return func(*args, **kwargs)
return wrapped
return decorator
@@ -221,6 +223,7 @@ def require_course_permission(permission):
Assumes that request is in args[0].
Assumes that course_id is in kwargs['course_id'].
"""
def decorator(func):
def wrapped(*args, **kwargs):
request = args[0]
@@ -230,7 +233,9 @@ def require_course_permission(permission):
return func(*args, **kwargs)
else:
return HttpResponseForbidden()
return wrapped
return decorator
@@ -242,6 +247,7 @@ def require_sales_admin(func):
If the user does not have privileges for this operation, this will return HttpResponseForbidden (403).
"""
def wrapped(request, course_id):
try:
@@ -256,6 +262,7 @@ def require_sales_admin(func):
return func(request, course_id)
else:
return HttpResponseForbidden()
return wrapped
@@ -267,6 +274,7 @@ def require_finance_admin(func):
If the user does not have privileges for this operation, this will return HttpResponseForbidden (403).
"""
def wrapped(request, course_id):
try:
@@ -281,6 +289,7 @@ def require_finance_admin(func):
return func(request, course_id)
else:
return HttpResponseForbidden()
return wrapped
@@ -315,8 +324,8 @@ def register_and_enroll_students(request, course_id): # pylint: disable=too-man
"""
if not configuration_helpers.get_value(
'ALLOW_AUTOMATED_SIGNUPS',
settings.FEATURES.get('ALLOW_AUTOMATED_SIGNUPS', False),
'ALLOW_AUTOMATED_SIGNUPS',
settings.FEATURES.get('ALLOW_AUTOMATED_SIGNUPS', False),
):
return HttpResponseForbidden()
@@ -2959,8 +2968,8 @@ def invalidate_certificate(request, generated_certificate, certificate_invalidat
:return: dict object containing updated certificate invalidation data.
"""
if CertificateInvalidation.get_certificate_invalidations(
generated_certificate.course_id,
generated_certificate.user,
generated_certificate.course_id,
generated_certificate.user,
):
raise ValueError(
_(u"Certificate of {user} has already been invalidated. Please check your spelling and retry.").format(

View File

@@ -2,7 +2,6 @@
Context dictionary for templates that use the ace_common base template.
"""
from django.conf import settings
from django.urls import NoReverseMatch, reverse