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

Add email field

This commit is contained in:
Steffo 2019-01-17 13:06:57 +01:00
parent f0cca142c4
commit dc76a28718
3 changed files with 8 additions and 14 deletions

View file

@ -71,7 +71,7 @@ code {
font-family: "Consolas", "Source Code Pro", monospace;
}
input[type="text"], input[type="password"] {
input[type="text"], input[type="password"], input[type="email"] {
background-color: rgba(red(@text-color), green(@text-color), blue(@text-color), 0.1);
color: @text-color;
border: none;

View file

@ -9,6 +9,7 @@
Modifica profilo
</h1>
<form action="{{ url_for('page_editprofile') }}" method="POST">
<input type="email" name="email" placeholder="La tua e-mail (Gravatar)" value="{{ royal.email }}"><br>
Puoi usare il <a href="{{ url_for('page_wiki', key='Meta') }}">Markdown</a> nella tua bio.
<textarea name="bio" placeholder="Scrivi la tua bio qui... (Markdown supportato)">{{ data.bio }}</textarea>
Se vuoi, puoi personalizzare il tuo profilo con un tuo <a href="https://www.w3schools.com/css/css_howto.asp">foglio di stile!</a>

View file

@ -194,33 +194,26 @@ def page_password():
@app.route("/editprofile", methods=["GET", "POST"])
@require_login
def page_editprofile():
profile_data = fl_g.session.query(db.ProfileData).filter_by(royal_id=fl_g.user.id).join(db.Royal).one_or_none()
royal = fl_g.session.query(db.Royal).filter_by(id=fl_g.user.id).one()
profile_data = fl_g.session.query(db.ProfileData).filter_by(royal=royal).one_or_none()
if request.method == "GET":
return render_template("profileedit.html", data=profile_data)
return render_template("profileedit.html", royal=royal, data=profile_data)
elif request.method == "POST":
css = request.form.get("css", "")
bio = request.form.get("bio", "")
email = request.form.get("email")
if "</style" in css:
abort(400)
return
royal.email = email
if profile_data is None:
profile_data = db.ProfileData(royal_id=fl_g.user.id, css=css, bio=bio)
profile_data = db.ProfileData(royal=royal, css=css, bio=bio)
fl_g.session.add(profile_data)
fl_g.session.flush()
profile_data.royal.fiorygi += 1
try:
telegram_bot.send_message(config["Telegram"]["main_group"],
f'⭐️ {profile_data.royal.username} ha'
f' <a href="http://ryg.steffo.eu/editprofile">configurato la sua bio</a>'
f' su Royalnet e ha ottenuto un fioryg!',
parse_mode="HTML", disable_web_page_preview=True, disable_notification=True)
except Exception:
pass
else:
profile_data.css = css
profile_data.bio = bio
fl_g.session.commit()
royal = fl_g.session.query(db.Royal).filter_by(id=fl_g.user.id).one()
return redirect(url_for("page_profile", name=royal.username))