forked from openedx/edx-platform
-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* origin/master: ginkgo!
- Loading branch information
Showing
2,658 changed files
with
132,681 additions
and
80,533 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"presets": [ | ||
[ | ||
"env", | ||
{ | ||
"targets": { | ||
"browsers": [ | ||
"last 2 versions", | ||
"IE >= 11" | ||
] | ||
}, | ||
"modules": false | ||
} | ||
] | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ source = | |
common/lib/capa | ||
common/lib/xmodule | ||
lms | ||
openedx/core/djangoapps | ||
openedx | ||
pavelib | ||
|
||
omit = | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -279,4 +279,7 @@ Jhony Avella <[email protected]> | |
Tanmay Mohapatra <[email protected]> | ||
Brian Mesick <[email protected]> | ||
Jeff LaJoie <[email protected]> | ||
Ivan Ivić <[email protected]> | ||
Brandon Baker <[email protected]> | ||
Shirley He <[email protected]> | ||
Sahar Markovich <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
# Do things in edx-platform | ||
|
||
# Careful with mktemp syntax: it has to work on Mac and Ubuntu, which have differences. | ||
PRIVATE_FILES := $(shell mktemp -u /tmp/private_files.XXXXXX) | ||
|
||
clean: | ||
# Remove all the git-ignored stuff, but save and restore things marked | ||
# by start-noclean/end-noclean. | ||
# by start-noclean/end-noclean. Include Makefile in the tarball so that | ||
# there's always at least one file even if there are no private files. | ||
sed -n -e '/start-noclean/,/end-noclean/p' < .gitignore > /tmp/private-files | ||
tar cf /tmp/private.tar `git ls-files --exclude-from=/tmp/private-files --ignored --others` | ||
git clean -fdX | ||
tar xf /tmp/private.tar | ||
-tar cf $(PRIVATE_FILES) Makefile `git ls-files --exclude-from=/tmp/private-files --ignored --others` | ||
-git clean -fdX | ||
tar xf $(PRIVATE_FILES) | ||
rm $(PRIVATE_FILES) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
""" | ||
CMS user tasks application configuration | ||
Signal handlers are connected here. | ||
""" | ||
|
||
from django.apps import AppConfig | ||
|
||
|
||
class CmsUserTasksConfig(AppConfig): | ||
""" | ||
Application Configuration for cms_user_tasks. | ||
""" | ||
name = u'cms_user_tasks' | ||
|
||
def ready(self): | ||
""" | ||
Connect signal handlers. | ||
""" | ||
from . import signals # pylint: disable=unused-variable |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
""" | ||
Receivers of signals sent from django-user-tasks | ||
""" | ||
from __future__ import absolute_import, print_function, unicode_literals | ||
|
||
import logging | ||
|
||
from django.core.urlresolvers import reverse | ||
from django.dispatch import receiver | ||
from user_tasks.models import UserTaskArtifact | ||
from user_tasks.signals import user_task_stopped | ||
|
||
from six.moves.urllib.parse import urljoin # pylint: disable=import-error | ||
|
||
from .tasks import send_task_complete_email | ||
|
||
LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
@receiver(user_task_stopped, dispatch_uid="cms_user_task_stopped") | ||
def user_task_stopped_handler(sender, **kwargs): # pylint: disable=unused-argument | ||
""" | ||
Handles sending notifications when a django-user-tasks completes. | ||
This is a signal receiver for user_task_stopped. Currently it only sends | ||
a generic "task completed" email, and only when a top-level task | ||
completes. Eventually it might make more sense to create specific per-task | ||
handlers. | ||
Arguments: | ||
sender (obj): Currently the UserTaskStatus object class | ||
**kwargs: See below | ||
Keywork Arguments: | ||
status (obj): UserTaskStatus of the completed task | ||
Returns: | ||
None | ||
""" | ||
status = kwargs['status'] | ||
|
||
# Only send email when the entire task is complete, should only send when | ||
# a chain / chord / etc completes, not on sub-tasks. | ||
if status.parent is None: | ||
# `name` and `status` are not unique, first is our best guess | ||
artifact = UserTaskArtifact.objects.filter(status=status, name="BASE_URL").first() | ||
|
||
detail_url = None | ||
if artifact and artifact.url.startswith(('http://', 'https://')): | ||
detail_url = urljoin( | ||
artifact.url, | ||
reverse('usertaskstatus-detail', args=[status.uuid]) | ||
) | ||
|
||
try: | ||
# Need to str state_text here because it is a proxy object and won't serialize correctly | ||
send_task_complete_email.delay(status.name.lower(), str(status.state_text), status.user.email, detail_url) | ||
except Exception: # pylint: disable=broad-except | ||
LOGGER.exception("Unable to queue send_task_complete_email") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
""" | ||
Celery tasks used by cms_user_tasks | ||
""" | ||
|
||
from boto.exception import NoAuthHandlerFound | ||
from celery.exceptions import MaxRetriesExceededError | ||
from celery.task import task | ||
from celery.utils.log import get_task_logger | ||
from django.conf import settings | ||
from django.core import mail | ||
|
||
from edxmako.shortcuts import render_to_string | ||
from openedx.core.djangoapps.site_configuration import helpers as configuration_helpers | ||
|
||
LOGGER = get_task_logger(__name__) | ||
TASK_COMPLETE_EMAIL_MAX_RETRIES = 3 | ||
TASK_COMPLETE_EMAIL_TIMEOUT = 60 | ||
|
||
|
||
@task(bind=True) | ||
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. | ||
""" | ||
retries = self.request.retries | ||
|
||
context = { | ||
'task_name': task_name, | ||
'task_status': task_state_text, | ||
'detail_url': detail_url | ||
} | ||
|
||
subject = render_to_string('emails/user_task_complete_email_subject.txt', context) | ||
# Eliminate any newlines | ||
subject = ''.join(subject.splitlines()) | ||
message = render_to_string('emails/user_task_complete_email.txt', context) | ||
|
||
from_address = configuration_helpers.get_value( | ||
'email_from_address', | ||
settings.DEFAULT_FROM_EMAIL | ||
) | ||
|
||
try: | ||
mail.send_mail(subject, message, from_address, [dest_addr], fail_silently=False) | ||
LOGGER.info("Task complete email has been sent to User %s", dest_addr) | ||
except NoAuthHandlerFound: | ||
LOGGER.info( | ||
'Retrying sending email to user %s, attempt # %s of %s', | ||
dest_addr, | ||
retries, | ||
TASK_COMPLETE_EMAIL_MAX_RETRIES | ||
) | ||
try: | ||
self.retry(countdown=TASK_COMPLETE_EMAIL_TIMEOUT, max_retries=TASK_COMPLETE_EMAIL_MAX_RETRIES) | ||
except MaxRetriesExceededError: | ||
LOGGER.error( | ||
'Unable to send task completion email to user from "%s" to "%s"', | ||
from_address, | ||
dest_addr, | ||
exc_info=True | ||
) | ||
except Exception: # pylint: disable=broad-except | ||
LOGGER.exception( | ||
'Unable to send task completion email to user from "%s" to "%s"', | ||
from_address, | ||
dest_addr, | ||
exc_info=True | ||
) |
Oops, something went wrong.