From d0765c90f3c08c016e6e4b6be2afd9d08d910896 Mon Sep 17 00:00:00 2001 From: NikolajDanger Date: Thu, 26 May 2022 12:51:32 +0200 Subject: [PATCH] :sparkles: --- aula/models.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/aula/models.py b/aula/models.py index 0bb751d..838fbd7 100644 --- a/aula/models.py +++ b/aula/models.py @@ -56,11 +56,21 @@ class Post(tuple): self.post_id = post_data[0] self.group_id = post_data[1] self.author_id = post_data[2] + self.author = "" self.title = post_data[3] self.content = post_data[4] self.created_date = post_data[5] + self._get_author_name() super().__init__() + def _get_author_name(self): + cur = conn.cursor() + sql_call = """ + SELECT first_name, last_name FROM users WHERE user_id = %s + """ + cur.execute(sql_call, (self.author_id,)) + self.author = ' '.join(cur.fetchone()) + class Thread(tuple): def __init__(self, thread_data): self.thread_id = thread_data[0]