From ca0099063a4cff880e448f546b249ac99729ff11 Mon Sep 17 00:00:00 2001 From: Mikkel <4072916+Mikk3@users.noreply.github.com> Date: Sat, 4 Jun 2022 12:12:18 +0200 Subject: [PATCH] Vis rolle information --- aula/models.py | 13 +++++++++---- aula/templates/group_show.html | 2 +- aula/templates/thread_show.html | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/aula/models.py b/aula/models.py index 20fb723..92727bc 100644 --- a/aula/models.py +++ b/aula/models.py @@ -18,6 +18,11 @@ def load_user(cpr_num): cur.close() return user +def convert_role(role): + if role == "student": return "Elev" + elif role == "parent": return "Forældre" + else: return "Lærer" + # # Models # @@ -70,7 +75,7 @@ class Message(tuple): "cpr_num": message_data[4], "first_name": message_data[5], "last_name": message_data[6], - "role": message_data[7], + "role": convert_role(message_data[7]), } super().__init__() @@ -112,7 +117,7 @@ class Post(tuple): 'cpr_num': post_data[7], 'first_name': post_data[8], 'last_name': post_data[9], - 'role': post_data[10], + 'role': convert_role(post_data[7]), } super().__init__() @@ -153,7 +158,7 @@ class User(tuple, UserMixin): self.first_name = user_data[1] self.last_name = user_data[2] self.password = user_data[3] - self.role = user_data[4] + self.role = convert_role(user_data[4]) super().__init__() def get_id(self): @@ -361,4 +366,4 @@ def insert_message(content, thread_id, author_cpr_num): cur.execute(sql_call, (content, thread_id, author_cpr_num)) # Husk commit() for INSERT og UPDATE, men ikke til SELECT! conn.commit() - cur.close() + cur.close() \ No newline at end of file diff --git a/aula/templates/group_show.html b/aula/templates/group_show.html index 19fa383..58902de 100644 --- a/aula/templates/group_show.html +++ b/aula/templates/group_show.html @@ -10,7 +10,7 @@

{{ post.title }}

diff --git a/aula/templates/thread_show.html b/aula/templates/thread_show.html index 55476fa..6c40b4d 100644 --- a/aula/templates/thread_show.html +++ b/aula/templates/thread_show.html @@ -10,7 +10,7 @@
{% endif %}

{{ message.created_date }}