diff --git a/core/frontend/index.jinja b/core/frontend/index.jinja index 7e4a1ca..fa89fc3 100644 --- a/core/frontend/index.jinja +++ b/core/frontend/index.jinja @@ -77,6 +77,9 @@ margin-bottom: 10px; width: 15%; } + .modal-content { + background-color: #181a1b; + }
diff --git a/titles/ongeki/frontend.py b/titles/ongeki/frontend.py index 0ec05c1..02fe5bf 100644 --- a/titles/ongeki/frontend.py +++ b/titles/ongeki/frontend.py @@ -2,6 +2,7 @@ import yaml import jinja2 from twisted.web.http import Request from os import path +from twisted.web.util import redirectTo from twisted.web.server import Session from core.frontend import FE_Base, IUserSession @@ -10,6 +11,7 @@ from core.config import CoreConfig from titles.ongeki.config import OngekiConfig from titles.ongeki.const import OngekiConstants from titles.ongeki.database import OngekiData +from titles.ongeki.base import OngekiBase class OngekiFrontend(FE_Base): @@ -24,19 +26,51 @@ class OngekiFrontend(FE_Base): yaml.safe_load(open(f"{cfg_dir}/{OngekiConstants.CONFIG_NAME}")) ) self.nav_name = "O.N.G.E.K.I." - self.geki_version = OngekiConstants.VERSION_NAMES[-1]+"?" - print(OngekiConstants.VERSION_NAMES[-1]) + self.version = 7 + def render_GET(self, request: Request) -> bytes: template = self.environment.get_template( "titles/ongeki/frontend/ongeki_index.jinja" ) sesh: Session = request.getSession() usr_sesh = IUserSession(sesh) - - return template.render( - title=f"{self.core_config.server.name} | {self.nav_name}", - game_list=self.environment.globals["game_list"], - gachas=self.game_cfg.gachas.enabled_gachas, - version= self.geki_version, - sesh=vars(usr_sesh) - ).encode("utf-16") + if getattr(usr_sesh, "userId", 0) != 0: + profile_data =self.data.profile.get_profile_data_ignore_version(usr_sesh.userId) + rival_list = self.data.profile.get_rivals(usr_sesh.userId) + rival_data = { + "userRivalList": rival_list, + "userId": usr_sesh.userId + } + self.version = getattr(profile_data, "version" , 7) + if len(rival_list) > 0: + rival_info = OngekiBase.handle_get_user_rival_data_api_request(self, rival_data) + + return template.render( + data=self.data.profile, + title=f"{self.core_config.server.name} | {self.nav_name}", + game_list=self.environment.globals["game_list"], + gachas=self.game_cfg.gachas.enabled_gachas, + profile_data=profile_data, + rival_info=rival_info["userRivalDataList"], + sesh=vars(usr_sesh) + ).encode("utf-16") + else: + return redirectTo(b"/gate/", request) + + def render_POST(self, request: Request): + uri = request.uri.decode() + sesh: Session = request.getSession() + usr_sesh = IUserSession(sesh) + if hasattr(usr_sesh, "userId"): + if uri == "/game/ongeki/rival.add": + rival_id = request.args[b"rivalUserId"][0].decode() + self.data.profile.put_rival(usr_sesh.userId, rival_id) + self.logger.info(f"{usr_sesh.userId} added a rival") + return redirectTo(b"/game/ongeki/", request) + elif uri == "/game/ongeki/rival.delete": + return b"" + + else: + return b"" + else: + return b"User is not logged in" diff --git a/titles/ongeki/frontend/ongeki_index.jinja b/titles/ongeki/frontend/ongeki_index.jinja index ddcdd05..0eb271b 100644 --- a/titles/ongeki/frontend/ongeki_index.jinja +++ b/titles/ongeki/frontend/ongeki_index.jinja @@ -1,8 +1,73 @@ {% extends "core/frontend/index.jinja" %} {% block content %} + +{% if sesh is defined and sesh["userId"] > 0 %}ID | +Name | +Delete | +
---|---|---|
{{rival.rivalUserId}} | +{{rival.rivalUserName}} | ++ |