Соеденины ветки, начата разработка раздела публикаций
This commit is contained in:
parent
237dbd031b
commit
169ec49972
BIN
documents/шаблоны/MoonCcircl — копия.png
Normal file
BIN
documents/шаблоны/MoonCcircl — копия.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 950 KiB |
33
main.py
33
main.py
@ -48,7 +48,7 @@ def save_photo(photo, login, post=False, id_post=None):
|
|||||||
if not post:
|
if not post:
|
||||||
with open(f'static/app_image/users_photo/{login}_logo.png', 'wb') as f:
|
with open(f'static/app_image/users_photo/{login}_logo.png', 'wb') as f:
|
||||||
photo.save(f)
|
photo.save(f)
|
||||||
return f'../static/app_image/users_photo/{login}_logo.png'
|
return f'static/app_image/users_photo/{login}_logo.png'
|
||||||
elif post and id_post != None:
|
elif post and id_post != None:
|
||||||
with open(f'static/app_image/post_photo/{login}_post_{id_post}.png', 'wb') as f:
|
with open(f'static/app_image/post_photo/{login}_post_{id_post}.png', 'wb') as f:
|
||||||
photo.save(f)
|
photo.save(f)
|
||||||
@ -70,6 +70,30 @@ def main_page():
|
|||||||
return render_template('base.html', title='moona')
|
return render_template('base.html', title='moona')
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/publications', methods=['GET', 'POST'])
|
||||||
|
def publications():
|
||||||
|
session = db_session.create_session()
|
||||||
|
fresh_posts = session.query(DiaryPost).filter(DiaryPost.public == 1).all()[::-1]
|
||||||
|
emotion_fresh = []
|
||||||
|
for i in fresh_posts:
|
||||||
|
emotion = {id: i.id, 'pos_emot': [], 'nig_emot': [], 'link': [],
|
||||||
|
'author': session.query(User).filter(User.id == i.author).first()}
|
||||||
|
if i.pos_emot:
|
||||||
|
emotion['pos_emot'] = i.pos_emot.split()
|
||||||
|
else:
|
||||||
|
emotion['pos_emot'] = None
|
||||||
|
if i.nig_emot:
|
||||||
|
emotion['nig_emot'] = i.nig_emot.split()
|
||||||
|
else:
|
||||||
|
emotion['nig_emot'] = None
|
||||||
|
if i.link:
|
||||||
|
emotion['link'] = i.link.split()
|
||||||
|
else:
|
||||||
|
emotion['link'] = None
|
||||||
|
emotion_fresh.append(emotion)
|
||||||
|
return render_template('publications.html', fresh_post=fresh_posts, emotion_fresh=emotion_fresh, title='moona')
|
||||||
|
|
||||||
|
|
||||||
@app.route('/answer_quest/<int:id>', methods=['GET', 'POST'])
|
@app.route('/answer_quest/<int:id>', methods=['GET', 'POST'])
|
||||||
def answer_quest(id):
|
def answer_quest(id):
|
||||||
session = db_session.create_session()
|
session = db_session.create_session()
|
||||||
@ -237,7 +261,7 @@ def diary():
|
|||||||
pub_post = pub_post[::-1]
|
pub_post = pub_post[::-1]
|
||||||
emotion_pub = []
|
emotion_pub = []
|
||||||
for i in pub_post:
|
for i in pub_post:
|
||||||
emotion = {id: i.id,'pos_emot': [], 'nig_emot': [], 'link': []}
|
emotion = {id: i.id, 'pos_emot': [], 'nig_emot': [], 'link': []}
|
||||||
if i.pos_emot:
|
if i.pos_emot:
|
||||||
emotion['pos_emot'] = i.pos_emot.split()
|
emotion['pos_emot'] = i.pos_emot.split()
|
||||||
else:
|
else:
|
||||||
@ -253,7 +277,7 @@ def diary():
|
|||||||
emotion_pub.append(emotion)
|
emotion_pub.append(emotion)
|
||||||
lis_emotion = []
|
lis_emotion = []
|
||||||
for i in posts:
|
for i in posts:
|
||||||
emotion = {id: i.id,'pos_emot': [], 'nig_emot': [], 'link': []}
|
emotion = {id: i.id, 'pos_emot': [], 'nig_emot': [], 'link': []}
|
||||||
if i.pos_emot:
|
if i.pos_emot:
|
||||||
emotion['pos_emot'] = i.pos_emot.split()
|
emotion['pos_emot'] = i.pos_emot.split()
|
||||||
else:
|
else:
|
||||||
@ -279,7 +303,8 @@ def diary():
|
|||||||
db_sess.query(Quest).filter(Quest.id.notin_([i.id for i in post_quest])).first())
|
db_sess.query(Quest).filter(Quest.id.notin_([i.id for i in post_quest])).first())
|
||||||
ans = []
|
ans = []
|
||||||
for i in post_quest:
|
for i in post_quest:
|
||||||
ans_id = db_sess.query(Answer).filter(Answer.id_question == i.id and Answer.user == current_user.id).first()
|
ans_id = db_sess.query(Answer).filter(
|
||||||
|
Answer.id_question == i.id and Answer.user.id == current_user.id).first()
|
||||||
if ans_id:
|
if ans_id:
|
||||||
ans.append(ans_id)
|
ans.append(ans_id)
|
||||||
post_quest = post_quest[::-1]
|
post_quest = post_quest[::-1]
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 25 KiB After Width: | Height: | Size: 25 KiB |
24
static/css/publications.css
Normal file
24
static/css/publications.css
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
table {
|
||||||
|
width: 90%;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
}
|
||||||
|
#row1, #row2, #row3 {
|
||||||
|
width: 30%;
|
||||||
|
}
|
||||||
|
.post_zag, .card-text, .card-body, .post_zag, .author {
|
||||||
|
width: 90%;
|
||||||
|
margin-left: auto;
|
||||||
|
margin-right: auto;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.post {
|
||||||
|
background-color: #7fc3ff;
|
||||||
|
border-radius: 22px;
|
||||||
|
width: 90%;
|
||||||
|
height: 95%;
|
||||||
|
margin-bottom: 20px;
|
||||||
|
}
|
||||||
|
details {
|
||||||
|
color: #ffffff;
|
||||||
|
}
|
||||||
91
templates/publications.html
Normal file
91
templates/publications.html
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
<link rel="stylesheet" href="../static/css/publications.css">
|
||||||
|
{% extends "base.html" %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
<table>
|
||||||
|
<td id="row1"></td>
|
||||||
|
<td id="row2">
|
||||||
|
<h1 class="post_zag">Свежее</h1>
|
||||||
|
<div class="fresh_block" id="fresh">
|
||||||
|
{% if fresh_post != [] %}
|
||||||
|
{% for item in fresh_post %}
|
||||||
|
<div class="card-body post">
|
||||||
|
<details>
|
||||||
|
<summary>
|
||||||
|
{% if item.name != None %}
|
||||||
|
<h2 class="card-title post_zag" style="color:#c5f1ff">{{item.name}}</h2>
|
||||||
|
{% endif %}
|
||||||
|
</summary>
|
||||||
|
{% if item.text != None %}
|
||||||
|
<strong class="card-text" style="color:#ffffff">{{item.text}}</strong>
|
||||||
|
{% endif %}
|
||||||
|
</details>
|
||||||
|
{% if emotion_fresh[loop.index0]['pos_emot'] != None %}
|
||||||
|
<div class="pos_emot">
|
||||||
|
<details>
|
||||||
|
<summary class="emot_block">
|
||||||
|
<strong class="emot_block">Позитивные эмоции</strong>
|
||||||
|
</summary>
|
||||||
|
<p></p>
|
||||||
|
{% for item2 in emotion_fresh[loop.index0]['pos_emot'] %}
|
||||||
|
<strong class="alert alert-success" role="alert" style="border-radius: 22px;">{{item2}}</strong>
|
||||||
|
{% endfor %}
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
<p></p>
|
||||||
|
{% endif %}
|
||||||
|
{% if emotion_fresh[loop.index0]['nig_emot'] != None %}
|
||||||
|
<div class="nig_emot">
|
||||||
|
<details>
|
||||||
|
<summary class="emot_block">
|
||||||
|
<strong class="emot_block">Негативные эмоции</strong>
|
||||||
|
</summary>
|
||||||
|
<p></p>
|
||||||
|
{% for item2 in emotion_fresh[loop.index0]['nig_emot'] %}
|
||||||
|
<strong class="alert alert-danger" role="alert" style="border-radius: 22px;">{{item2}}</strong>
|
||||||
|
{% endfor %}
|
||||||
|
</details>
|
||||||
|
</div>
|
||||||
|
<p></p>
|
||||||
|
{% endif %}
|
||||||
|
{% if item.photo != None %}
|
||||||
|
<p></p>
|
||||||
|
<div class="photo">
|
||||||
|
<img width="90%" src="{{ item.photo }}"
|
||||||
|
style="border-radius: 22px;">
|
||||||
|
</div>
|
||||||
|
<p></p>
|
||||||
|
{% endif %}
|
||||||
|
{% if emotion_fresh[loop.index0]['link'] != None %}
|
||||||
|
<details>
|
||||||
|
<summary class="emot_block">
|
||||||
|
<strong class="emot_block">Ссылки</strong>
|
||||||
|
</summary>
|
||||||
|
<p></p>
|
||||||
|
{% for item2 in emotion_fresh[loop.index0]['link'] %}
|
||||||
|
<div class="link">
|
||||||
|
<a class="alert alert-light" role="alert" href="{{ item2 }}" style="border-radius: 22px;">Ссылка
|
||||||
|
{{ loop.index }}</a>
|
||||||
|
</div>
|
||||||
|
<p></p>
|
||||||
|
{% endfor %}
|
||||||
|
</details>
|
||||||
|
{% endif %}
|
||||||
|
<div class="author" style="style=position:absolute; width:148px; height:44px; left:255px; -webkit-border-radius:
|
||||||
|
22px;-moz-border-radius: 22px;border-radius: 22px; border:2px solid #FFFFFF; background-color:#1daff0; top:
|
||||||
|
98px;"><img src="../{{ emotion_fresh[loop.index0]['author'].photo }}" width="40" height="40" style="border-radius: 22px">
|
||||||
|
<strong style="color: #ffffff">{{ emotion_fresh[loop.index0]['author'].name }}</strong>
|
||||||
|
</div>
|
||||||
|
<strong style="color:#ffffff">{{item.date}}</strong>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div class="bad_centre" style="background-color:#1daff0; border-radius: 22px;color:#ffffff">
|
||||||
|
<h1 class="hz1">Ничего не нашлось :с</h1>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</td>
|
||||||
|
<td id="row3"></td>
|
||||||
|
</table>
|
||||||
|
{% endblock %}
|
||||||
Loading…
x
Reference in New Issue
Block a user