diff --git a/documents/шаблоны/MoonCcircl — копия.png b/documents/шаблоны/MoonCcircl — копия.png new file mode 100644 index 0000000..efc605e Binary files /dev/null and b/documents/шаблоны/MoonCcircl — копия.png differ diff --git a/main.py b/main.py index 6e68393..112dff5 100644 --- a/main.py +++ b/main.py @@ -48,7 +48,7 @@ def save_photo(photo, login, post=False, id_post=None): if not post: with open(f'static/app_image/users_photo/{login}_logo.png', 'wb') as 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: with open(f'static/app_image/post_photo/{login}_post_{id_post}.png', 'wb') as f: photo.save(f) @@ -70,6 +70,30 @@ def main_page(): 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/', methods=['GET', 'POST']) def answer_quest(id): session = db_session.create_session() @@ -237,7 +261,7 @@ def diary(): pub_post = pub_post[::-1] emotion_pub = [] 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: emotion['pos_emot'] = i.pos_emot.split() else: @@ -253,7 +277,7 @@ def diary(): emotion_pub.append(emotion) lis_emotion = [] 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: emotion['pos_emot'] = i.pos_emot.split() else: @@ -279,7 +303,8 @@ def diary(): 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() + ans_id = db_sess.query(Answer).filter( + Answer.id_question == i.id and Answer.user.id == current_user.id).first() if ans_id: ans.append(ans_id) post_quest = post_quest[::-1] diff --git a/static/app_image/users_photo/Dinosaurik_logo.jpg b/static/app_image/users_photo/Dinosaurik_logo.png similarity index 100% rename from static/app_image/users_photo/Dinosaurik_logo.jpg rename to static/app_image/users_photo/Dinosaurik_logo.png diff --git a/static/css/publications.css b/static/css/publications.css new file mode 100644 index 0000000..7eca729 --- /dev/null +++ b/static/css/publications.css @@ -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; +} \ No newline at end of file diff --git a/templates/publications.html b/templates/publications.html new file mode 100644 index 0000000..87205ba --- /dev/null +++ b/templates/publications.html @@ -0,0 +1,91 @@ + +{% extends "base.html" %} + +{% block content %} + + + + +
+

Свежее

+
+ {% if fresh_post != [] %} + {% for item in fresh_post %} +
+
+ + {% if item.name != None %} +

{{item.name}}

+ {% endif %} +
+ {% if item.text != None %} + {{item.text}} + {% endif %} +
+ {% if emotion_fresh[loop.index0]['pos_emot'] != None %} +
+
+ + Позитивные эмоции + +

+ {% for item2 in emotion_fresh[loop.index0]['pos_emot'] %} + {{item2}} + {% endfor %} +
+
+

+ {% endif %} + {% if emotion_fresh[loop.index0]['nig_emot'] != None %} +
+
+ + Негативные эмоции + +

+ {% for item2 in emotion_fresh[loop.index0]['nig_emot'] %} + {{item2}} + {% endfor %} +
+
+

+ {% endif %} + {% if item.photo != None %} +

+
+ +
+

+ {% endif %} + {% if emotion_fresh[loop.index0]['link'] != None %} +
+ + Ссылки + +

+ {% for item2 in emotion_fresh[loop.index0]['link'] %} + +

+ {% endfor %} +
+ {% endif %} +
+ {{ emotion_fresh[loop.index0]['author'].name }} +
+ {{item.date}} +
+ {% endfor %} +
+ {% else %} +
+

Ничего не нашлось :с

+
+ {% endif %} +
+{% endblock %} \ No newline at end of file