blog privacy settings, can delete blog posts
This commit is contained in:
@@ -6,9 +6,7 @@ logged in users are presumed to all be admins with distinction only between bein
|
|||||||
|
|
||||||
# assorted todo
|
# assorted todo
|
||||||
|
|
||||||
- ==privacy settings in database to keep selected members private to logged-in users ==
|
- privacy settings for blog posts
|
||||||
- ==privacy settings for groups? ==
|
|
||||||
- ==privacy settings for blog posts==
|
|
||||||
- add delete button to blog posts on main feed
|
- add delete button to blog posts on main feed
|
||||||
- show blog posts in edit member section with a delete button
|
- show blog posts in edit member section with a delete button
|
||||||
- page theme edit inside the user (below user theme?)
|
- page theme edit inside the user (below user theme?)
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ def new():
|
|||||||
title = request.form['title']
|
title = request.form['title']
|
||||||
content = request.form['content']
|
content = request.form['content']
|
||||||
mid = request.form["mid"]
|
mid = request.form["mid"]
|
||||||
|
privacy = request.form["privacy"]
|
||||||
|
|
||||||
db.execute("INSERT INTO blog (member_id, title, content) VALUES (?, ?, ?)",(mid, title, content))
|
db.execute("INSERT INTO blog (member_id, title, content, public) VALUES (?, ?, ?, ?)",(mid, title, content, privacy))
|
||||||
db.commit()
|
db.commit()
|
||||||
|
|
||||||
return redirect(url_for('blog.blog'))
|
return redirect(url_for('blog.blog'))
|
||||||
@@ -44,3 +45,15 @@ def new():
|
|||||||
|
|
||||||
return render_template('blog/new.html', members=members)
|
return render_template('blog/new.html', members=members)
|
||||||
|
|
||||||
|
@bp.route("/delete/<pid>/<location>")
|
||||||
|
@login_required
|
||||||
|
def delete(pid, location):
|
||||||
|
db = get_db()
|
||||||
|
db.execute("DELETE FROM blog WHERE id=(?)",(pid,))
|
||||||
|
db.commit()
|
||||||
|
|
||||||
|
if location == "blog":
|
||||||
|
return redirect(url_for("blog.blog"))
|
||||||
|
else:
|
||||||
|
return redirect(url_for("home.page", mid=location))
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,9 @@
|
|||||||
|
|
||||||
{% for post in blog %}
|
{% for post in blog %}
|
||||||
{% set op = member_ids[post[1]] %}
|
{% set op = member_ids[post[1]] %}
|
||||||
|
{% if not g.user and op[23]==0 %}
|
||||||
|
{% elif not g.user and post[5]==0 %}
|
||||||
|
{% else %}
|
||||||
<div class="post">
|
<div class="post">
|
||||||
{% if member_icons[op[0]][0] %}
|
{% if member_icons[op[0]][0] %}
|
||||||
<img src="{{ url_for('static', filename='icons/'+member_icons[op[0]][0]) }}" class="icon">
|
<img src="{{ url_for('static', filename='icons/'+member_icons[op[0]][0]) }}" class="icon">
|
||||||
@@ -15,12 +18,16 @@
|
|||||||
<img src="{{ url_for('static', filename='any.jpg') }}" class="icon">
|
<img src="{{ url_for('static', filename='any.jpg') }}" class="icon">
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<div class="title">{{post[3]|safe}}</div>
|
<div class="title">{{post[3]|safe}}</div>
|
||||||
<div class="timestamp">{{post[2]}} - <a href="{{ url_for('home.page', mid=post[1]) }}">{{op[3]}}</a></div>
|
<div class="timestamp">{{post[2]}} - <a href="{{ url_for('home.page', mid=post[1]) }}">{{op[3]}}</a> {% if g.user %}{% if op[23]==0 %}(Private){% else %}(Public)</b>{% endif %}{% endif %}</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{{post[4]|safe}}
|
{{post[4]|safe}}
|
||||||
</div>
|
</div>
|
||||||
<br class="clear" />
|
<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>
|
||||||
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@@ -16,6 +16,11 @@
|
|||||||
<option value="{{member[0]}}">{{member[1]}}</option>
|
<option value="{{member[0]}}">{{member[1]}}</option>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</select>
|
||||||
|
<br>
|
||||||
|
<input type="radio" id="public" name="privacy" value=1 checked>
|
||||||
|
<label for="public">Public</label><br>
|
||||||
|
<input type="radio" id="private" name="privacy" value=0>
|
||||||
|
<label for="private">Private</label><br>
|
||||||
<input type="submit" value="Submit">
|
<input type="submit" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,10 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
{% if not g.user and member[23]==0 %}
|
||||||
|
permission denied
|
||||||
|
{% else %}
|
||||||
|
|
||||||
{% if icon %}
|
{% if icon %}
|
||||||
<img class="icon" src="{{ url_for('static', filename='icons/'+icon[0]) }}">
|
<img class="icon" src="{{ url_for('static', filename='icons/'+icon[0]) }}">
|
||||||
{% else %}
|
{% else %}
|
||||||
@@ -18,13 +22,17 @@
|
|||||||
<div class="heading big">{{member[3]}}'s blog</div>
|
<div class="heading big">{{member[3]}}'s blog</div>
|
||||||
<div id="blog">
|
<div id="blog">
|
||||||
{% for post in blog %}
|
{% for post in blog %}
|
||||||
|
{% if not g.user and post[5]==0 %}
|
||||||
|
{% else %}
|
||||||
<div class="post">
|
<div class="post">
|
||||||
<div class="title">{{post[3]|safe}}</div>
|
<div class="title">{{post[3]|safe}}</div>
|
||||||
<div class="timestamp">{{post[2]}}</div>
|
<div class="timestamp">{{post[2]}} {% if g.user %}{% if post[5]==0 %}(Private){% else %}(Public){% endif %}{% endif %}</div>
|
||||||
<div class="content">
|
<div class="content">
|
||||||
{{post[4]|safe}}
|
{{post[4]|safe}}
|
||||||
</div>
|
</div>
|
||||||
|
{% if g.user %}<a href="{{url_for('blog.delete', pid=post[0], location=member[0])}}" class="danger">Delete post</a>{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@@ -37,4 +45,6 @@
|
|||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
Reference in New Issue
Block a user