|
48 | 48 | )
|
49 | 49 | from django_comment_client.utils import has_forum_access
|
50 | 50 | from instructor.offline_gradecalc import student_grades, offline_grades_available
|
51 |
| -from instructor.views.tools import strip_if_string |
| 51 | +from instructor.views.tools import strip_if_string, bulk_email_is_enabled_for_course |
52 | 52 | from instructor_task.api import (
|
53 | 53 | get_running_instructor_tasks,
|
54 | 54 | get_instructor_task_history,
|
@@ -110,10 +110,11 @@ def instructor_dashboard(request, course_id):
|
110 | 110 | # the instructor dashboard page is modal: grades, psychometrics, admin
|
111 | 111 | # keep that state in request.session (defaults to grades mode)
|
112 | 112 | idash_mode = request.POST.get('idash_mode', '')
|
| 113 | + idash_mode_key = u'idash_mode:{0}'.format(course_id) |
113 | 114 | if idash_mode:
|
114 |
| - request.session['idash_mode'] = idash_mode |
| 115 | + request.session[idash_mode_key] = idash_mode |
115 | 116 | else:
|
116 |
| - idash_mode = request.session.get('idash_mode', 'Grades') |
| 117 | + idash_mode = request.session.get(idash_mode_key, 'Grades') |
117 | 118 |
|
118 | 119 | enrollment_number = CourseEnrollment.num_enrolled_in(course_id)
|
119 | 120 |
|
@@ -760,33 +761,36 @@ def getdat(u):
|
760 | 761 | email_subject = request.POST.get("subject")
|
761 | 762 | html_message = request.POST.get("message")
|
762 | 763 |
|
763 |
| - try: |
764 |
| - # Create the CourseEmail object. This is saved immediately, so that |
765 |
| - # any transaction that has been pending up to this point will also be |
766 |
| - # committed. |
767 |
| - email = CourseEmail.create(course_id, request.user, email_to_option, email_subject, html_message) |
| 764 | + if bulk_email_is_enabled_for_course(course_id): |
| 765 | + try: |
| 766 | + # Create the CourseEmail object. This is saved immediately, so that |
| 767 | + # any transaction that has been pending up to this point will also be |
| 768 | + # committed. |
| 769 | + email = CourseEmail.create(course_id, request.user, email_to_option, email_subject, html_message) |
768 | 770 |
|
769 |
| - # Submit the task, so that the correct InstructorTask object gets created (for monitoring purposes) |
770 |
| - submit_bulk_course_email(request, course_id, email.id) # pylint: disable=E1101 |
| 771 | + # Submit the task, so that the correct InstructorTask object gets created (for monitoring purposes) |
| 772 | + submit_bulk_course_email(request, course_id, email.id) # pylint: disable=E1101 |
771 | 773 |
|
772 |
| - except Exception as err: |
773 |
| - # Catch any errors and deliver a message to the user |
774 |
| - error_msg = "Failed to send email! ({0})".format(err) |
775 |
| - msg += "<font color='red'>" + error_msg + "</font>" |
776 |
| - log.exception(error_msg) |
| 774 | + except Exception as err: |
| 775 | + # Catch any errors and deliver a message to the user |
| 776 | + error_msg = "Failed to send email! ({0})".format(err) |
| 777 | + msg += "<font color='red'>" + error_msg + "</font>" |
| 778 | + log.exception(error_msg) |
777 | 779 |
|
778 |
| - else: |
779 |
| - # If sending the task succeeds, deliver a success message to the user. |
780 |
| - if email_to_option == "all": |
781 |
| - text = _( |
782 |
| - "Your email was successfully queued for sending. " |
783 |
| - "Please note that for large classes, it may take up to an hour " |
784 |
| - "(or more, if other courses are simultaneously sending email) " |
785 |
| - "to send all emails." |
786 |
| - ) |
787 | 780 | else:
|
788 |
| - text = _('Your email was successfully queued for sending.') |
789 |
| - email_msg = '<div class="msg msg-confirm"><p class="copy">{text}</p></div>'.format(text=text) |
| 781 | + # If sending the task succeeds, deliver a success message to the user. |
| 782 | + if email_to_option == "all": |
| 783 | + text = _( |
| 784 | + "Your email was successfully queued for sending. " |
| 785 | + "Please note that for large classes, it may take up to an hour " |
| 786 | + "(or more, if other courses are simultaneously sending email) " |
| 787 | + "to send all emails." |
| 788 | + ) |
| 789 | + else: |
| 790 | + text = _('Your email was successfully queued for sending.') |
| 791 | + email_msg = '<div class="msg msg-confirm"><p class="copy">{text}</p></div>'.format(text=text) |
| 792 | + else: |
| 793 | + msg += "<font color='red'>Email is not enabled for this course.</font>" |
790 | 794 |
|
791 | 795 | elif "Show Background Email Task History" in action:
|
792 | 796 | message, datatable = get_background_task_table(course_id, task_type='bulk_course_email')
|
@@ -895,8 +899,7 @@ def get_analytics_result(analytics_name):
|
895 | 899 | # 1. Feature flag is on
|
896 | 900 | # 2. We have explicitly enabled email for the given course via django-admin
|
897 | 901 | # 3. It is NOT an XML course
|
898 |
| - if settings.FEATURES['ENABLE_INSTRUCTOR_EMAIL'] and \ |
899 |
| - CourseAuthorization.instructor_email_enabled(course_id) and is_studio_course: |
| 902 | + if bulk_email_is_enabled_for_course(course_id): |
900 | 903 | show_email_tab = True
|
901 | 904 |
|
902 | 905 | # display course stats only if there is no other table to display:
|
|
0 commit comments