@@ -56,7 +56,7 @@ class TestNewInstructorDashboardEmailViewMongoBacked(SharedModuleStoreTestCase):
|
||||
response = self.client.get(self.url)
|
||||
self.assertIn(self.email_link, response.content)
|
||||
|
||||
send_to_label = '<ul role="group" aria-label="Send to:">'
|
||||
send_to_label = '<div class="send_to_list">Send to:</div>'
|
||||
self.assertTrue(send_to_label in response.content)
|
||||
self.assertEqual(response.status_code, 200)
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class FakeContentTask(FakeInfo):
|
||||
|
||||
def __init__(self, email_id, num_sent, num_failed, sent_to):
|
||||
super(FakeContentTask, self).__init__()
|
||||
self.task_input = {'email_id': email_id, 'to_option': sent_to}
|
||||
self.task_input = {'email_id': email_id}
|
||||
self.task_input = json.dumps(self.task_input)
|
||||
self.task_output = {'succeeded': num_sent, 'failed': num_failed}
|
||||
self.task_output = json.dumps(self.task_output)
|
||||
@@ -51,20 +51,6 @@ class FakeEmail(FakeInfo):
|
||||
'created',
|
||||
]
|
||||
|
||||
class FakeTarget(object):
|
||||
""" Corresponding fake target for a fake email """
|
||||
target_type = "expected"
|
||||
|
||||
def get_target_type_display(self):
|
||||
""" Mocks out a django method """
|
||||
return self.target_type
|
||||
|
||||
class FakeTargetGroup(object):
|
||||
""" Helps to mock out a django M2M relationship """
|
||||
def all(self):
|
||||
""" Mocks out a django method """
|
||||
return [FakeEmail.FakeTarget()]
|
||||
|
||||
def __init__(self, email_id):
|
||||
super(FakeEmail, self).__init__()
|
||||
self.id = unicode(email_id) # pylint: disable=invalid-name
|
||||
@@ -75,7 +61,23 @@ class FakeEmail(FakeInfo):
|
||||
hour = random.randint(0, 23)
|
||||
minute = random.randint(0, 59)
|
||||
self.created = datetime.datetime(year, month, day, hour, minute, tzinfo=utc)
|
||||
self.targets = FakeEmail.FakeTargetGroup()
|
||||
self.targets = FakeTargetGroup()
|
||||
|
||||
|
||||
class FakeTarget(object):
|
||||
""" Corresponding fake target for a fake email """
|
||||
target_type = "expected"
|
||||
|
||||
def long_display(self):
|
||||
""" Mocks out a class method """
|
||||
return self.target_type
|
||||
|
||||
|
||||
class FakeTargetGroup(object):
|
||||
""" Mocks out the M2M relationship between FakeEmail and FakeTarget """
|
||||
def all(self):
|
||||
""" Mocks out a django method """
|
||||
return [FakeTarget()]
|
||||
|
||||
|
||||
class FakeEmailInfo(FakeInfo):
|
||||
|
||||
@@ -2489,7 +2489,7 @@ def list_forum_members(request, course_id):
|
||||
@require_post_params(send_to="sending to whom", subject="subject line", message="message text")
|
||||
def send_email(request, course_id):
|
||||
"""
|
||||
Send an email to self, staff, or everyone involved in a course.
|
||||
Send an email to self, staff, cohorts, or everyone involved in a course.
|
||||
Query Parameters:
|
||||
- 'send_to' specifies what group the email should be sent to
|
||||
Options are defined by the CourseEmail model in
|
||||
|
||||
@@ -33,6 +33,7 @@ from courseware.access import has_access
|
||||
from courseware.courses import get_course_by_id, get_studio_url
|
||||
from django_comment_client.utils import has_forum_access
|
||||
from django_comment_common.models import FORUM_ROLE_ADMINISTRATOR
|
||||
from openedx.core.djangoapps.course_groups.cohorts import get_course_cohorts, is_course_cohorted, DEFAULT_COHORT_NAME
|
||||
from student.models import CourseEnrollment
|
||||
from shoppingcart.models import Coupon, PaidCourseRegistration, CourseRegCodeItem
|
||||
from course_modes.models import CourseMode, CourseModesArchive
|
||||
@@ -609,6 +610,9 @@ def _section_send_email(course, access):
|
||||
# xblock rendering.
|
||||
request_token=uuid.uuid1().get_hex()
|
||||
)
|
||||
cohorts = []
|
||||
if is_course_cohorted(course_key):
|
||||
cohorts = get_course_cohorts(course)
|
||||
email_editor = fragment.content
|
||||
section_data = {
|
||||
'section_key': 'send_email',
|
||||
@@ -616,6 +620,8 @@ def _section_send_email(course, access):
|
||||
'access': access,
|
||||
'send_email': reverse('send_email', kwargs={'course_id': unicode(course_key)}),
|
||||
'editor': email_editor,
|
||||
'cohorts': cohorts,
|
||||
'default_cohort_name': DEFAULT_COHORT_NAME,
|
||||
'list_instructor_tasks_url': reverse(
|
||||
'list_instructor_tasks', kwargs={'course_id': unicode(course_key)}
|
||||
),
|
||||
|
||||
@@ -33,7 +33,7 @@ def extract_email_features(email_task):
|
||||
From the given task, extract email content information
|
||||
|
||||
Expects that the given task has the following attributes:
|
||||
* task_input (dict containing email_id and to_option)
|
||||
* task_input (dict containing email_id)
|
||||
* task_output (optional, dict containing total emails sent)
|
||||
* requester, the user who executed the task
|
||||
|
||||
@@ -57,7 +57,7 @@ def extract_email_features(email_task):
|
||||
email = CourseEmail.objects.get(id=task_input_information['email_id'])
|
||||
email_feature_dict = {
|
||||
'created': get_default_time_display(email.created),
|
||||
'sent_to': [target.get_target_type_display() for target in email.targets.all()],
|
||||
'sent_to': [target.long_display() for target in email.targets.all()],
|
||||
'requester': str(email_task.requester),
|
||||
}
|
||||
features = ['subject', 'html_message', 'id']
|
||||
|
||||
Reference in New Issue
Block a user