Возможность администраторам удалять все посты
This commit is contained in:
parent
a4ded16d12
commit
a74fd4af62
BIN
db/moona_data.db
BIN
db/moona_data.db
Binary file not shown.
4
main.py
4
main.py
@ -529,7 +529,7 @@ def post_edit(id):
|
||||
else:
|
||||
post_exc.photo = photo
|
||||
check_pop = session.query(Popularity).filter(Popularity.post == post_exc.id).first()
|
||||
if post_ed.public.data and check_pop:
|
||||
if not post_ed.public.data and check_pop:
|
||||
session.delete(check_pop)
|
||||
session.commit()
|
||||
return redirect('/diary')
|
||||
@ -550,7 +550,7 @@ def post_deleted(id):
|
||||
session = db_session.create_session()
|
||||
find_post = session.query(DiaryPost).filter(DiaryPost.id == id).first()
|
||||
if find_post:
|
||||
if find_post.author == current_user.id:
|
||||
if find_post.author == current_user.id or current_user.role == 'admin':
|
||||
session = db_session.create_session()
|
||||
pos = session.query(DiaryPost).filter(DiaryPost.id == id,
|
||||
DiaryPost.author == current_user.id).first()
|
||||
|
||||
@ -100,7 +100,7 @@
|
||||
</div>
|
||||
<strong style="color:#ffffff">{{item.date}}</strong>
|
||||
<div>
|
||||
<a style="border-radius: 15px;" href="/post/{{ item.id }}" class="btn" , id="edit_btn">
|
||||
<a style="border-radius: 15px;" href="/post/{{ item.id }}" class="btn" id="edit_btn">
|
||||
Изменить
|
||||
</a>
|
||||
<a style="border-radius: 15px;" href="/post_deleted/{{ item.id }}" class="btn btn-danger">
|
||||
|
||||
@ -7,11 +7,13 @@
|
||||
<td style="width: 110%;">
|
||||
<h1 class="upp_zag">Главная</h1>
|
||||
</td>
|
||||
{% if current_user.is_authenticated %}
|
||||
<td>
|
||||
<a href="/add_post" id="add_post" class="btn btn-primary"
|
||||
style="background-color:#1daff0;border-radius: 15px;"><strong>Добавить
|
||||
запись</strong></a>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</table>
|
||||
<table id="main_table">
|
||||
@ -131,6 +133,13 @@
|
||||
<strong style="color: #ffffff">{{ emotion_for_you[loop.index0]['author'].name }}</strong>
|
||||
</div>
|
||||
<strong style="color:#ffffff">{{item.date}}</strong>
|
||||
{% if current_user.is_authenticated %}
|
||||
{% if current_user.role == 'admin' %}
|
||||
<a style="border-radius: 15px;" href="/post_deleted/{{ item.id }}" class="btn btn-danger">
|
||||
Удалить
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
@ -231,6 +240,13 @@
|
||||
<strong style="color: #ffffff">{{ emotion_you_like_that[loop.index0]['author'].name }}</strong>
|
||||
</div>
|
||||
<strong style="color:#ffffff">{{item.date}}</strong>
|
||||
{% if current_user.is_authenticated %}
|
||||
{% if current_user.role == 'admin' %}
|
||||
<a style="border-radius: 15px;" href="/post_deleted/{{ item.id }}" class="btn btn-danger">
|
||||
Удалить
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
|
||||
@ -2,20 +2,20 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
{% if current_user.is_authenticated %}
|
||||
<table class="but">
|
||||
<tr>
|
||||
<td style="width: 110%;">
|
||||
<h1 class="upp_zag">Публикации</h1>
|
||||
</td>
|
||||
{% if current_user.is_authenticated %}
|
||||
<td>
|
||||
<a href="/add_post" id="add_post" class="btn btn-primary"
|
||||
style="background-color:#1daff0;border-radius: 15px;"><strong>Добавить
|
||||
запись</strong></a>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</table>
|
||||
{% endif %}
|
||||
<table>
|
||||
<td id="row1">
|
||||
<div id="row1_div">
|
||||
@ -109,6 +109,13 @@
|
||||
<strong style="color: #ffffff">{{ emotion_pop[loop.index0]['author'].name }}</strong>
|
||||
</div>
|
||||
<strong style="color:#ffffff">{{item.date}}</strong>
|
||||
{% if current_user.is_authenticated %}
|
||||
{% if current_user.role == 'admin' %}
|
||||
<a style="border-radius: 15px;" href="/post_deleted/{{ item.id }}" class="btn btn-danger">
|
||||
Удалить
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@ -211,6 +218,13 @@
|
||||
<strong style="color: #ffffff">{{ emotion_fresh[loop.index0]['author'].name }}</strong>
|
||||
</div>
|
||||
<strong style="color:#ffffff">{{item.date}}</strong>
|
||||
{% if current_user.is_authenticated %}
|
||||
{% if current_user.role == 'admin' %}
|
||||
<a style="border-radius: 15px;" href="/post_deleted/{{ item.id }}" class="btn btn-danger">
|
||||
Удалить
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
@ -312,6 +326,14 @@
|
||||
<strong style="color: #ffffff">{{ emotion_for_you[loop.index0]['author'].name }}</strong>
|
||||
</div>
|
||||
<strong style="color:#ffffff">{{item.date}}</strong>
|
||||
|
||||
{% if current_user.is_authenticated %}
|
||||
{% if current_user.role == 'admin' %}
|
||||
<a style="border-radius: 15px;" href="/post_deleted/{{ item.id }}" class="btn btn-danger">
|
||||
Удалить
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user