fix #15 REQUIRES DB INIT

This commit is contained in:
cube
2026-04-03 21:49:39 +01:00
parent 567f736d0d
commit b40cb00d4d
4 changed files with 87 additions and 41 deletions

View File

@@ -80,7 +80,19 @@ 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" edit_location = "details"
if "page_settings" in request.form:
show_groups = "show_groups" in request.form
show_blog = "show_blog" in request.form
show_icons = "show_icons" in request.form
show_blinkies = "show_blinkies" in request.form
show_stamps = "show_stamps" in request.form
db.execute("UPDATE member SET show_groups=(?), show_blog=(?), show_icons=(?), show_blinkies=(?), show_stamps=(?) WHERE id=(?)",(show_groups, show_blog, show_icons, show_blinkies, show_stamps, mid))
db.commit()
edit_location = "page_settings"
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.
@@ -92,21 +104,21 @@ def edit(mid):
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" 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" 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" edit_location = "groups"
if "blinkie" in request.files: if "blinkie" in request.files:
file = request.files["blinkie"] file = request.files["blinkie"]
@@ -115,7 +127,7 @@ def edit(mid):
db.execute("INSERT INTO blinkies (member_id, blinkie_location) VALUES (?, ?)", (mid, filename)) db.execute("INSERT INTO blinkies (member_id, blinkie_location) VALUES (?, ?)", (mid, filename))
db.commit() db.commit()
edit_location="blinkies" edit_location = "blinkies"
if "stamp" in request.files: if "stamp" in request.files:
file = request.files["stamp"] file = request.files["stamp"]
@@ -124,7 +136,7 @@ def edit(mid):
db.execute("INSERT INTO stamps (member_id, stamp_location) VALUES (?, ?)", (mid, filename)) db.execute("INSERT INTO stamps (member_id, stamp_location) VALUES (?, ?)", (mid, filename))
db.commit() db.commit()
edit_location="stamps" edit_location = "stamps"
member = db.execute("SELECT * FROM member WHERE id=(?)",(mid,)).fetchone() member = db.execute("SELECT * FROM member WHERE id=(?)",(mid,)).fetchone()

View File

@@ -27,6 +27,16 @@ CREATE TABLE member (
front BOOLEAN NOT NULL DEFAULT 0, front BOOLEAN NOT NULL DEFAULT 0,
public BOOLEAN NOT NULL DEFAULT 1, public BOOLEAN NOT NULL DEFAULT 1,
theme TEXT NOT NULL DEFAULT 'default', theme TEXT NOT NULL DEFAULT 'default',
show_blog BOOLEAN NOT NULL DEFAULT 1,
show_icons BOOLEAN NOT NULL DEFAULT 1,
show_blinkies BOOLEAN NOT NULL DEFAULT 1,
show_stamps BOOLEAN NOT NULL DEFAULT 1,
show_groups BOOLEAN NOT NULL DEFAULT 1,
blog_title TEXT DEFAULT "Blog",
icons_title TEXT DEFAULT "Icons",
blinkies_title TEXT DEFAULT "Blinkies",
stamps_title TEXT DEFAULT "Stamps",
groups_title TEXT DEFAULT "Groups",
FOREIGN KEY (user_id) REFERENCES user (id), FOREIGN KEY (user_id) REFERENCES user (id),
FOREIGN KEY (main_icon) REFERENCES icons (id) FOREIGN KEY (main_icon) REFERENCES icons (id)
); );

View File

@@ -33,6 +33,22 @@
<input type="submit" value="Submit"> <input type="submit" value="Submit">
</form> </form>
<div class="heading">Public Page Settings</div>
<form method="post" id="page_settings">
<p>Select which sections to show on this member's public page</p>
<input type="checkbox" id="show_groups" name="show_groups" {% if member[15] %}checked{% endif %}>
<label for="show_groups">Groups</label><br>
<input type="checkbox" id="show_blog" name="show_blog" {% if member[11] %}checked{% endif %}>
<label for="show_blog">Blog</label><br>
<input type="checkbox" id="show_icons" name="show_icons" {% if member[12] %}checked{% endif %}>
<label for="show_icons">Icons</label><br>
<input type="checkbox" id="show_blinkies" name="show_blinkies" {% if member[13] %}checked{% endif %}>
<label for="show_blinkies">Blinkies</label><br>
<input type="checkbox" id="show_stamps" name="show_stamps" {% if member[14] %}checked{% endif %}>
<label for="show_stamps">Stamps</label><br>
<input type="submit" name="page_settings" value="Submit">
</form>
{% if unjoined_groups or joined_groups %} {% if unjoined_groups or joined_groups %}
<div class="heading">Manage groups</div> <div class="heading">Manage groups</div>

View File

@@ -26,50 +26,58 @@
{{member[5].replace('\n', '<br>')|safe}} {{member[5].replace('\n', '<br>')|safe}}
</div> </div>
<br class="clear" /> <br class="clear" />
{% if blog|length > 0 %} {% if member[11] %}
{% if not g.user and not blog_public_show %} {% if blog|length > 0 %}
{% else %} {% if not g.user and not blog_public_show %}
<div class="heading big">{{member[3]}}'s blog</div>
{% endif %}
<div id="blog">
{% for post in blog %}
{% if not g.user and post[5]==0 %}
{% else %} {% else %}
<div class="post"> <div class="heading big">{{member[3]}}'s blog</div>
<div class="title">{{post[3]|safe}}</div>
<div class="timestamp">{{post[2]}} {% if g.user %}{% if post[5]==0 %}(Private){% else %}(Public){% endif %}{% endif %}</div>
<div class="content">
{{post[4].replace('\n', '<br>')|safe}}
</div>
{% if g.user %}<a href="{{url_for('blog.toggle',pid=post[0], location=member[0])}}">Toggle privacy</a> | <a href="{{url_for('blog.edit',pid=post[0],location=member[0])}}">Edit Post</a> | <a href="{{url_for('blog.delete', pid=post[0], location=member[0])}}" class="danger">Delete post</a>{% endif %}
</div>
{% endif %} {% endif %}
<div id="blog">
{% for post in blog %}
{% if not g.user and post[5]==0 %}
{% else %}
<div class="post">
<div class="title">{{post[3]|safe}}</div>
<div class="timestamp">{{post[2]}} {% if g.user %}{% if post[5]==0 %}(Private){% else %}(Public){% endif %}{% endif %}</div>
<div class="content">
{{post[4].replace('\n', '<br>')|safe}}
</div>
{% if g.user %}<a href="{{url_for('blog.toggle',pid=post[0], location=member[0])}}">Toggle privacy</a> | <a href="{{url_for('blog.edit',pid=post[0],location=member[0])}}">Edit Post</a> | <a href="{{url_for('blog.delete', pid=post[0], location=member[0])}}" class="danger">Delete post</a>{% endif %}
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}
{% endif %}
{% if member[13] %}
{% if blinkies|length > 0 %}
<div class="heading big">Blinkies</div>
{% for blinkie in blinkies %}
<img class="blinkie" src="{{ url_for('static', filename='blinkies/'+blinkie[0]) }}">
{% endfor %} {% endfor %}
</div> {% endif %}
{% endif %}
{% if blinkies|length > 0 %}
<div class="heading big">Blinkies</div>
{% for blinkie in blinkies %}
<img class="blinkie" src="{{ url_for('static', filename='blinkies/'+blinkie[0]) }}">
{% endfor %}
{% endif %} {% endif %}
<br class="clear" /> <br class="clear" />
{% if stamps|length > 0 %} {% if member[14] %}
<div class="heading big">Stamps</div> {% if stamps|length > 0 %}
{% for stamp in stamps %} <div class="heading big">Stamps</div>
<img class="stamp" src="{{ url_for('static', filename='stamps/'+stamp[0]) }}"> {% for stamp in stamps %}
{% endfor %} <img class="stamp" src="{{ url_for('static', filename='stamps/'+stamp[0]) }}">
{% endfor %}
{% endif %}
{% endif %} {% endif %}
<br class="clear" /> <br class="clear" />
{% if all_icons|length > 1 %} {% if member[12] %}
<div class="heading big">Icons</div> {% if all_icons|length > 1 %}
{% for i in all_icons %} <div class="heading big">Icons</div>
<img class="icon" src="{{ url_for('static', filename='icons/'+i[0]) }}"> {% for i in all_icons %}
{% endfor %} <img class="icon" src="{{ url_for('static', filename='icons/'+i[0]) }}">
{% endfor %}
{% endif %}
{% endif %} {% endif %}
<br class="clear" /> <br class="clear" />