diff --git a/db.py b/db.py index 6f1bdf31..a860570a 100644 --- a/db.py +++ b/db.py @@ -894,6 +894,18 @@ class LoginToken(Base): return f"" +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"" + + # If run as script, create all the tables in the db if __name__ == "__main__": print("Creating new tables...") diff --git a/static/ee.ogg b/static/ee.ogg new file mode 100644 index 00000000..31d633d1 Binary files /dev/null and b/static/ee.ogg differ diff --git a/static/nryg.less b/static/nryg.less index 15485fea..7fdbec69 100644 --- a/static/nryg.less +++ b/static/nryg.less @@ -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; diff --git a/templates/main.html b/templates/main.html index fb690e96..5b47fbfb 100644 --- a/templates/main.html +++ b/templates/main.html @@ -4,9 +4,25 @@ Pagina principale {% endblock %} +{% block posthead %} + +{% endblock %} + {% block body %} -

- Royal Games +

+ Royal Games

diff --git a/webserver.py b/webserver.py index 9687c23b..f241b293 100644 --- a/webserver.py +++ b/webserver.py @@ -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/") @@ -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__)