From d26585fed4a86e4eec5d97b3758c7f82b41a0ae9 Mon Sep 17 00:00:00 2001 From: NikolajDanger Date: Thu, 26 May 2022 14:35:57 +0200 Subject: [PATCH] :sparkles: --- aula/models.py | 14 ++++++++++++-- aula/static/main.css | 7 +++++++ aula/templates/home.html | 5 ++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/aula/models.py b/aula/models.py index 838fbd7..1b3fa71 100644 --- a/aula/models.py +++ b/aula/models.py @@ -55,11 +55,13 @@ class Post(tuple): def __init__(self, post_data): self.post_id = post_data[0] self.group_id = post_data[1] + self.group_name = "" self.author_id = post_data[2] - self.author = "" + self.author_name = "" self.title = post_data[3] self.content = post_data[4] self.created_date = post_data[5] + self._get_group_name() self._get_author_name() super().__init__() @@ -69,7 +71,15 @@ class Post(tuple): SELECT first_name, last_name FROM users WHERE user_id = %s """ cur.execute(sql_call, (self.author_id,)) - self.author = ' '.join(cur.fetchone()) + self.author_name = ' '.join(cur.fetchone()) + + def _get_group_name(self): + cur = conn.cursor() + sql_call = """ + SELECT name FROM groups WHERE group_id = %s + """ + cur.execute(sql_call, (self.group_id,)) + self.group_name = cur.fetchone()[0] class Thread(tuple): def __init__(self, thread_data): diff --git a/aula/static/main.css b/aula/static/main.css index 7004c30..ac9d272 100644 --- a/aula/static/main.css +++ b/aula/static/main.css @@ -13,6 +13,13 @@ h1, h2, h3, h4, h5, h6 { margin-bottom: 120px; } +.group-name { + position: relative; + right: 0; + bottom: 0; + text-align: right; +} + .navbar { padding-top: 0; padding-bottom: 0; diff --git a/aula/templates/home.html b/aula/templates/home.html index d2e57f8..735edc4 100644 --- a/aula/templates/home.html +++ b/aula/templates/home.html @@ -8,11 +8,14 @@

{{ post.title }}

{{ post.content }}

+
{% endfor %}