diff --git a/db/moona_data.db b/db/moona_data.db index 4bbfa02..7ce8ea6 100644 Binary files a/db/moona_data.db and b/db/moona_data.db differ diff --git a/main.py b/main.py index a3f3522..b548f52 100644 --- a/main.py +++ b/main.py @@ -232,6 +232,41 @@ def diary(): db_sess = db_session.create_session() if current_user.is_authenticated: 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() days_reg = current_user.data_reg - datetime.date.today() days_reg = abs(days_reg.days) + 1 @@ -242,18 +277,25 @@ def diary(): while len(post_quest) < days_reg: post_quest.append( db_sess.query(Quest).filter(Quest.id.notin_([i.id for i in post_quest])).first()) - ans = [] for i in post_quest: ans_id = db_sess.query(Answer).filter(Answer.id_question == i.id and Answer.user == current_user.id).first() if ans_id: ans.append(ans_id) - if ans: - ls = [i.id_question for i in ans] + post_quest = post_quest[::-1] + ans = ans[::-1] + ans2 = {} + for i in ans: + ans2[i.id_question] = i else: posts = None - return render_template('diary.html', title='moona', my_post=posts, message='', question=post_quest[::-1], - ans=ans[::-1], ls=ls, ln=len(ans)) + post_quest = None + 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') diff --git a/static/app_image/post_photo/Duvakin_post_3.png b/static/app_image/post_photo/Duvakin_post_3.png new file mode 100644 index 0000000..2e1ab85 Binary files /dev/null and b/static/app_image/post_photo/Duvakin_post_3.png differ diff --git a/static/app_image/post_photo/Duvakin_post_4.png b/static/app_image/post_photo/Duvakin_post_4.png new file mode 100644 index 0000000..55130e6 Binary files /dev/null and b/static/app_image/post_photo/Duvakin_post_4.png differ diff --git a/static/css/diary.css b/static/css/diary.css index 74e0bab..9a861ab 100644 --- a/static/css/diary.css +++ b/static/css/diary.css @@ -17,11 +17,11 @@ text-align: center; #image { width: 70%; } -#all_my_post { +#all_my_post, #all_my_post1 { margin-left: auto; margin-right: auto; } -#my_post { +#my_post, #my_post1 { text-align: center; margin-left: auto; margin-right: auto; @@ -35,7 +35,7 @@ margin-left: auto; margin-right: auto; margin-top: 25px; } -#pub, #private { +.pub, .private { width: 60%; height: 10%; margin-left: auto; @@ -45,17 +45,19 @@ margin-left: auto; margin-top: 20px; margin-left: 85%; } -#edit_btn { +#edit_btn, #edit_btn1 { background-color: #c5f1ff; } -#row2 { -width: 35%; +#row2, #row1 { +width: 30%; +} +#row1, #row2, #all_my_question { +display:inline-block; +vertical-align: top; } #all_my_question { width: 30%; -} -#row1 { -width: 35%; +height: -100%; } .question, .my_post { background-color:#7fc3ff; @@ -67,4 +69,12 @@ margin-left: 5%; background-color:#ddefff; border:2px solid #FFFFFF; border-radius: 25px; +} +.emot_block { +color: #ffffff; +font-weight: bolder; +} +table { +margin-left: 5%; +width: 100%; } \ No newline at end of file diff --git a/templates/diary.html b/templates/diary.html index 8f3320a..15a7d01 100644 --- a/templates/diary.html +++ b/templates/diary.html @@ -11,6 +11,103 @@
+ Публикации+
+ {% if my_post != [] %}
+ {% for item in pub_post %}
+
+
+ {% endfor %}
+ {% else %}
+
+
+ {% if emotion_pub[loop.index0]['pos_emot'] != None %}
+ {% if item.name != None %}
+
+ {% if item.text != None %}
+ {{item.text}}
+ {% endif %}
+ |
Мои мысли@@ -27,48 +124,64 @@ {{item.text}} {% endif %} - {% if item.pos_emot != None %} + {% if emotion[loop.index0]['pos_emot'] != None %}
- {% for item2 in item.pos_emot %}
- {{item2}}
- {% endfor %}
+
+
{% endif %}
- {% if item.nig_emot != None %}
+ {% if emotion[loop.index0]['nig_emot'] != None %}
+
+ Позитивные эмоции ++ + {% for item2 in emotion[loop.index0]['pos_emot'] %} + {{item2}} + {% endfor %} +
- {% for item2 in item.nig_emot %}
- {{item2}}
- {% endfor %}
-
- {% endif %}
- {% if item.case != None %}
-
- {% for item2 in item.case %}
- {{item2}}
- {% endfor %}
+
+
{% endif %}
{% if item.photo != None %}
+
+ Негативные эмоции ++ + {% for item2 in emotion[loop.index0]['nig_emot'] %} + {{item2}} + {% endfor %} +
+
+
{% endif %}
{% if item.public == 1 or item.public == 'True' %}
- + Ссылки ++ + {% for item2 in emotion[loop.index0]['link'] %} + + + {% endfor %} +Запись
+ Запись
опубликована
{% else %}
- Запись
+
{{item.date}}
Запись
приватная
{% endif %}
@@ -79,7 +192,7 @@
|