Добавлено отображение эмоций, ссылок, скорректировано отображение вопросов, добавлен блок публикаций в раздел дневника
This commit is contained in:
parent
c00724f5e2
commit
f4a9954394
BIN
db/moona_data.db
BIN
db/moona_data.db
Binary file not shown.
52
main.py
52
main.py
@ -232,6 +232,41 @@ def diary():
|
|||||||
db_sess = db_session.create_session()
|
db_sess = db_session.create_session()
|
||||||
if current_user.is_authenticated:
|
if current_user.is_authenticated:
|
||||||
posts = db_sess.query(DiaryPost).filter(DiaryPost.author == current_user.id).all()
|
posts = db_sess.query(DiaryPost).filter(DiaryPost.author == current_user.id).all()
|
||||||
|
posts = posts[::-1]
|
||||||
|
pub_post = db_sess.query(DiaryPost).filter(DiaryPost.author == current_user.id, DiaryPost.public == 1).all()
|
||||||
|
pub_post = pub_post[::-1]
|
||||||
|
emotion_pub = []
|
||||||
|
for i in pub_post:
|
||||||
|
emotion = {id: i.id,'pos_emot': [], 'nig_emot': [], 'link': []}
|
||||||
|
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_pub.append(emotion)
|
||||||
|
lis_emotion = []
|
||||||
|
for i in posts:
|
||||||
|
emotion = {id: i.id,'pos_emot': [], 'nig_emot': [], 'link': []}
|
||||||
|
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
|
||||||
|
lis_emotion.append(emotion)
|
||||||
quest = db_sess.query(Answer).filter(Answer.user == current_user.id).all()
|
quest = db_sess.query(Answer).filter(Answer.user == current_user.id).all()
|
||||||
days_reg = current_user.data_reg - datetime.date.today()
|
days_reg = current_user.data_reg - datetime.date.today()
|
||||||
days_reg = abs(days_reg.days) + 1
|
days_reg = abs(days_reg.days) + 1
|
||||||
@ -242,18 +277,25 @@ def diary():
|
|||||||
while len(post_quest) < days_reg:
|
while len(post_quest) < days_reg:
|
||||||
post_quest.append(
|
post_quest.append(
|
||||||
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 == current_user.id).first()
|
||||||
if ans_id:
|
if ans_id:
|
||||||
ans.append(ans_id)
|
ans.append(ans_id)
|
||||||
if ans:
|
post_quest = post_quest[::-1]
|
||||||
ls = [i.id_question for i in ans]
|
ans = ans[::-1]
|
||||||
|
ans2 = {}
|
||||||
|
for i in ans:
|
||||||
|
ans2[i.id_question] = i
|
||||||
else:
|
else:
|
||||||
posts = None
|
posts = None
|
||||||
return render_template('diary.html', title='moona', my_post=posts, message='', question=post_quest[::-1],
|
post_quest = None
|
||||||
ans=ans[::-1], ls=ls, ln=len(ans))
|
ans2 = None
|
||||||
|
lis_emotion = None
|
||||||
|
emotion_pub = None
|
||||||
|
pub_post = None
|
||||||
|
return render_template('diary.html', title='moona', my_post=posts, message='', question=post_quest,
|
||||||
|
ans=ans2, emotion=lis_emotion, emotion_pub=emotion_pub, pub_post=pub_post)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/logout')
|
@app.route('/logout')
|
||||||
|
|||||||
BIN
static/app_image/post_photo/Duvakin_post_3.png
Normal file
BIN
static/app_image/post_photo/Duvakin_post_3.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 798 KiB |
BIN
static/app_image/post_photo/Duvakin_post_4.png
Normal file
BIN
static/app_image/post_photo/Duvakin_post_4.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 245 KiB |
@ -17,11 +17,11 @@ text-align: center;
|
|||||||
#image {
|
#image {
|
||||||
width: 70%;
|
width: 70%;
|
||||||
}
|
}
|
||||||
#all_my_post {
|
#all_my_post, #all_my_post1 {
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
}
|
}
|
||||||
#my_post {
|
#my_post, #my_post1 {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
@ -35,7 +35,7 @@ margin-left: auto;
|
|||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
margin-top: 25px;
|
margin-top: 25px;
|
||||||
}
|
}
|
||||||
#pub, #private {
|
.pub, .private {
|
||||||
width: 60%;
|
width: 60%;
|
||||||
height: 10%;
|
height: 10%;
|
||||||
margin-left: auto;
|
margin-left: auto;
|
||||||
@ -45,17 +45,19 @@ margin-left: auto;
|
|||||||
margin-top: 20px;
|
margin-top: 20px;
|
||||||
margin-left: 85%;
|
margin-left: 85%;
|
||||||
}
|
}
|
||||||
#edit_btn {
|
#edit_btn, #edit_btn1 {
|
||||||
background-color: #c5f1ff;
|
background-color: #c5f1ff;
|
||||||
}
|
}
|
||||||
#row2 {
|
#row2, #row1 {
|
||||||
width: 35%;
|
width: 30%;
|
||||||
|
}
|
||||||
|
#row1, #row2, #all_my_question {
|
||||||
|
display:inline-block;
|
||||||
|
vertical-align: top;
|
||||||
}
|
}
|
||||||
#all_my_question {
|
#all_my_question {
|
||||||
width: 30%;
|
width: 30%;
|
||||||
}
|
height: -100%;
|
||||||
#row1 {
|
|
||||||
width: 35%;
|
|
||||||
}
|
}
|
||||||
.question, .my_post {
|
.question, .my_post {
|
||||||
background-color:#7fc3ff;
|
background-color:#7fc3ff;
|
||||||
@ -68,3 +70,11 @@ background-color:#ddefff;
|
|||||||
border:2px solid #FFFFFF;
|
border:2px solid #FFFFFF;
|
||||||
border-radius: 25px;
|
border-radius: 25px;
|
||||||
}
|
}
|
||||||
|
.emot_block {
|
||||||
|
color: #ffffff;
|
||||||
|
font-weight: bolder;
|
||||||
|
}
|
||||||
|
table {
|
||||||
|
margin-left: 5%;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
@ -11,6 +11,103 @@
|
|||||||
</div>
|
</div>
|
||||||
<table>
|
<table>
|
||||||
<td id="row1">
|
<td id="row1">
|
||||||
|
<h1 class="my_post_zag">Публикации</h1>
|
||||||
|
<div id="all_my_post1">
|
||||||
|
{% if my_post != [] %}
|
||||||
|
{% for item in pub_post %}
|
||||||
|
<div class="card-body" id="my_post1">
|
||||||
|
<details>
|
||||||
|
<summary style="color:#ffffff">{% if item.name != None %}
|
||||||
|
<h2 class="card-title" id="my_post_zag1" style="color:#c5f1ff">{{item.name}}</h2>
|
||||||
|
{% endif %}
|
||||||
|
</summary>
|
||||||
|
{% if item.text != None %}
|
||||||
|
<strong class="card-text" id="my_text1" style="color:#ffffff">{{item.text}}</strong>
|
||||||
|
{% endif %}
|
||||||
|
</details>
|
||||||
|
{% if emotion_pub[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_pub[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_pub[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_pub[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_pub[loop.index0]['link'] != None %}
|
||||||
|
<details>
|
||||||
|
<summary class="emot_block">
|
||||||
|
<strong class="emot_block">Ссылки</strong>
|
||||||
|
</summary>
|
||||||
|
<p></p>
|
||||||
|
{% for item2 in emotion_pub[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>
|
||||||
|
<p></p>
|
||||||
|
{% endif %}
|
||||||
|
{% if item.public == 1 or item.public == 'True' %}
|
||||||
|
<div style="border-radius: 22px;" class="alert alert-success pub" role="alert">Запись
|
||||||
|
опубликована
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<div style="border-radius: 22px;" class="alert alert-danger private" role="alert">Запись
|
||||||
|
приватная
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
<div class="my_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="../{{ current_user.photo }}" width="40" height="40" style="border-radius: 22px">
|
||||||
|
<strong style="color: #ffffff">{{ current_user.name }}</strong>
|
||||||
|
</div>
|
||||||
|
<strong style="color:#ffffff">{{item.date}}</strong>
|
||||||
|
<div>
|
||||||
|
<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">
|
||||||
|
Удалить
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% else %}
|
||||||
|
<div class="bad_centre" style="background-color:#1daff0; border-radius: 22px;color:#ffffff">
|
||||||
|
<h1 class="hz1">Ничего не нашлось :с</h1>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td id="row2">
|
<td id="row2">
|
||||||
<h1 class="my_post_zag">Мои мысли</h1>
|
<h1 class="my_post_zag">Мои мысли</h1>
|
||||||
@ -27,48 +124,64 @@
|
|||||||
<strong class="card-text" id="my_text" style="color:#ffffff">{{item.text}}</strong>
|
<strong class="card-text" id="my_text" style="color:#ffffff">{{item.text}}</strong>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</details>
|
</details>
|
||||||
{% if item.pos_emot != None %}
|
{% if emotion[loop.index0]['pos_emot'] != None %}
|
||||||
<div class="pos_emot">
|
<div class="pos_emot">
|
||||||
{% for item2 in item.pos_emot %}
|
<details>
|
||||||
<strong>{{item2}}</strong>
|
<summary class="emot_block">
|
||||||
{% endfor %}
|
<strong class="emot_block">Позитивные эмоции</strong>
|
||||||
|
</summary>
|
||||||
|
<p></p>
|
||||||
|
{% for item2 in emotion[loop.index0]['pos_emot'] %}
|
||||||
|
<strong class="alert alert-success" role="alert" style="border-radius: 22px;">{{item2}}</strong>
|
||||||
|
{% endfor %}
|
||||||
|
</details>
|
||||||
</div>
|
</div>
|
||||||
|
<p></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if item.nig_emot != None %}
|
{% if emotion[loop.index0]['nig_emot'] != None %}
|
||||||
<div class="nig_emot">
|
<div class="nig_emot">
|
||||||
{% for item2 in item.nig_emot %}
|
<details>
|
||||||
<strong>{{item2}}</strong>
|
<summary class="emot_block">
|
||||||
{% endfor %}
|
<strong class="emot_block">Негативные эмоции</strong>
|
||||||
</div>
|
</summary>
|
||||||
{% endif %}
|
<p></p>
|
||||||
{% if item.case != None %}
|
{% for item2 in emotion[loop.index0]['nig_emot'] %}
|
||||||
<div class="case">
|
<strong class="alert alert-danger" role="alert" style="border-radius: 22px;">{{item2}}</strong>
|
||||||
{% for item2 in item.case %}
|
{% endfor %}
|
||||||
<strong>{{item2}}</strong>
|
</details>
|
||||||
{% endfor %}
|
|
||||||
</div>
|
</div>
|
||||||
|
<p></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if item.photo != None %}
|
{% if item.photo != None %}
|
||||||
<p></p>
|
<p></p>
|
||||||
<div class="photo">
|
<div class="photo">
|
||||||
<img width="90%" src="{{ item.photo }}"
|
<img width="90%" src="{{ item.photo }}"
|
||||||
style="border-radius: 22px; border:2px solid #FFFFFF;">
|
style="border-radius: 22px;">
|
||||||
</div>
|
</div>
|
||||||
<p></p>
|
<p></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if item.link != None %}
|
{% if emotion[loop.index0]['link'] != None %}
|
||||||
{% for item2 in item.link %}
|
<details>
|
||||||
<div class="link">
|
<summary class="emot_block">
|
||||||
<a href="{{ item2 }}">Ссылка {{ loop.index }}</a>
|
<strong class="emot_block">Ссылки</strong>
|
||||||
</div>
|
</summary>
|
||||||
{% endfor %}
|
<p></p>
|
||||||
|
{% for item2 in emotion[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>
|
||||||
|
<p></p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% if item.public == 1 or item.public == 'True' %}
|
{% if item.public == 1 or item.public == 'True' %}
|
||||||
<div style="border-radius: 22px;" class="alert alert-success" role="alert" id="pub">Запись
|
<div style="border-radius: 22px;" class="alert alert-success pub" role="alert">Запись
|
||||||
опубликована
|
опубликована
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div style="border-radius: 22px;" class="alert alert-danger" role="alert" id="ptivate">Запись
|
<div style="border-radius: 22px;" class="alert alert-danger private" role="alert">Запись
|
||||||
приватная
|
приватная
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -79,7 +192,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_btn1">
|
||||||
Изменить
|
Изменить
|
||||||
</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">
|
||||||
@ -101,11 +214,11 @@
|
|||||||
<div class="question">
|
<div class="question">
|
||||||
{% for item in question %}
|
{% for item in question %}
|
||||||
<a href="/answer_quest/{{item.id}}" class="btn">
|
<a href="/answer_quest/{{item.id}}" class="btn">
|
||||||
{% if item.id in ls %}
|
{% if item.id in ans %}
|
||||||
<div class="is_ans">
|
<div class="is_ans">
|
||||||
<strong>{{item.quest}}</strong>
|
<strong>{{item.quest}}</strong>
|
||||||
<div class="alert alert-success" role="alert" style="border-radius: 25px;">Ответ есть</div>
|
<div class="alert alert-success" role="alert" style="border-radius: 25px;">Ответ есть</div>
|
||||||
<strong>{{ans[ln - loop.index0].answer}}</strong>
|
<strong>{{ans[item.id].answer}}</strong>
|
||||||
</div>
|
</div>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="is_ans">
|
<div class="is_ans">
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user