From d456ed365cf69233eae2095d1b6355c661148ccd Mon Sep 17 00:00:00 2001 From: = <=> Date: Sun, 16 Jun 2024 14:08:59 +0200 Subject: [PATCH] Working diva frontend --- changelog.md | 4 ++ titles/diva/frontend.py | 14 ++--- titles/diva/schema/score.py | 4 +- titles/diva/templates/diva_index.jinja | 12 +++++ titles/diva/templates/diva_playlog.jinja | 67 +++++++++++++++++++++--- 5 files changed, 86 insertions(+), 15 deletions(-) diff --git a/changelog.md b/changelog.md index 3f8c6ba..c00c489 100644 --- a/changelog.md +++ b/changelog.md @@ -1,6 +1,10 @@ # Changelog Documenting updates to ARTEMiS, to be updated every time the master branch is pushed to. +## 20240616 +### DIVA ++ Working frontend with name and level strings edit and playlog + ## 20240530 ### DIVA + Fix reader for when dificulty is not a int diff --git a/titles/diva/frontend.py b/titles/diva/frontend.py index 2015c22..cc5c332 100644 --- a/titles/diva/frontend.py +++ b/titles/diva/frontend.py @@ -56,7 +56,7 @@ class DivaFrontend(FE_Base): ), media_type="text/html; charset=utf-8") return resp else: - return RedirectResponse("/login") + return RedirectResponse("/gate") async def render_GET_playlog(self, request: Request) -> bytes: template = self.environment.get_template( @@ -86,15 +86,15 @@ class DivaFrontend(FE_Base): for record in playlog: song = await self.data.static.get_music_chart(record[2], record[3], record[4]) if song: - title = song[4] - artist = song[5] + title = song.title + vocaloid_arranger = song.vocaloid_arranger else: title = "Unknown" - artist = "Unknown" + vocaloid_arranger = "Unknown" playlog_with_title.append({ "raw": record, "title": title, - "artist": artist + "vocaloid_arranger": vocaloid_arranger }) return Response(template.render( title=f"{self.core_config.server.name} | {self.nav_name}", @@ -110,7 +110,7 @@ class DivaFrontend(FE_Base): async def update_name(self, request: Request) -> Response: usr_sesh = self.validate_session(request) if not usr_sesh: - return RedirectResponse("/login") + return RedirectResponse("/gate") form_data = await request.form() new_name: str = form_data.get("new_name") @@ -147,7 +147,7 @@ class DivaFrontend(FE_Base): async def update_lv(self, request: Request) -> Response: usr_sesh = self.validate_session(request) if not usr_sesh: - return RedirectResponse("/login") + return RedirectResponse("/gate") form_data = await request.form() new_lv: str = form_data.get("new_lv") diff --git a/titles/diva/schema/score.py b/titles/diva/schema/score.py index 65ff99c..ce89f74 100644 --- a/titles/diva/schema/score.py +++ b/titles/diva/schema/score.py @@ -240,8 +240,8 @@ class DivaScoreData(BaseData): return None return result.fetchall() - async def get_playlogs(self, user_id: int, idx: int = 0, limit: int = 0) -> Optional[List[Row]]: - sql = playlog.select(playlog.c.user == user_id) + async def get_playlogs(self, aime_id: int, idx: int = 0, limit: int = 0) -> Optional[Row]: + sql = select(playlog).where(playlog.c.user == aime_id).order_by(playlog.c.date_scored.desc()) if limit: sql = sql.limit(limit) diff --git a/titles/diva/templates/diva_index.jinja b/titles/diva/templates/diva_index.jinja index 0cba3f4..c2f0888 100644 --- a/titles/diva/templates/diva_index.jinja +++ b/titles/diva/templates/diva_index.jinja @@ -28,14 +28,26 @@ Lvl: {{ profile[5] }} + + + + Lvl points: {{ profile[6] }} + + + + Vocaloid points: {{ profile[7] }} + + + + diff --git a/titles/diva/templates/diva_playlog.jinja b/titles/diva/templates/diva_playlog.jinja index cb63a00..c5a5618 100644 --- a/titles/diva/templates/diva_playlog.jinja +++ b/titles/diva/templates/diva_playlog.jinja @@ -9,17 +9,72 @@

Score counts: {{ playlog_count }}

{% set difficultyName = ['easy', 'normal', 'hard', 'extreme', 'extra extreme'] %} + {% set clearState = ['MISSxTAKE', 'STANDARD', 'GREAT', 'EXELLENT', 'PERFECT'] %} {% for record in playlog %}
-
-
{{ record.title }}
-
-
{{ record.artist }}
+
+
+
+
{{ record.title }}
+
+
{{ record.vocaloid_arranger }}
+
+
+
{{record.raw.date_scored}}
+
-
-
{{ difficultyName[record.raw[4]] }}
+
+
+

{{ record.raw.score }}

+

{{ record.raw.atn_pnt / 100 }}%

+
{{ difficultyName[record.raw.difficulty] }}
+
+
+ + + + + + + + + + + + + + + + + + + + + +
COOL{{ record.raw.cool }}
FINE{{ record.raw.fine }}
SAFE{{ record.raw.safe }}
SAD{{ record.raw.sad }}
WORST{{ record.raw.worst }}
+
+
+
{{ record.raw.max_combo }}
+ {% if record.raw.clr_kind == -1 %} +
{{ clearState[0] }}
+ {% elif record.raw.clr_kind == 2 %} +
{{ clearState[1] }}
+ {% elif record.raw.clr_kind == 3 %} +
{{ clearState[2] }}
+ {% elif record.raw.clr_kind == 4 %} +
{{ clearState[3] }}
+ {% elif record.raw.clr_kind == 5 %} +
{{ clearState[4] }}
+ {% endif %} + {% if record.raw.clr_kind == -1 %} +
NOT CLEAR
+ {% else %} +
CLEAR
+ {% endif %} +
+
{% endfor %}