fix #4
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -13,3 +13,5 @@ dist/
|
|||||||
build/
|
build/
|
||||||
*.egg-info/
|
*.egg-info/
|
||||||
/myriad/static/icons
|
/myriad/static/icons
|
||||||
|
/myriad/static/blinkies
|
||||||
|
/myriad/static/stamps
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ logged in users are presumed to all be admins with distinction only between bein
|
|||||||
|
|
||||||
in the blog view, member privacy outweighs individual post privacy. if a private member makes a public post, it will not show up in the public feed. however, if that member switches to public, their public posts will all become publicly viewable (but private posts will remain private).
|
in the blog view, member privacy outweighs individual post privacy. if a private member makes a public post, it will not show up in the public feed. however, if that member switches to public, their public posts will all become publicly viewable (but private posts will remain private).
|
||||||
|
|
||||||
|
the blinkies and stamps stuff is literally just because i want an easy way to upload them when i find them. and im the dev so i get to decide mwa ha ha
|
||||||
|
|
||||||
# dev set up (windows)
|
# dev set up (windows)
|
||||||
|
|
||||||
- after cloning, run `py -3 -m venv .venv` in the root directory and then `.venv\Scripts\activate`
|
- after cloning, run `py -3 -m venv .venv` in the root directory and then `.venv\Scripts\activate`
|
||||||
|
|||||||
@@ -50,8 +50,10 @@ def page(mid):
|
|||||||
blog = db.execute("SELECT * FROM blog WHERE member_id=(?) ORDER BY created DESC",(mid,)).fetchall()
|
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()
|
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()
|
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")
|
@bp.route("/groups")
|
||||||
def groups():
|
def groups():
|
||||||
|
|||||||
@@ -38,8 +38,10 @@ def delete(mid):
|
|||||||
@login_required
|
@login_required
|
||||||
def edit(mid):
|
def edit(mid):
|
||||||
db = get_db()
|
db = get_db()
|
||||||
|
edit_location=None
|
||||||
|
|
||||||
if request.method == "POST":
|
if request.method == "POST":
|
||||||
|
|
||||||
if "name" in request.form:
|
if "name" in request.form:
|
||||||
name = request.form['name']
|
name = request.form['name']
|
||||||
bio = request.form['bio']
|
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.execute("UPDATE member SET member_name=(?), bio=(?), subtitle=(?), public=(?), theme=(?) WHERE id=(?)",(name, bio, subtitle, privacy, theme, mid))
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
edit_location="details"
|
||||||
|
|
||||||
if "file" in request.files:
|
if "file" in request.files:
|
||||||
# here we are just saving the uploaded file to the icons folder.
|
# 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
|
# 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"]
|
file = request.files["file"]
|
||||||
filename = str(uuid.uuid4()) + "." + file.filename.split(".")[1]
|
filename = str(uuid.uuid4()) + "." + file.filename.split(".")[1]
|
||||||
file.save(os.path.join(current_app.config["ICON_UPLOAD_FOLDER"], filename))
|
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()
|
db.commit()
|
||||||
|
|
||||||
|
edit_location="icons"
|
||||||
|
|
||||||
if "gid_add" in request.form:
|
if "gid_add" in request.form:
|
||||||
gid = request.form["gid_add"]
|
gid = request.form["gid_add"]
|
||||||
db.execute("INSERT INTO group_members (group_id,member_id) VALUES (?,?)",(gid,mid))
|
db.execute("INSERT INTO group_members (group_id,member_id) VALUES (?,?)",(gid,mid))
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
|
edit_location="groups"
|
||||||
|
|
||||||
elif "gid_remove" in request.form:
|
elif "gid_remove" in request.form:
|
||||||
gid = request.form["gid_remove"]
|
gid = request.form["gid_remove"]
|
||||||
db.execute("DELETE FROM group_members WHERE group_id=(?) AND member_id=(?)",(gid,mid))
|
db.execute("DELETE FROM group_members WHERE group_id=(?) AND member_id=(?)",(gid,mid))
|
||||||
db.commit()
|
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()
|
member = db.execute("SELECT * FROM member WHERE id=(?)",(mid,)).fetchone()
|
||||||
icons = db.execute("SELECT * FROM icons WHERE member_id=(?)",(mid,)).fetchall()
|
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()
|
groups = db.execute("SELECT * FROM groups").fetchall()
|
||||||
member_groups = db.execute("SELECT * FROM group_members WHERE member_id=(?)",(mid,)).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"])
|
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>")
|
@bp.route("/set_main_icon/<mid>/<icon_id>")
|
||||||
@login_required
|
@login_required
|
||||||
@@ -164,10 +194,21 @@ def remove_home(mid,location):
|
|||||||
return redirect(url_for('home.full_list'))
|
return redirect(url_for('home.full_list'))
|
||||||
|
|
||||||
|
|
||||||
@bp.route("/assets")
|
@bp.route("/assets", methods=('GET', 'POST'))
|
||||||
@login_required
|
@login_required
|
||||||
def assets():
|
def assets():
|
||||||
db = get_db()
|
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()
|
icons = db.execute("SELECT * FROM icons").fetchall()
|
||||||
icon_storage = os.listdir(current_app.config["ICON_UPLOAD_FOLDER"])
|
icon_storage = os.listdir(current_app.config["ICON_UPLOAD_FOLDER"])
|
||||||
|
|
||||||
@@ -188,7 +229,10 @@ def assets():
|
|||||||
if not in_storage:
|
if not in_storage:
|
||||||
unlinked_icons.append(i)
|
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")
|
@bp.route("/delete_idb")
|
||||||
@login_required
|
@login_required
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ DROP TABLE IF EXISTS icons;
|
|||||||
DROP TABLE IF EXISTS groups;
|
DROP TABLE IF EXISTS groups;
|
||||||
DROP TABLE IF EXISTS group_members;
|
DROP TABLE IF EXISTS group_members;
|
||||||
DROP TABLE IF EXISTS blog;
|
DROP TABLE IF EXISTS blog;
|
||||||
|
DROP TABLE IF EXISTS blinkies;
|
||||||
|
DROP TABLE IF EXISTS stamps;
|
||||||
|
|
||||||
CREATE TABLE user (
|
CREATE TABLE user (
|
||||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||||
@@ -57,4 +59,18 @@ CREATE TABLE blog (
|
|||||||
content TEXT,
|
content TEXT,
|
||||||
public BOOLEAN NOT NULL DEFAULT 1,
|
public BOOLEAN NOT NULL DEFAULT 1,
|
||||||
FOREIGN KEY (member_id) REFERENCES member (id)
|
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 %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="heading big">Blinkies</div>
|
<div class="heading big">Blinkies</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="heading big">Stamps</div>
|
<div class="heading big">Stamps</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -7,13 +7,12 @@
|
|||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="container">
|
<div class="container">
|
||||||
|
|
||||||
|
|
||||||
<a href="{{url_for('home.page', mid=member[0])}}">View {{member[3]}}'s page</a>
|
<a href="{{url_for('home.page', mid=member[0])}}">View {{member[3]}}'s page</a>
|
||||||
<br class="clear" />
|
<br class="clear" />
|
||||||
|
|
||||||
<div class="heading">Edit Details</div>
|
<div class="heading">Edit Details</div>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post" id="details">
|
||||||
<label for="name">Name</label>
|
<label for="name">Name</label>
|
||||||
<input name="name" id="name" value="{{ member[3] }}" required><br>
|
<input name="name" id="name" value="{{ member[3] }}" required><br>
|
||||||
<label for="subtitle">Subtitle</label>
|
<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!
|
<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>
|
<div class="heading">Manage groups</div>
|
||||||
|
|
||||||
<form method="post">
|
<form method="post" id="groups">
|
||||||
<select name="gid_add" id="gid_add">
|
<select name="gid_add" id="gid_add">
|
||||||
{% for group in unjoined_groups %}
|
{% for group in unjoined_groups %}
|
||||||
<option value="{{group[0]}}">{{group[1]}}</option>
|
<option value="{{group[0]}}">{{group[1]}}</option>
|
||||||
@@ -58,22 +58,49 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="heading">Manage Icons</div>
|
<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="file" name="file">
|
||||||
<input type="submit" value="Upload New Icon">
|
<input type="submit" value="Upload New Icon">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
<div id="manage_icons">
|
<div id="manage_icons" id="icons">
|
||||||
{% for icon in icons %}
|
{% for icon in icons %}
|
||||||
|
|
||||||
<img class="icon" src="{{ url_for('static', filename='icons/'+icon[2]) }}">
|
<img class="icon" src="{{ url_for('static', filename='icons/'+icon[2]) }}">
|
||||||
<br class="clear" />
|
<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>
|
<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" />
|
<br class="clear" />
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</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>
|
</div>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -47,11 +47,27 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% if all_icons|length > 1 %}
|
{% 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 %}
|
{% for i in all_icons %}
|
||||||
<img class="icon" src="{{ url_for('static', filename='icons/'+i[0]) }}">
|
<img class="icon" src="{{ url_for('static', filename='icons/'+i[0]) }}">
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% 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 %}
|
{% endif %}
|
||||||
|
|||||||
Reference in New Issue
Block a user