Repository: e-valuation/EvaP

Issue:
Misguiding messages on contributor's course edit page
When a course is already approved, the contributor course edit page shows a message saying you can't edit this course anymore (introduced in #1076).
Also, a message instructing the user to edit the data is shown. This is misleading. The second message shouldn't be there.

![grafik](https://user-images.githubusercontent.com/13838962/37304966-601f88f0-2633-11e8-8ca8-e49b3c07dc29.png)

@janno42 please make sure I'm not missing out anything here.



Discussion:
Correct, this message should be removed for courses already approved by an editor.

Resolving patch:
diff --git a/evap/contributor/views.py b/evap/contributor/views.py
--- a/evap/contributor/views.py
+++ b/evap/contributor/views.py
@@ -68,12 +68,9 @@ def course_view(request, course_id):
     course = get_object_or_404(Course, id=course_id)
 
     # check rights
-    if not (course.is_user_editor_or_delegate(user) and course.state in ['prepared', 'editor_approved', 'approved', 'in_evaluation', 'evaluated', 'reviewed']):
+    if not course.is_user_editor_or_delegate(user) or course.state not in ['prepared', 'editor_approved', 'approved', 'in_evaluation', 'evaluated', 'reviewed']:
         raise PermissionDenied
 
-    if course.is_user_editor_or_delegate(user):
-        messages.info(request, _('You cannot edit this course because it has already been approved.'))
-
     InlineContributionFormset = inlineformset_factory(Course, Contribution, formset=ContributionFormSet, form=EditorContributionForm, extra=0)
 
     form = CourseForm(request.POST or None, instance=course)
@@ -85,7 +82,7 @@ def course_view(request, course_id):
             field.disabled = True
 
     template_data = dict(form=form, formset=formset, course=course, editable=False,
-                        responsibles=[contributor.username for contributor in course.responsible_contributors])
+                         responsibles=[contributor.username for contributor in course.responsible_contributors])
     return render(request, "contributor_course_form.html", template_data)
 
 


Test patch:
diff --git a/evap/contributor/tests/test_views.py b/evap/contributor/tests/test_views.py
--- a/evap/contributor/tests/test_views.py
+++ b/evap/contributor/tests/test_views.py
@@ -52,8 +52,10 @@ def test_wrong_state(self):
     def test_information_message(self):
         self.course.editor_approve()
         self.course.save()
+
         page = self.app.get(self.url, user='editor')
         self.assertContains(page, "You cannot edit this course because it has already been approved")
+        self.assertNotContains(page, "Please review the course's details below, add all contributors and select suitable questionnaires. Once everything is okay, please approve the course on the bottom of the page.")
 
 
 class TestContributorCoursePreviewView(ViewTest):
@@ -166,3 +168,7 @@ def test_contact_modal_escape(self):
         self.assertIn("Adam &amp; Eve", page)
         self.assertNotIn("Adam & Eve", page)
 
+    def test_information_message(self):
+        page = self.app.get(self.url, user='editor')
+        self.assertNotContains(page, "You cannot edit this course because it has already been approved")
+        self.assertContains(page, "Please review the course's details below, add all contributors and select suitable questionnaires. Once everything is okay, please approve the course on the bottom of the page.")