toggle blog post privacy

This commit is contained in:
cube
2026-03-20 19:27:01 +00:00
parent 869588ef13
commit e74ea6ca69
4 changed files with 20 additions and 5 deletions

View File

@@ -4,11 +4,10 @@ flask app for plurals to publicly share member lists
logged in users are presumed to all be admins with distinction only between being logged in and not
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).
# assorted todo
- privacy settings for blog posts
- add delete button to blog posts on main feed
- show blog posts in edit member section with a delete button
- page theme edit inside the user (below user theme?)
- apply page theme edits
- add blinkies and stamps sections to member pages

View File

@@ -57,3 +57,19 @@ def delete(pid, location):
else:
return redirect(url_for("home.page", mid=location))
@bp.route("/toggle/<pid>/<location>")
@login_required
def toggle(pid, location):
db = get_db()
post = db.execute("SELECT * FROM blog WHERE id=(?)",(pid,)).fetchone()
if post[5] == 0:
db.execute("UPDATE blog SET public=(?) WHERE id=(?)",(1, pid))
db.commit()
else:
db.execute("UPDATE blog SET public=(?) WHERE id=(?)",(0, pid))
db.commit()
if location == "blog":
return redirect(url_for("blog.blog"))
else:
return redirect(url_for("home.page", mid=location))

View File

@@ -24,7 +24,7 @@
</div>
<br class="clear" />
{% if g.user %}
{% if post[5]==0 %}<b style="color:red;">Private</b>{% else %}<b style="color:green;">Public</b>{% endif %} | <a href="{{url_for('blog.delete', pid=post[0], location='blog')}}" class="danger">Delete post</a>
{% if post[5]==0 %}<b style="color:red;">Private</b>{% else %}<b style="color:green;">Public</b>{% endif %} | <a href="{{url_for('blog.toggle',pid=post[0], location='blog')}}">Toggle privacy</a> | <a href="{{url_for('blog.delete', pid=post[0], location='blog')}}" class="danger">Delete post</a>
{% endif %}
</div>
{% endif %}

View File

@@ -30,7 +30,7 @@
<div class="content">
{{post[4]|safe}}
</div>
{% if g.user %}<a href="{{url_for('blog.delete', pid=post[0], location=member[0])}}" class="danger">Delete post</a>{% endif %}
<a href="{{url_for('blog.toggle',pid=post[0], location=member[0])}}">Toggle privacy</a> | {% if g.user %}<a href="{{url_for('blog.delete', pid=post[0], location=member[0])}}" class="danger">Delete post</a>{% endif %}
</div>
{% endif %}
{% endfor %}