mirror of
https://github.com/RYGhub/royalnet.git
synced 2024-11-27 13:34:28 +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)
|
||||
|
||||
|
||||
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):
|
||||
|
|
|
@ -22,6 +22,14 @@
|
|||
<h1>
|
||||
Profilo di {{ ryg.username }} {% if session.get('user_id', '') == ryg.id %}<a href="/setcss" id="edit-css">Modifica</a>{% endif %}
|
||||
</h1>
|
||||
{% if css.bio %}
|
||||
<div class="box upper-box">
|
||||
Bio
|
||||
</div>
|
||||
<div class="box lower-box">
|
||||
{{ css.bio }}
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="game-panels">
|
||||
{% with record = ryg %}
|
||||
{% include "minis/ryg.html" %}
|
||||
|
|
|
@ -1,15 +1,16 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% block pagetitle %}
|
||||
CSS
|
||||
Modifica profilo
|
||||
{% endblock %}
|
||||
|
||||
{% block body %}
|
||||
<h1>
|
||||
CSS
|
||||
Modifica profilo
|
||||
</h1>
|
||||
<form action="{{ url_for('page_setcss') }}" method="POST">
|
||||
<textarea name="css" placeholder="Incolla il CSS per il tuo profilo qui...">{{ css }}</textarea>
|
||||
<form action="{{ url_for('page_editprofile') }}" method="POST">
|
||||
<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">
|
||||
</form>
|
||||
{% endblock %}
|
20
webserver.py
20
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 "</style" in css:
|
||||
abort(400)
|
||||
return
|
||||
if ccss is None:
|
||||
ccss = db.CustomCSS(royal_id=user_id, css=css)
|
||||
db_session.add(ccss)
|
||||
if profile_data is None:
|
||||
profile_data = db.ProfileData(royal_id=user_id, css=css, bio=bio)
|
||||
db_session.add(profile_data)
|
||||
else:
|
||||
ccss.css = request.form.get("css", "")
|
||||
profile_data.css = css
|
||||
profile_data.bio = bio
|
||||
db_session.commit()
|
||||
royal = db_session.query(db.Royal).filter_by(id=user_id).one()
|
||||
db_session.close()
|
||||
|
|
Loading…
Reference in a new issue