Limite autorisation de commentaire aux pers. autorisées

This commit is contained in:
Claude Paroz 2019-02-07 09:24:55 +01:00
parent 6dfc3c6e42
commit f11d20c2f9
6 changed files with 66 additions and 4 deletions

View file

@ -154,6 +154,13 @@ class StudentCommentView(UpdateView):
model = Student
form_class = StudentCommentForm
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
# Only authorized teachers can comment on the student.
if not self.object.can_comment(self.request.user):
del context['form']
return context
def get_success_url(self):
messages.success(
self.request, "L'enregistrement des commentaires pour %s a réussi." % self.object