From 8efc8d4ff02bde6c9dd1e076f35febeda80a2be7 Mon Sep 17 00:00:00 2001
From: Lou-M <73669620+Lou-M@users.noreply.github.com>
Date: Thu, 24 Oct 2024 20:46:18 +0200
Subject: [PATCH] =?UTF-8?q?Minimale=20=C3=84nderungen=20zur=20Verbesserung?=
 =?UTF-8?q?=20der=20Lesbarkeit=20(#242)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Termintitel im letzten (also Start-)Embed hervorheben

... ein Versuch zur besseren Lesbarkeit

* Changed embed for appointments to use underscore instead of italic and added bullet points to module information

---------

Co-authored-by: dnns01 <git@dnns01.de>
---
 extensions/module_information.py | 60 +++++++++++++-------------------
 models.py                        |  3 +-
 2 files changed, 27 insertions(+), 36 deletions(-)

diff --git a/extensions/module_information.py b/extensions/module_information.py
index a5a478d..ca3e1b4 100644
--- a/extensions/module_information.py
+++ b/extensions/module_information.py
@@ -59,16 +59,12 @@ class ModuleInformation(commands.Cog):
 
     @staticmethod
     async def download_for(title, module):
-        desc = ""
-        found = False
-        for download in module.downloads.where(Download.title.contains(title)):
-            found = True
-            desc += f"[{download.title}]({download.url})\n"
-        if not found:
+        downloads = [f"- [{download.title}]({download.url})" for download in module.downloads.where(Download.title.contains(title))]
+        if len(downloads) == 0:
             raise ModuleInformationNotFoundError
 
         return discord.Embed(title=f"{title} {module.title}",
-                             description=desc,
+                             description="\n".join(downloads),
                              color=19607, url=module.url)
 
     async def handbook(self, module):
@@ -85,29 +81,26 @@ class ModuleInformation(commands.Cog):
 
     @staticmethod
     async def info(module):
-        desc = (f"Wie viele Credits bekomme ich? **{module.ects} ECTS**\n"
-                f"Wie lange geht das Modul? **{module.duration}**\n"
-                f"Wie oft wird das Modul angeboten? **{module.interval}**\n"
-                )
+        embed = discord.Embed(title=f"Modul {module.title}",
+                             color=19607, url=module.url)
+        embed.add_field(name="Wie viele Credits bekomme ich?", value=f"{module.ects} ECTS", inline=False)
+        embed.add_field(name="Wie lange geht das Modul?", value=module.duration, inline=False)
+        embed.add_field(name="Wie oft wird das Modul angeboten?", value=module.interval, inline=False)
+        embed.add_field(name="\u200b", value="\u200b", inline=False)
 
-        if (requirements := module.requirements) and len(requirements) > 0 and requirements != 'keine':
-            desc += f"\nInhaltliche Voraussetzungen: \n{requirements}\n"
+        if (requirements := module.requirements) and len(requirements) > 0 and requirements not in  ['keine', "-"]:
+            embed.add_field(name="Inhaltliche Voraussetzungen", value=requirements, inline=False)
 
         if (notes := module.notes) and len(notes) > 0 and notes != '-':
-            desc += f"\nAnmerkungen: \n\n{notes}\n"
+            embed.add_field(name="Anmerkunden", value=notes, inline=False)
 
         if (contacts := module.contacts) and len(contacts) > 0:
-            desc += f"\nAnsprechparnter: \n"
-            desc += ', '.join([contact.name for contact in contacts]) + "\n"
+            embed.add_field(name="Ansprechpartner", value=', '.join([f"- {contact.name}" for contact in contacts]), inline=False)
 
         if (events := module.events) and len(events) > 0:
-            desc += f"\nAktuelles Angebot in der VU: \n"
-            for event in events:
-                desc += f"[{event.name}]({event.url})\n"
+            embed.add_field(name="Aktuelles Angebot in der VU", value="\n".join([f"- [{event.name}]({event.url})" for event in events]), inline=False)
 
-        return discord.Embed(title=f"Modul {module.title}",
-                             description=desc,
-                             color=19607, url=module.url)
+        return embed
 
     @staticmethod
     async def effort(module):
@@ -126,11 +119,8 @@ class ModuleInformation(commands.Cog):
             raise ModuleInformationNotFoundError(
                 f"Ich kann leider derzeit keine Mentoriate für das Modul {module.number}-{module.title} finden.")
 
-        desc = ""
-        for support in module.support:
-            desc += f"[{support.title}]({support.url})\n"
         return discord.Embed(title=f"Mentoriate {module.title}",
-                             description=desc,
+                             description="\n".join([f"- [{support.title}]({support.url})" for support in module.support]),
                              color=19607, url=module.url)
 
     @staticmethod
@@ -139,23 +129,23 @@ class ModuleInformation(commands.Cog):
             raise ModuleInformationNotFoundError(
                 f"Ich kann leider derzeit keine Prüfungsinformationen für das Modul {module.number}-{module.title} finden.")
 
-        desc = ""
+        embed = discord.Embed(title=f"Prüfungsinformationen {module.title}",
+                             color=19607, url=module.url)
+
         for exam in module.exams:
-            desc += f"**{exam.name}**\n{exam.type}\n"
+            desc = f"- {exam.type}\n"
             if exam.weight and len(exam.weight) > 0 and exam.weight != '-':
-                desc += f"Gewichtung: **{exam.weight}**\n"
-            desc += "\n"
+                desc += f"- Gewichtung: **{exam.weight}**\n"
 
             if exam.requirements and len(exam.requirements) > 0 and exam.requirements != 'keine':
-                desc += f"Inhaltliche Voraussetzungen: \n{exam.requirements}\n\n"
+                desc += f"- Inhaltliche Voraussetzungen: \n  - {exam.requirements}\n"
 
             if exam.hard_requirements and len(exam.hard_requirements) > 0 \
                     and exam.hard_requirements != 'keine':
-                desc += f"Formale Voraussetzungen: \n{exam.hard_requirements}\n\n"
+                desc += f"- Formale Voraussetzungen: \n  - {exam.hard_requirements}\n"
+            embed.add_field(name=exam.name, value=desc, inline=False)
 
-        return discord.Embed(title=f"Prüfungsinformationen {module.title}",
-                             description=desc,
-                             color=19607, url=module.url)
+        return embed
 
     async def get_embed(self, module: Module, topic: Topics):
         if topic == Topics.handbuch:
diff --git a/models.py b/models.py
index 656e001..0588d8b 100644
--- a/models.py
+++ b/models.py
@@ -136,7 +136,7 @@ class Appointment(BaseModel):
                        f"- Durch Klicken auf Abmelden nimmst du deine vorherige Anmeldung wieder zurück und wirst "
                        f"nicht benachrichtigt.") if state != 2 else ""
         emoji = "📅" if state == 0 else ("📣" if state == 1 else "✅")
-        embed = discord.Embed(title=f"{emoji} {self.title} {'*findet jetzt statt.*' if state == 2 else ''}",
+        embed = discord.Embed(title=f"{emoji} __{self.title}__ {'findet jetzt statt.' if state == 2 else ''}",
                               description=description)
 
         embed.color = Colour.green() if state == 0 else Colour.yellow() if state == 1 else 19607
@@ -273,3 +273,4 @@ class Contact(BaseModel):
 db.create_tables(
     [Settings, LinkCategory, Link, NewsFeed, NewsArticle, Poll, PollChoice, PollParticipant, Command, CommandText, Appointment,
      Attendee, Course, Module, Event, Support, Exam, Download, Contact], safe=True)
+
-- 
GitLab