本文整理汇总了Python中lms.djangoapps.verify_student.services.IDVerificationService.user_status方法的典型用法代码示例。如果您正苦于以下问题:Python IDVerificationService.user_status方法的具体用法?Python IDVerificationService.user_status怎么用?Python IDVerificationService.user_status使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lms.djangoapps.verify_student.services.IDVerificationService
的用法示例。
在下文中一共展示了IDVerificationService.user_status方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: generate_certificate
# 需要导入模块: from lms.djangoapps.verify_student.services import IDVerificationService [as 别名]
# 或者: from lms.djangoapps.verify_student.services.IDVerificationService import user_status [as 别名]
def generate_certificate(self, **kwargs):
"""
Generates a certificate for a single user.
kwargs:
- student: The student for whom to generate a certificate.
- course_key: The course key for the course that the student is
receiving a certificate in.
- expected_verification_status: The expected verification status
for the user. When the status has changed, we double check
that the actual verification status is as expected before
generating a certificate, in the off chance that the database
has not yet updated with the user's new verification status.
"""
original_kwargs = kwargs.copy()
student = User.objects.get(id=kwargs.pop('student'))
course_key = CourseKey.from_string(kwargs.pop('course_key'))
expected_verification_status = kwargs.pop('expected_verification_status', None)
if expected_verification_status:
actual_verification_status = IDVerificationService.user_status(student)
actual_verification_status = actual_verification_status['status']
if expected_verification_status != actual_verification_status:
logger.warn('Expected verification status {expected} '
'differs from actual verification status {actual} '
'for user {user} in course {course}'.format(
expected=expected_verification_status,
actual=actual_verification_status,
user=student.id,
course=course_key
))
raise self.retry(kwargs=original_kwargs)
generate_user_certificates(student=student, course_key=course_key, **kwargs)
示例2: _listen_for_id_verification_status_changed
# 需要导入模块: from lms.djangoapps.verify_student.services import IDVerificationService [as 别名]
# 或者: from lms.djangoapps.verify_student.services.IDVerificationService import user_status [as 别名]
def _listen_for_id_verification_status_changed(sender, user, **kwargs): # pylint: disable=unused-argument
"""
Catches a track change signal, determines user status,
calls fire_ungenerated_certificate_task for passing grades
"""
if not auto_certificate_generation_enabled():
return
user_enrollments = CourseEnrollment.enrollments_for_user(user=user)
grade_factory = CourseGradeFactory()
expected_verification_status = IDVerificationService.user_status(user)
expected_verification_status = expected_verification_status['status']
for enrollment in user_enrollments:
if grade_factory.read(user=user, course=enrollment.course_overview).passed:
if fire_ungenerated_certificate_task(user, enrollment.course_id, expected_verification_status):
message = (
u'Certificate generation task initiated for {user} : {course} via track change ' +
u'with verification status of {status}'
)
log.info(message.format(
user=user.id,
course=enrollment.course_id,
status=expected_verification_status
))
示例3: test_user_status
# 需要导入模块: from lms.djangoapps.verify_student.services import IDVerificationService [as 别名]
# 或者: from lms.djangoapps.verify_student.services.IDVerificationService import user_status [as 别名]
def test_user_status(self):
# test for correct status when no error returned
user = UserFactory.create()
status = IDVerificationService.user_status(user)
self.assertDictEqual(status, {'status': 'none', 'error': '', 'should_display': True})
# test for when photo verification has been created
SoftwareSecurePhotoVerification.objects.create(user=user, status='approved')
status = IDVerificationService.user_status(user)
self.assertDictEqual(status, {'status': 'approved', 'error': '', 'should_display': True})
# create another photo verification for the same user, make sure the denial
# is handled properly
SoftwareSecurePhotoVerification.objects.create(
user=user, status='denied', error_msg='[{"photoIdReasons": ["Not provided"]}]'
)
status = IDVerificationService.user_status(user)
self.assertDictEqual(status, {'status': 'must_reverify', 'error': ['id_image_missing'], 'should_display': True})
# test for when sso verification has been created
SSOVerification.objects.create(user=user, status='approved')
status = IDVerificationService.user_status(user)
self.assertDictEqual(status, {'status': 'approved', 'error': '', 'should_display': False})
# create another sso verification for the same user, make sure the denial
# is handled properly
SSOVerification.objects.create(user=user, status='denied')
status = IDVerificationService.user_status(user)
self.assertDictEqual(status, {'status': 'must_reverify', 'error': '', 'should_display': False})
# test for when manual verification has been created
ManualVerification.objects.create(user=user, status='approved')
status = IDVerificationService.user_status(user)
self.assertDictEqual(status, {'status': 'approved', 'error': '', 'should_display': False})
示例4: get
# 需要导入模块: from lms.djangoapps.verify_student.services import IDVerificationService [as 别名]
# 或者: from lms.djangoapps.verify_student.services.IDVerificationService import user_status [as 别名]
def get(self, request):
"""
Render the reverification flow.
Most of the work is done client-side by composing the same
Backbone views used in the initial verification flow.
"""
verification_status = IDVerificationService.user_status(request.user)
expiration_datetime = IDVerificationService.get_expiration_datetime(request.user, ['approved'])
can_reverify = False
if expiration_datetime:
if is_verification_expiring_soon(expiration_datetime):
# The user has an active verification, but the verification
# is set to expire within "EXPIRING_SOON_WINDOW" days (default is 4 weeks).
# In this case user can resubmit photos for reverification.
can_reverify = True
# If the user has no initial verification or if the verification
# process is still ongoing 'pending' or expired then allow the user to
# submit the photo verification.
# A photo verification is marked as 'pending' if its status is either
# 'submitted' or 'must_retry'.
if verification_status['status'] in ["none", "must_reverify", "expired", "pending"] or can_reverify:
context = {
"user_full_name": request.user.profile.name,
"platform_name": configuration_helpers.get_value('PLATFORM_NAME', settings.PLATFORM_NAME),
"capture_sound": staticfiles_storage.url("audio/camera_capture.wav"),
}
return render_to_response("verify_student/reverify.html", context)
else:
context = {
"status": verification_status['status']
}
return render_to_response("verify_student/reverify_not_allowed.html", context)
示例5: student_dashboard
# 需要导入模块: from lms.djangoapps.verify_student.services import IDVerificationService [as 别名]
# 或者: from lms.djangoapps.verify_student.services.IDVerificationService import user_status [as 别名]
#.........这里部分代码省略.........
)
for enrollment in course_enrollments
}
# Determine the per-course verification status
# This is a dictionary in which the keys are course locators
# and the values are one of:
#
# VERIFY_STATUS_NEED_TO_VERIFY
# VERIFY_STATUS_SUBMITTED
# VERIFY_STATUS_APPROVED
# VERIFY_STATUS_MISSED_DEADLINE
#
# Each of which correspond to a particular message to display
# next to the course on the dashboard.
#
# If a course is not included in this dictionary,
# there is no verification messaging to display.
verify_status_by_course = check_verify_status_by_course(user, course_enrollments)
cert_statuses = {
enrollment.course_id: cert_info(request.user, enrollment.course_overview)
for enrollment in course_enrollments
}
# only show email settings for Mongo course and when bulk email is turned on
show_email_settings_for = frozenset(
enrollment.course_id for enrollment in course_enrollments if (
BulkEmailFlag.feature_enabled(enrollment.course_id)
)
)
# Verification Attempts
# Used to generate the "you must reverify for course x" banner
verification_status = IDVerificationService.user_status(user)
verification_errors = get_verification_error_reasons_for_display(verification_status['error'])
# Gets data for midcourse reverifications, if any are necessary or have failed
statuses = ["approved", "denied", "pending", "must_reverify"]
reverifications = reverification_info(statuses)
block_courses = frozenset(
enrollment.course_id for enrollment in course_enrollments
if is_course_blocked(
request,
CourseRegistrationCode.objects.filter(
course_id=enrollment.course_id,
registrationcoderedemption__redeemed_by=request.user
),
enrollment.course_id
)
)
enrolled_courses_either_paid = frozenset(
enrollment.course_id for enrollment in course_enrollments
if enrollment.is_paid_course()
)
# If there are *any* denied reverifications that have not been toggled off,
# we'll display the banner
denied_banner = any(item.display for item in reverifications["denied"])
# Populate the Order History for the side-bar.
order_history_list = order_history(
user,
course_org_filter=site_org_whitelist,
org_filter_out_set=site_org_blacklist
示例6: verification_status
# 需要导入模块: from lms.djangoapps.verify_student.services import IDVerificationService [as 别名]
# 或者: from lms.djangoapps.verify_student.services.IDVerificationService import user_status [as 别名]
def verification_status(self):
"""Return the verification status for this user."""
verification_status = IDVerificationService.user_status(self.user)
return verification_status['status']