fix: convert integrity signature waffle flag to CourseWaffleFlag

This commit is contained in:
Bianca Severino
2021-06-09 11:43:09 -04:00
parent de8859584f
commit 58d5b29f19
4 changed files with 17 additions and 10 deletions

View File

@@ -894,7 +894,7 @@ class SequenceBlock(
'allow_proctoring_opt_out': self.allow_proctoring_opt_out,
'due_date': self.due,
'grace_period': self.graceperiod, # lint-amnesty, pylint: disable=no-member
'is_integrity_signature_enabled': is_integrity_signature_enabled(),
'is_integrity_signature_enabled': is_integrity_signature_enabled(course_id),
}
# inject the user's credit requirements and fulfillments

View File

@@ -2,10 +2,13 @@
Toggles for the Agreements app
"""
from edx_toggles.toggles import WaffleFlag
from opaque_keys.edx.keys import CourseKey
from openedx.core.djangoapps.waffle_utils import CourseWaffleFlag
# .. toggle_name: agreements.enable_integrity_signature
# .. toggle_implementation: WaffleFlag
# .. toggle_implementation: CourseWaffleFlag
# .. toggle_default: False
# .. toggle_description: Supports rollout of the integrity signature feature
# .. toggle_use_cases: temporary, open_edx
@@ -14,8 +17,12 @@ from edx_toggles.toggles import WaffleFlag
# .. toggle_warnings: None
# .. toggle_tickets: MST-786
ENABLE_INTEGRITY_SIGNATURE = WaffleFlag('agreements.enable_integrity_signature', __name__)
ENABLE_INTEGRITY_SIGNATURE = CourseWaffleFlag( # lint-amnesty, pylint: disable=toggle-missing-annotation
'agreements', 'enable_integrity_signature', __name__,
)
def is_integrity_signature_enabled():
return ENABLE_INTEGRITY_SIGNATURE.is_enabled()
def is_integrity_signature_enabled(course_key):
if isinstance(course_key, str):
course_key = CourseKey.from_string(course_key)
return ENABLE_INTEGRITY_SIGNATURE.is_enabled(course_key)

View File

@@ -68,7 +68,7 @@ class IntegritySignatureView(AuthenticatedAPIView):
Only staff should be able to access this endpoint for other users.
"""
# check that waffle flag is enabled
if not is_integrity_signature_enabled():
if not is_integrity_signature_enabled(CourseKey.from_string(course_id)):
return Response(
status=status.HTTP_404_NOT_FOUND,
)
@@ -112,7 +112,7 @@ class IntegritySignatureView(AuthenticatedAPIView):
}
"""
# check that waffle flag is enabled
if not is_integrity_signature_enabled():
if not is_integrity_signature_enabled(CourseKey.from_string(course_id)):
return Response(
status=status.HTTP_404_NOT_FOUND,
)

View File

@@ -300,10 +300,10 @@ class CoursewareMeta:
Boolean describing whether the user needs to sign the integrity agreement for a course.
"""
if (
not self.is_staff
is_integrity_signature_enabled(self.course_key)
and not self.is_staff
and self.enrollment_object
and self.enrollment_object.mode in CourseMode.CERTIFICATE_RELEVANT_MODES
and is_integrity_signature_enabled()
):
signature = get_integrity_signature(self.effective_user.username, str(self.course_key))
if not signature: