mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-23 19:44:20 +00:00
Add bio to profiles
This commit is contained in:
parent
daa54fe1ee
commit
1025802ab1
4 changed files with 29 additions and 17 deletions
9
db.py
9
db.py
|
@ -821,13 +821,14 @@ class AprilFoolsBan(Base):
|
||||||
datetime = Column(DateTime, nullable=False)
|
datetime = Column(DateTime, nullable=False)
|
||||||
|
|
||||||
|
|
||||||
class CustomCSS(Base):
|
class ProfileData(Base):
|
||||||
__tablename__ = "customcss"
|
__tablename__ = "profiledata"
|
||||||
|
|
||||||
royal_id = Column(Integer, ForeignKey("royals.id"), primary_key=True)
|
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):
|
class WikiEntry(Base):
|
||||||
|
|
|
@ -22,6 +22,14 @@
|
||||||
<h1>
|
<h1>
|
||||||
Profilo di {{ ryg.username }} {% if session.get('user_id', '') == ryg.id %}<a href="/setcss" id="edit-css">Modifica</a>{% endif %}
|
Profilo di {{ ryg.username }} {% if session.get('user_id', '') == ryg.id %}<a href="/setcss" id="edit-css">Modifica</a>{% endif %}
|
||||||
</h1>
|
</h1>
|
||||||
|
{% if css.bio %}
|
||||||
|
<div class="box upper-box">
|
||||||
|
Bio
|
||||||
|
</div>
|
||||||
|
<div class="box lower-box">
|
||||||
|
{{ css.bio }}
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
<div class="game-panels">
|
<div class="game-panels">
|
||||||
{% with record = ryg %}
|
{% with record = ryg %}
|
||||||
{% include "minis/ryg.html" %}
|
{% include "minis/ryg.html" %}
|
||||||
|
|
|
@ -1,15 +1,16 @@
|
||||||
{% extends 'base.html' %}
|
{% extends 'base.html' %}
|
||||||
|
|
||||||
{% block pagetitle %}
|
{% block pagetitle %}
|
||||||
CSS
|
Modifica profilo
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<h1>
|
<h1>
|
||||||
CSS
|
Modifica profilo
|
||||||
</h1>
|
</h1>
|
||||||
<form action="{{ url_for('page_setcss') }}" method="POST">
|
<form action="{{ url_for('page_editprofile') }}" method="POST">
|
||||||
<textarea name="css" placeholder="Incolla il CSS per il tuo profilo qui...">{{ css }}</textarea>
|
<textarea name="bio" placeholder="Scrivi la tua bio qui...">{{ data.bio }}</textarea>
|
||||||
|
<textarea name="css" placeholder="Incolla il CSS per il tuo profilo qui...">{{ data.css }}</textarea>
|
||||||
<input type="submit" value="Salva">
|
<input type="submit" value="Salva">
|
||||||
</form>
|
</form>
|
||||||
{% endblock %}
|
{% endblock %}
|
20
webserver.py
20
webserver.py
|
@ -74,7 +74,7 @@ def page_profile(name: str):
|
||||||
db_session.close()
|
db_session.close()
|
||||||
abort(404)
|
abort(404)
|
||||||
return
|
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()
|
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()
|
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()
|
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"))
|
return redirect(url_for("page_login"))
|
||||||
|
|
||||||
|
|
||||||
@app.route("/setcss", methods=["GET", "POST"])
|
@app.route("/editprofile", methods=["GET", "POST"])
|
||||||
def page_setcss():
|
def page_editprofile():
|
||||||
user_id = fl_session.get("user_id")
|
user_id = fl_session.get("user_id")
|
||||||
db_session = db.Session()
|
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":
|
if request.method == "GET":
|
||||||
db_session.close()
|
db_session.close()
|
||||||
if user_id is None:
|
if user_id is None:
|
||||||
return redirect(url_for("page_login"))
|
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":
|
elif request.method == "POST":
|
||||||
if user_id is None:
|
if user_id is None:
|
||||||
return redirect(url_for("page_login"))
|
return redirect(url_for("page_login"))
|
||||||
css = request.form.get("css", "")
|
css = request.form.get("css", "")
|
||||||
|
bio = request.form.get("bio", "")
|
||||||
if "</style" in css:
|
if "</style" in css:
|
||||||
abort(400)
|
abort(400)
|
||||||
return
|
return
|
||||||
if ccss is None:
|
if profile_data is None:
|
||||||
ccss = db.CustomCSS(royal_id=user_id, css=css)
|
profile_data = db.ProfileData(royal_id=user_id, css=css, bio=bio)
|
||||||
db_session.add(ccss)
|
db_session.add(profile_data)
|
||||||
else:
|
else:
|
||||||
ccss.css = request.form.get("css", "")
|
profile_data.css = css
|
||||||
|
profile_data.bio = bio
|
||||||
db_session.commit()
|
db_session.commit()
|
||||||
royal = db_session.query(db.Royal).filter_by(id=user_id).one()
|
royal = db_session.query(db.Royal).filter_by(id=user_id).one()
|
||||||
db_session.close()
|
db_session.close()
|
||||||
|
|
Loading…
Reference in a new issue