From d909f1e715f5dcb52db630389b4ad76ef776d51a Mon Sep 17 00:00:00 2001
From: Martin Mares <mj@ucw.cz>
Date: Tue, 5 Mar 2024 13:59:13 +0100
Subject: [PATCH] Do not crash when trying to determine author roles in
 discussion topics

---
 owl/post.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/owl/post.py b/owl/post.py
index 9134cfd..9b53851 100644
--- a/owl/post.py
+++ b/owl/post.py
@@ -208,7 +208,7 @@ def topic_post(form, student_uid) -> Optional[db.Post]:
     if comment or attach or points is not None:
         if g.is_teacher:
             role = db.PostRole.teacher
-        elif g.uid == student_uid:
+        elif g.uid == student_uid or g.topic.type == 'D':
             role = db.PostRole.student
         elif g.is_grader:
             role = db.PostRole.grader
-- 
GitLab