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