fix #4
This commit is contained in:
@@ -38,8 +38,10 @@ def delete(mid):
|
||||
@login_required
|
||||
def edit(mid):
|
||||
db = get_db()
|
||||
edit_location=None
|
||||
|
||||
if request.method == "POST":
|
||||
|
||||
if "name" in request.form:
|
||||
name = request.form['name']
|
||||
bio = request.form['bio']
|
||||
@@ -49,6 +51,8 @@ def edit(mid):
|
||||
db.execute("UPDATE member SET member_name=(?), bio=(?), subtitle=(?), public=(?), theme=(?) WHERE id=(?)",(name, bio, subtitle, privacy, theme, mid))
|
||||
db.commit()
|
||||
|
||||
edit_location="details"
|
||||
|
||||
if "file" in request.files:
|
||||
# here we are just saving the uploaded file to the icons folder.
|
||||
# we're not going hard on security because we expect there to only be 1 admin
|
||||
@@ -56,22 +60,48 @@ def edit(mid):
|
||||
file = request.files["file"]
|
||||
filename = str(uuid.uuid4()) + "." + file.filename.split(".")[1]
|
||||
file.save(os.path.join(current_app.config["ICON_UPLOAD_FOLDER"], filename))
|
||||
db.execute("INSERT INTO icons (member_id, icon_location) VALUES (?, ?)", (mid, filename),)
|
||||
db.execute("INSERT INTO icons (member_id, icon_location) VALUES (?, ?)", (mid, filename))
|
||||
db.commit()
|
||||
|
||||
edit_location="icons"
|
||||
|
||||
if "gid_add" in request.form:
|
||||
gid = request.form["gid_add"]
|
||||
db.execute("INSERT INTO group_members (group_id,member_id) VALUES (?,?)",(gid,mid))
|
||||
db.commit()
|
||||
|
||||
edit_location="groups"
|
||||
|
||||
elif "gid_remove" in request.form:
|
||||
gid = request.form["gid_remove"]
|
||||
db.execute("DELETE FROM group_members WHERE group_id=(?) AND member_id=(?)",(gid,mid))
|
||||
db.commit()
|
||||
|
||||
edit_location="groups"
|
||||
|
||||
if "blinkie" in request.files:
|
||||
file = request.files["blinkie"]
|
||||
filename = str(uuid.uuid4()) + "." + file.filename.split(".")[1]
|
||||
file.save(os.path.join(current_app.config["BLINKIES_UPLOAD_FOLDER"], filename))
|
||||
db.execute("INSERT INTO blinkies (member_id, blinkie_location) VALUES (?, ?)", (mid, filename))
|
||||
db.commit()
|
||||
|
||||
edit_location="blinkies"
|
||||
|
||||
if "stamp" in request.files:
|
||||
file = request.files["stamp"]
|
||||
filename = str(uuid.uuid4()) + "." + file.filename.split(".")[1]
|
||||
file.save(os.path.join(current_app.config["STAMPS_UPLOAD_FOLDER"], filename))
|
||||
db.execute("INSERT INTO stamps (member_id, stamp_location) VALUES (?, ?)", (mid, filename))
|
||||
db.commit()
|
||||
|
||||
edit_location="stamps"
|
||||
|
||||
|
||||
member = db.execute("SELECT * FROM member WHERE id=(?)",(mid,)).fetchone()
|
||||
icons = db.execute("SELECT * FROM icons WHERE member_id=(?)",(mid,)).fetchall()
|
||||
blinkies = db.execute("SELECT * FROM blinkies WHERE member_id=(?)",(mid,)).fetchall()
|
||||
stamps = db.execute("SELECT * FROM stamps WHERE member_id=(?)",(mid,)).fetchall()
|
||||
|
||||
groups = db.execute("SELECT * FROM groups").fetchall()
|
||||
member_groups = db.execute("SELECT * FROM group_members WHERE member_id=(?)",(mid,)).fetchall()
|
||||
@@ -91,7 +121,7 @@ def edit(mid):
|
||||
|
||||
themes = os.listdir(current_app.config["THEMES_FOLDER"])
|
||||
|
||||
return render_template("manage/edit.html", member=member, icons=icons, unjoined_groups=unjoined_groups, joined_groups=joined_groups, themes=themes)
|
||||
return render_template("manage/edit.html", member=member, icons=icons, unjoined_groups=unjoined_groups, joined_groups=joined_groups, themes=themes, edit_location=edit_location, blinkies=blinkies, stamps=stamps)
|
||||
|
||||
@bp.route("/set_main_icon/<mid>/<icon_id>")
|
||||
@login_required
|
||||
@@ -164,10 +194,21 @@ def remove_home(mid,location):
|
||||
return redirect(url_for('home.full_list'))
|
||||
|
||||
|
||||
@bp.route("/assets")
|
||||
@bp.route("/assets", methods=('GET', 'POST'))
|
||||
@login_required
|
||||
def assets():
|
||||
db = get_db()
|
||||
|
||||
if "blinkie" in request.files:
|
||||
file = request.files["blinkie"]
|
||||
filename = file.filename
|
||||
file.save(os.path.join(current_app.config["BLINKIES_UPLOAD_FOLDER"], filename))
|
||||
|
||||
if "stamp" in request.files:
|
||||
file = request.files["stamp"]
|
||||
filename = file.filename
|
||||
file.save(os.path.join(current_app.config["STAMPS_UPLOAD_FOLDER"], filename))
|
||||
|
||||
icons = db.execute("SELECT * FROM icons").fetchall()
|
||||
icon_storage = os.listdir(current_app.config["ICON_UPLOAD_FOLDER"])
|
||||
|
||||
@@ -188,7 +229,10 @@ def assets():
|
||||
if not in_storage:
|
||||
unlinked_icons.append(i)
|
||||
|
||||
return render_template("manage/assets.html", icons=unlinked_icons, icon_storage=i_storage)
|
||||
blinkies = os.listdir(current_app.config["BLINKIES_UPLOAD_FOLDER"])
|
||||
stamps = os.listdir(current_app.config["STAMPS_UPLOAD_FOLDER"])
|
||||
|
||||
return render_template("manage/assets.html", icons=unlinked_icons, icon_storage=i_storage, blinkies=blinkies, stamps=stamps)
|
||||
|
||||
@bp.route("/delete_idb")
|
||||
@login_required
|
||||
|
||||
Reference in New Issue
Block a user