Repository: e-valuation/EvaP

Issue:
Course state change without sending automated email
For some courses (especially D-School courses) staff users need an option to instantly begin the evaluation (out of the state `approved`). Also, no automated message should be sent, because the staff users will send a customized email to all participants of this course.

In other cases evaluation results shall be published without notifying all participants (e.g. for feedback questionnaires about special events).

It should be possible to change a course's state with explicitly not sending email notifications.



Discussion:

Resolving patch:
diff --git a/evap/staff/views.py b/evap/staff/views.py
--- a/evap/staff/views.py
+++ b/evap/staff/views.py
@@ -129,14 +129,15 @@ def semester_course_operation(request, semester_id):
     if request.method == 'POST':
         course_ids = request.POST.getlist('course_ids')
         courses = Course.objects.filter(id__in=course_ids)
+        send_email = request.POST.get('send_email') == 'on'
         if operation == 'revertToNew':
             helper_semester_course_operation_revert(request, courses)
         elif operation == 'prepare' or operation == 'reenableEditorReview':
-            helper_semester_course_operation_prepare(request, courses)
+            helper_semester_course_operation_prepare(request, courses, send_email)
         elif operation == 'approve':
             helper_semester_course_operation_approve(request, courses)
         elif operation == 'publish':
-            helper_semester_course_operation_publish(request, courses)
+            helper_semester_course_operation_publish(request, courses, send_email)
         elif operation == 'unpublish':
             helper_semester_course_operation_unpublish(request, courses)
 
@@ -176,6 +177,7 @@ def semester_course_operation(request, semester_id):
         operation=operation,
         current_state_name=current_state_name,
         new_state_name=new_state_name,
+        show_email_checkbox=operation in ['prepare', 'reenableEditorReview', 'publish']
     )
     return render(request, "staff_course_operation.html", template_data)
 
@@ -186,14 +188,14 @@ def helper_semester_course_operation_revert(request, courses):
     messages.success(request, ungettext("Successfully reverted %(courses)d course to new.",
         "Successfully reverted %(courses)d courses to new.", len(courses)) % {'courses': len(courses)})
 
-def helper_semester_course_operation_prepare(request, courses):
+def helper_semester_course_operation_prepare(request, courses, send_email):
     for course in courses:
         course.ready_for_editors()
         course.save()
     messages.success(request, ungettext("Successfully enabled %(courses)d course for editor review.",
         "Successfully enabled %(courses)d courses for editor review.", len(courses)) % {'courses': len(courses)})
-
-    EmailTemplate.send_review_notifications(courses)
+    if send_email:
+        EmailTemplate.send_review_notifications(courses)
 
 def helper_semester_course_operation_approve(request, courses):
     for course in courses:
@@ -202,13 +204,14 @@ def helper_semester_course_operation_approve(request, courses):
     messages.success(request, ungettext("Successfully approved %(courses)d course.",
         "Successfully approved %(courses)d courses.", len(courses)) % {'courses': len(courses)})
 
-def helper_semester_course_operation_publish(request, courses):
+def helper_semester_course_operation_publish(request, courses, send_email):
     for course in courses:
         course.publish()
         course.save()
     messages.success(request, ungettext("Successfully published %(courses)d course.",
         "Successfully published %(courses)d courses.", len(courses)) % {'courses': len(courses)})
-    send_publish_notifications(evaluation_results_courses=courses)
+    if send_email:
+        send_publish_notifications(evaluation_results_courses=courses)
 
 def helper_semester_course_operation_unpublish(request, courses):
     for course in courses:


Test patch: