Merge pull request #25584 from edx/robrap/ARCHBOM-1260-code-owner-decorator
ARCHBOM-1260: set code_owner for celery tasks
This commit is contained in:
@@ -9,6 +9,7 @@ from celery.task import task
|
||||
from celery.utils.log import get_task_logger
|
||||
from django.conf import settings
|
||||
from django.core import mail
|
||||
from edx_django_utils.monitoring import set_code_owner_attribute
|
||||
|
||||
from common.djangoapps.edxmako.shortcuts import render_to_string
|
||||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers
|
||||
@@ -19,6 +20,7 @@ TASK_COMPLETE_EMAIL_TIMEOUT = 60
|
||||
|
||||
|
||||
@task(bind=True)
|
||||
@set_code_owner_attribute
|
||||
def send_task_complete_email(self, task_name, task_state_text, dest_addr, detail_url):
|
||||
"""
|
||||
Sending an email to the users when an async task completes.
|
||||
|
||||
@@ -22,6 +22,7 @@ from django.core.files import File
|
||||
from django.test import RequestFactory
|
||||
from django.utils.text import get_valid_filename
|
||||
from django.utils.translation import ugettext as _
|
||||
from edx_django_utils.monitoring import set_code_owner_attribute, set_code_owner_attribute_from_module
|
||||
from opaque_keys.edx.keys import CourseKey
|
||||
from opaque_keys.edx.locator import LibraryLocator
|
||||
from organizations.models import OrganizationCourse
|
||||
@@ -83,6 +84,7 @@ def clone_instance(instance, field_values):
|
||||
|
||||
|
||||
@task()
|
||||
@set_code_owner_attribute
|
||||
def rerun_course(source_course_key_string, destination_course_key_string, user_id, fields=None):
|
||||
"""
|
||||
Reruns a course in a new celery task.
|
||||
@@ -169,6 +171,7 @@ def _parse_time(time_isoformat):
|
||||
|
||||
|
||||
@task(routing_key=settings.UPDATE_SEARCH_INDEX_JOB_QUEUE)
|
||||
@set_code_owner_attribute
|
||||
def update_search_index(course_id, triggered_time_isoformat):
|
||||
""" Updates course search index. """
|
||||
try:
|
||||
@@ -193,6 +196,7 @@ def update_search_index(course_id, triggered_time_isoformat):
|
||||
|
||||
|
||||
@task()
|
||||
@set_code_owner_attribute
|
||||
def update_library_index(library_id, triggered_time_isoformat):
|
||||
""" Updates course search index. """
|
||||
try:
|
||||
@@ -238,10 +242,13 @@ class CourseExportTask(UserTask): # pylint: disable=abstract-method
|
||||
|
||||
|
||||
@task(base=CourseExportTask, bind=True)
|
||||
# Note: The decorator @set_code_owner_attribute could not be used because
|
||||
# the implementation of this task breaks with any additional decorators.
|
||||
def export_olx(self, user_id, course_key_string, language):
|
||||
"""
|
||||
Export a course or library to an OLX .tar.gz archive and prepare it for download.
|
||||
"""
|
||||
set_code_owner_attribute_from_module(__name__)
|
||||
courselike_key = CourseKey.from_string(course_key_string)
|
||||
|
||||
try:
|
||||
@@ -370,10 +377,13 @@ class CourseImportTask(UserTask): # pylint: disable=abstract-method
|
||||
|
||||
|
||||
@task(base=CourseImportTask, bind=True)
|
||||
# Note: The decorator @set_code_owner_attribute could not be used because
|
||||
# the implementation of this task breaks with any additional decorators.
|
||||
def import_olx(self, user_id, course_key_string, archive_path, archive_name, language):
|
||||
"""
|
||||
Import a course or library from a provided OLX .tar.gz archive.
|
||||
"""
|
||||
set_code_owner_attribute_from_module(__name__)
|
||||
courselike_key = CourseKey.from_string(course_key_string)
|
||||
try:
|
||||
user = User.objects.get(pk=user_id)
|
||||
|
||||
Reference in New Issue
Block a user