Przeglądaj źródła

toggle blog post privacy

cube 1 dzień temu
rodzic
commit
e74ea6ca69
4 zmienionych plików z 20 dodań i 5 usunięć
  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 Wyświetl plik

4
 
4
 
5
 logged in users are presumed to all be admins with distinction only between being logged in and not
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
 # assorted todo
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
 - page theme edit inside the user (below user theme?) 
11
 - page theme edit inside the user (below user theme?) 
13
 - apply page theme edits
12
 - apply page theme edits
14
 - add blinkies and stamps sections to member pages
13
 - add blinkies and stamps sections to member pages

+ 16
- 0
myriad/blog.py Wyświetl plik

57
     else:
57
     else:
58
         return redirect(url_for("home.page", mid=location))
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 Wyświetl plik

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

+ 1
- 1
myriad/templates/page.html Wyświetl plik

30
                 <div class="content">
30
                 <div class="content">
31
                     {{post[4]|safe}}
31
                     {{post[4]|safe}}
32
                 </div>
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
             </div>
34
             </div>
35
             {% endif %}
35
             {% endif %}
36
             {% endfor %}
36
             {% endfor %}