Rival Delete functionality
This commit is contained in:
parent
147d7adaaf
commit
16d801aff5
@ -4,6 +4,7 @@
|
||||
<title>{{ title }}</title>
|
||||
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-rbsA2VBKQhggwzxH7pPCaAqO46MgnOM80zW1RWuH61DGLwZJEdK2Kadq2F9CUG65" crossorigin="anonymous">
|
||||
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.2.3/dist/js/bootstrap.bundle.min.js" integrity="sha384-kenU1KFdBIe4zVF0s0G1M5b4hcpxyD9F7jL+jjXkk+Q2h455rYXK/7HAuoJl+0I4" crossorigin="anonymous"></script>
|
||||
<script src="https://cdn.jsdelivr.net/npm/jquery@3.2.1/dist/jquery.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
|
||||
<style>
|
||||
html {
|
||||
background-color: #181a1b !important;
|
||||
|
@ -65,12 +65,15 @@ class OngekiFrontend(FE_Base):
|
||||
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")
|
||||
# self.logger.info(f"{usr_sesh.userId} added a rival")
|
||||
return redirectTo(b"/game/ongeki/", request)
|
||||
elif uri == "/game/ongeki/rival.delete":
|
||||
return b""
|
||||
rival_id = request.args[b"rivalUserId"][0].decode()
|
||||
self.data.profile.delete_rival(usr_sesh.userId, rival_id)
|
||||
# self.logger.info(f"{response}")
|
||||
return redirectTo(b"/game/ongeki/", request)
|
||||
|
||||
else:
|
||||
return b""
|
||||
return b"Something went wrong"
|
||||
else:
|
||||
return b"User is not logged in"
|
||||
|
12
titles/ongeki/frontend/js/rival_scripts.js
Normal file
12
titles/ongeki/frontend/js/rival_scripts.js
Normal file
@ -0,0 +1,12 @@
|
||||
function deleteRival(rivalUserId){
|
||||
|
||||
$(document).ready(function () {
|
||||
$.post("/game/ongeki/rival.delete",
|
||||
{
|
||||
rivalUserId
|
||||
},
|
||||
function(data,status){
|
||||
window.location.replace("/game/ongeki/")
|
||||
})
|
||||
});
|
||||
}
|
@ -32,10 +32,10 @@
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for rival in rival_info%}
|
||||
<tr>
|
||||
<tr id="{{rival.rivalUserId}}">
|
||||
<td>{{rival.rivalUserId}}</td>
|
||||
<td>{{rival.rivalUserName}}</td>
|
||||
<td><button class="btn-danger btn btn-sm">Delete</button></td>
|
||||
<td><button class="btn-danger btn btn-sm" onclick="deleteRival({{rival.rivalUserId}})">Delete</button></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
@ -65,8 +65,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{# <script>
|
||||
</script> #}
|
||||
<script>
|
||||
{% include 'titles/ongeki/frontend/js/rival_scripts.js' %}
|
||||
</script>
|
||||
{% else %}
|
||||
<h2>Not Currently Logged In</h2>
|
||||
{% endif %}
|
||||
|
@ -3,7 +3,7 @@ from sqlalchemy import Table, Column, UniqueConstraint, PrimaryKeyConstraint, an
|
||||
from sqlalchemy.types import Integer, String, TIMESTAMP, Boolean, JSON, BigInteger
|
||||
from sqlalchemy.engine.base import Connection
|
||||
from sqlalchemy.schema import ForeignKey
|
||||
from sqlalchemy.sql import func, select
|
||||
from sqlalchemy.sql import func, select, delete
|
||||
from sqlalchemy.engine import Row
|
||||
from sqlalchemy.dialects.mysql import insert
|
||||
|
||||
@ -519,3 +519,10 @@ class OngekiProfileData(BaseData):
|
||||
)
|
||||
return None
|
||||
return result.lastrowid
|
||||
def delete_rival(self, aime_id: int, rival_id: int) -> Optional[int]:
|
||||
sql = delete(rival).where(rival.c.user==aime_id, rival.c.rivalUserId==rival_id)
|
||||
result = self.execute(sql)
|
||||
if result is None:
|
||||
self.logger.error(f"delete_rival: failed to delete! aime_id: {aime_id}, rival_id: {rival_id}")
|
||||
else:
|
||||
return result.rowcount
|
Loading…
Reference in New Issue
Block a user