fix #4
This commit is contained in:
@@ -50,8 +50,10 @@ def page(mid):
|
||||
blog = db.execute("SELECT * FROM blog WHERE member_id=(?) ORDER BY created DESC",(mid,)).fetchall()
|
||||
icon = db.execute("SELECT icon_location FROM icons WHERE id=(?)",(member[6],)).fetchone()
|
||||
all_icons = db.execute("SELECT icon_location FROM icons WHERE member_id=(?)",(mid,)).fetchall()
|
||||
blinkies = db.execute("SELECT blinkie_location FROM blinkies WHERE member_id=(?)",(mid,)).fetchall()
|
||||
stamps = db.execute("SELECT stamp_location FROM stamps WHERE member_id=(?)",(mid,)).fetchall()
|
||||
|
||||
return render_template('page.html', member=member, blog=blog, icon=icon, all_icons=all_icons)
|
||||
return render_template('page.html', member=member, blog=blog, icon=icon, all_icons=all_icons, blinkies=blinkies, stamps=stamps)
|
||||
|
||||
@bp.route("/groups")
|
||||
def groups():
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -4,6 +4,8 @@ DROP TABLE IF EXISTS icons;
|
||||
DROP TABLE IF EXISTS groups;
|
||||
DROP TABLE IF EXISTS group_members;
|
||||
DROP TABLE IF EXISTS blog;
|
||||
DROP TABLE IF EXISTS blinkies;
|
||||
DROP TABLE IF EXISTS stamps;
|
||||
|
||||
CREATE TABLE user (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
@@ -57,4 +59,18 @@ CREATE TABLE blog (
|
||||
content TEXT,
|
||||
public BOOLEAN NOT NULL DEFAULT 1,
|
||||
FOREIGN KEY (member_id) REFERENCES member (id)
|
||||
);
|
||||
|
||||
CREATE TABLE blinkies (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
member_id INTEGER NOT NULL,
|
||||
blinkie_location TEXT NOT NULL,
|
||||
FOREIGN KEY (member_id) REFERENCES member (id)
|
||||
);
|
||||
|
||||
CREATE TABLE stamps (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
member_id INTEGER NOT NULL,
|
||||
stamp_location TEXT NOT NULL,
|
||||
FOREIGN KEY (member_id) REFERENCES member (id)
|
||||
);
|
||||
@@ -36,8 +36,10 @@
|
||||
{% endif %}
|
||||
|
||||
<div class="heading big">Blinkies</div>
|
||||
|
||||
|
||||
<div class="heading big">Stamps</div>
|
||||
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -7,13 +7,12 @@
|
||||
{% block content %}
|
||||
<div class="container">
|
||||
|
||||
|
||||
<a href="{{url_for('home.page', mid=member[0])}}">View {{member[3]}}'s page</a>
|
||||
<br class="clear" />
|
||||
|
||||
<div class="heading">Edit Details</div>
|
||||
|
||||
<form method="post">
|
||||
<form method="post" id="details">
|
||||
<label for="name">Name</label>
|
||||
<input name="name" id="name" value="{{ member[3] }}" required><br>
|
||||
<label for="subtitle">Subtitle</label>
|
||||
@@ -36,9 +35,10 @@
|
||||
|
||||
<a href="{{ url_for('manage.delete', mid=member[0]) }}" class="danger">Delete member</a> - WARNING: this is permanent and cannot be undone!
|
||||
|
||||
|
||||
<div class="heading">Manage groups</div>
|
||||
|
||||
<form method="post">
|
||||
<form method="post" id="groups">
|
||||
<select name="gid_add" id="gid_add">
|
||||
{% for group in unjoined_groups %}
|
||||
<option value="{{group[0]}}">{{group[1]}}</option>
|
||||
@@ -58,22 +58,49 @@
|
||||
|
||||
|
||||
<div class="heading">Manage Icons</div>
|
||||
<form method="post" enctype="multipart/form-data">
|
||||
<form method="post" enctype="multipart/form-data" id="icons">
|
||||
<input type="file" name="file">
|
||||
<input type="submit" value="Upload New Icon">
|
||||
</form>
|
||||
|
||||
<div id="manage_icons">
|
||||
<div id="manage_icons" id="icons">
|
||||
{% for icon in icons %}
|
||||
|
||||
<img class="icon" src="{{ url_for('static', filename='icons/'+icon[2]) }}">
|
||||
<br class="clear" />
|
||||
<a href="{{ url_for('manage.set_main_icon', mid=member[0], icon_id=icon[0]) }}">Set Main Icon</a> ☆ <a href="{{ url_for('manage.delete_icon', mid=member[0], icon_id=icon[0]) }}">Delete Icon</a>
|
||||
<br class="clear" />
|
||||
<hr>
|
||||
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
|
||||
|
||||
<div class="heading">Manage Blinkies</div>
|
||||
<form method="post" enctype="multipart/form-data" id="blinkies">
|
||||
<input type="file" name="blinkie">
|
||||
<input type="submit" value="Upload to Blinkies">
|
||||
</form>
|
||||
|
||||
{% for blinkie in blinkies %}
|
||||
<img src="{{ url_for('static', filename='blinkies/'+blinkie[2]) }}">
|
||||
{% endfor %}
|
||||
|
||||
|
||||
<div class="heading">Manage Stamps</div>
|
||||
<form method="post" enctype="multipart/form-data" id="stamps">
|
||||
<input type="file" name="stamp">
|
||||
<input type="submit" value="Upload to Stamps">
|
||||
</form>
|
||||
|
||||
{% for stamp in stamps %}
|
||||
<img src="{{ url_for('static', filename='stamps/'+stamp[2]) }}">
|
||||
{% endfor %}
|
||||
|
||||
|
||||
|
||||
{% if edit_location %}
|
||||
<script>document.getElementById('{{edit_location}}').scrollIntoView();</script>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
||||
@@ -47,11 +47,27 @@
|
||||
{% endif %}
|
||||
|
||||
{% if all_icons|length > 1 %}
|
||||
<div class="heading big">{{member[3]}}'s icons</div>
|
||||
<div class="heading big">Icons</div>
|
||||
{% for i in all_icons %}
|
||||
<img class="icon" src="{{ url_for('static', filename='icons/'+i[0]) }}">
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<br class="clear" />
|
||||
|
||||
{% if blinkies|length > 0 %}
|
||||
<div class="heading big">Blinkies</div>
|
||||
{% for blinkie in blinkies %}
|
||||
<img src="{{ url_for('static', filename='blinkies/'+blinkie[0]) }}">
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<br class="clear" />
|
||||
|
||||
{% if stamps|length > 0 %}
|
||||
<div class="heading big">Stamps</div>
|
||||
{% for stamp in stamps %}
|
||||
<img src="{{ url_for('static', filename='stamps/'+stamp[0]) }}">
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
|
||||
|
||||
{% endif %}
|
||||
|
||||
Reference in New Issue
Block a user