1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Fix some bugs?

This commit is contained in:
Steffo 2018-09-27 12:52:41 +02:00
parent 565bbf68e3
commit 1f3f78ac65
5 changed files with 69 additions and 3 deletions

12
db.py
View file

@ -894,6 +894,18 @@ class LoginToken(Base):
return f"<LoginToken for {self.royal.username}>"
class EETrigger(Base):
__tablename__ = "eetriggers"
royal_id = Column(Integer, ForeignKey("royals.id"), primary_key=True)
royal = relationship("Royal", backref="triggers", lazy="joined")
stage = Column(String, nullable=False)
def __repr__(self):
return f"<EETrigger of {self.royal.username}: {self.stage}>"
# If run as script, create all the tables in the db
if __name__ == "__main__":
print("Creating new tables...")

BIN
static/ee.ogg Normal file

Binary file not shown.

View file

@ -6,6 +6,7 @@
@accent-color: white;
@link-color: #00aaff;
@visited-color: #aa66ff;
@old-ryg-color: #ff7f00;
body {
font-family: sans-serif;
@ -869,6 +870,24 @@ table {
}
}
.ee {
color: @old-ryg-color;
cursor: pointer;
&:hover {
text-decoration: underline #ff7f00;
}
&:active {
text-decoration: underline white;
}
}
.eeclear {
opacity: 0.8;
cursor: help;
}
#debug-mode {
color: red;
font-weight: bold;

View file

@ -4,9 +4,25 @@
Pagina principale
{% endblock %}
{% block posthead %}
<script>
var audio = new Audio("{{ url_for('static', filename='ee.ogg') }}");
function ee() {
fetch("/ee/r", {
method: "POST",
mode: "same-origin",
credentials: "same-origin"
});
document.getElementById("main-title").innerHTML = '<span class="eeclear" title="Soon, my pupil.">R</span>oyal Games';
audio.play();
}
</script>
{% endblock %}
{% block body %}
<h1>
Royal Games
<h1 id="main-title">
<span {% if triggerable_r %}class="ee" onclick="ee()" {% else %}class="eeclear" title="Soon, my pupil."{% endif %}>R</span>oyal Games
</h1>
<div class="main-page">
<div class="left">

View file

@ -66,9 +66,10 @@ def page_main():
random_diario = db_session.query(db.Diario).order_by(db.func.random()).first()
next_events = db_session.query(db.Event).filter(db.Event.time > datetime.datetime.now()).order_by(
db.Event.time).all()
triggerable_r = not bool(db_session.query(db.EETrigger).filter_by(royal_id=fl_session["user_id"]).one_or_none())
db_session.close()
return render_template("main.html", royals=royals, wiki_pages=wiki_pages, entry=random_diario,
next_events=next_events, rygconf=config, escape=escape)
next_events=next_events, rygconf=config, escape=escape, triggerable_r=triggerable_r)
@app.route("/profile/<name>")
@ -318,6 +319,24 @@ def page_diario():
return render_template("diario.html", rygconf=config, entries=diario_entries)
@app.route("/ee/r", methods=["POST"])
def ee_r():
if fl_session["user_id"] is None:
abort(403)
return
db_session = db.Session()
trigger = db_session.query(db.EETrigger).filter_by(royal_id=fl_session["user_id"]).one_or_none()
if trigger is None:
trigger = db.EETrigger(royal_id=fl_session["user_id"],
stage="R")
user = db_session.query(db.Royal).filter_by(id=fl_session["user_id"]).one()
db_session.add(trigger)
user.fiorygi += 1
db_session.commit()
db_session.close()
return "R"
if __name__ == "__main__":
try:
app.run(host="0.0.0.0", port=1235, debug=__debug__)