From 1025802ab1a734c95456a7733bfd347079c362bb Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Wed, 1 Aug 2018 18:05:18 +0200 Subject: [PATCH] Add bio to profiles --- db.py | 9 +++++---- templates/profile.html | 8 ++++++++ templates/setcss.html | 9 +++++---- webserver.py | 20 +++++++++++--------- 4 files changed, 29 insertions(+), 17 deletions(-) diff --git a/db.py b/db.py index cce9f755..255e8ef3 100644 --- a/db.py +++ b/db.py @@ -821,13 +821,14 @@ class AprilFoolsBan(Base): datetime = Column(DateTime, nullable=False) -class CustomCSS(Base): - __tablename__ = "customcss" +class ProfileData(Base): + __tablename__ = "profiledata" royal_id = Column(Integer, ForeignKey("royals.id"), primary_key=True) - royal = relationship("Royal", lazy="joined") + royal = relationship("Royal", backref="profile_data", uselist=False, lazy="joined") - css = Column(Text, nullable=False) + css = Column(Text) + bio = Column(Text) class WikiEntry(Base): diff --git a/templates/profile.html b/templates/profile.html index eff13888..15973d5e 100644 --- a/templates/profile.html +++ b/templates/profile.html @@ -22,6 +22,14 @@

Profilo di {{ ryg.username }} {% if session.get('user_id', '') == ryg.id %}Modifica{% endif %}

+ {% if css.bio %} +
+ Bio +
+
+ {{ css.bio }} +
+ {% endif %}
{% with record = ryg %} {% include "minis/ryg.html" %} diff --git a/templates/setcss.html b/templates/setcss.html index 3cdbaa11..943a2382 100644 --- a/templates/setcss.html +++ b/templates/setcss.html @@ -1,15 +1,16 @@ {% extends 'base.html' %} {% block pagetitle %} - CSS + Modifica profilo {% endblock %} {% block body %}

- CSS + Modifica profilo

-
- + + +
{% endblock %} \ No newline at end of file diff --git a/webserver.py b/webserver.py index a982138e..0a6f8314 100644 --- a/webserver.py +++ b/webserver.py @@ -74,7 +74,7 @@ def page_profile(name: str): db_session.close() abort(404) return - css = db_session.query(db.CustomCSS).filter_by(royal=user).one_or_none() + css = db_session.query(db.ProfileData).filter_by(royal=user).one_or_none() steam = db_session.query(db.Steam).filter_by(royal=user).one_or_none() osu = db_session.query(db.Osu).filter_by(royal=user).one_or_none() rl = db_session.query(db.RocketLeague).join(db.Steam).filter_by(royal=user).one_or_none() @@ -145,28 +145,30 @@ def page_password(): return redirect(url_for("page_login")) -@app.route("/setcss", methods=["GET", "POST"]) -def page_setcss(): +@app.route("/editprofile", methods=["GET", "POST"]) +def page_editprofile(): user_id = fl_session.get("user_id") db_session = db.Session() - ccss = db_session.query(db.CustomCSS).filter_by(royal_id=user_id).one_or_none() + profile_data = db_session.query(db.ProfileData).filter_by(royal_id=user_id).one_or_none() if request.method == "GET": db_session.close() if user_id is None: return redirect(url_for("page_login")) - return render_template("setcss.html", css=ccss.css, config=config) + return render_template("setcss.html", data=profile_data, config=config) elif request.method == "POST": if user_id is None: return redirect(url_for("page_login")) css = request.form.get("css", "") + bio = request.form.get("bio", "") if "