Files
edx-platform/openedx/features/enterprise_support/tasks.py
Feanil Patel 9cf2f9f298 Run 2to3 -f future . -w
This will remove imports from __future__ that are no longer needed.

https://docs.python.org/3.5/library/2to3.html#2to3fixer-future
2019-12-30 10:35:30 -05:00

39 lines
1.3 KiB
Python

"""
Tasks for Enterprise.
"""
import logging
from celery import task
from enterprise.models import EnterpriseCourseEnrollment
from openedx.features.enterprise_support.utils import clear_data_consent_share_cache
log = logging.getLogger('edx.celery.task')
@task(name=u'openedx.features.enterprise_support.tasks.clear_enterprise_customer_data_consent_share_cache')
def clear_enterprise_customer_data_consent_share_cache(enterprise_customer_uuid):
"""
clears data_sharing_consent_needed cache for whole enterprise
"""
enterprise_course_enrollments = EnterpriseCourseEnrollment.objects.filter(
enterprise_customer_user__enterprise_customer__uuid=enterprise_customer_uuid
)
count = enterprise_course_enrollments.count()
log.info(
u'Stated Clearing {count} data_sharing_consent_needed cache for enterprise customer {uuid}'.format(
count=count,
uuid=enterprise_customer_uuid,
)
)
for enrollment in enterprise_course_enrollments:
clear_data_consent_share_cache(
enrollment.enterprise_customer_user.user_id,
enrollment.course_id
)
log.info(u'Ended Clearing data_sharing_consent_needed cache for enterprise customer {uuid}'.format(
uuid=enterprise_customer_uuid,
))