From c467165bf3cb1447a06c202e85e0bded63274b80 Mon Sep 17 00:00:00 2001 From: Bartuccio Antoine Date: Sun, 16 Jun 2019 18:34:11 +0200 Subject: [PATCH] pedagogy: fix error with author change on comment when edited by an admin --- pedagogy/templates/pedagogy/uv_detail.jinja | 1 + pedagogy/views.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pedagogy/templates/pedagogy/uv_detail.jinja b/pedagogy/templates/pedagogy/uv_detail.jinja index b089e6f1..9b80efe4 100644 --- a/pedagogy/templates/pedagogy/uv_detail.jinja +++ b/pedagogy/templates/pedagogy/uv_detail.jinja @@ -21,6 +21,7 @@

{{ comment.grade_work_load }}

{{ comment.comment }}

{% trans %}Published: {% endtrans %}{{ comment.publish_date }}

+

{% trans %}Author: {% endtrans %}{{ comment.author }}

{% if user.is_owner(comment) %}

{% trans %}Edit{% endtrans %}

{% trans %}Delete{% endtrans %}

diff --git a/pedagogy/views.py b/pedagogy/views.py index f545e4e0..e9fb709f 100644 --- a/pedagogy/views.py +++ b/pedagogy/views.py @@ -110,8 +110,9 @@ class UVCommentUpdateView(CanEditPropMixin, UpdateView): def get_form_kwargs(self): kwargs = super(UVCommentUpdateView, self).get_form_kwargs() - kwargs["author_id"] = self.request.user.id - kwargs["uv_id"] = self.get_object().uv.id + obj = self.get_object() + kwargs["author_id"] = obj.author.id + kwargs["uv_id"] = obj.uv.id return kwargs