浏览代码

toggle blog post privacy

cube 1 天前
父节点
当前提交
e74ea6ca69
共有 4 个文件被更改,包括 20 次插入5 次删除
  1. 2
    3
      README.md
  2. 16
    0
      myriad/blog.py
  3. 1
    1
      myriad/templates/blog/blog.html
  4. 1
    1
      myriad/templates/page.html

+ 2
- 3
README.md 查看文件

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

+ 16
- 0
myriad/blog.py 查看文件

@@ -57,3 +57,19 @@ def delete(pid, location):
57 57
     else:
58 58
         return redirect(url_for("home.page", mid=location))
59 59
 
60
+@bp.route("/toggle/<pid>/<location>")
61
+@login_required
62
+def toggle(pid, location):
63
+    db = get_db()
64
+    post = db.execute("SELECT * FROM blog WHERE id=(?)",(pid,)).fetchone()
65
+    if post[5] == 0:
66
+        db.execute("UPDATE blog SET public=(?) WHERE id=(?)",(1, pid))
67
+        db.commit()
68
+    else:
69
+        db.execute("UPDATE blog SET public=(?) WHERE id=(?)",(0, pid))
70
+        db.commit()
71
+
72
+    if location == "blog":
73
+        return redirect(url_for("blog.blog"))
74
+    else:
75
+        return redirect(url_for("home.page", mid=location))

+ 1
- 1
myriad/templates/blog/blog.html 查看文件

@@ -24,7 +24,7 @@
24 24
         </div>
25 25
         <br class="clear" />
26 26
         {% if g.user %}
27
-        {% 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>
27
+        {% 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>
28 28
         {% endif %}
29 29
     </div>
30 30
     {% endif %}

+ 1
- 1
myriad/templates/page.html 查看文件

@@ -30,7 +30,7 @@
30 30
                 <div class="content">
31 31
                     {{post[4]|safe}}
32 32
                 </div>
33
-                {% if g.user %}<a href="{{url_for('blog.delete', pid=post[0], location=member[0])}}" class="danger">Delete post</a>{% endif %}
33
+                <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 %}
34 34
             </div>
35 35
             {% endif %}
36 36
             {% endfor %}