diff --git a/db/moona_data.db b/db/moona_data.db index c1743f2..f2a06d7 100644 Binary files a/db/moona_data.db and b/db/moona_data.db differ diff --git a/main.py b/main.py index 0c9d88a..9cb5be9 100644 --- a/main.py +++ b/main.py @@ -72,6 +72,36 @@ def main_page(): return render_template('base.html', title='moona') +@app.route('/profile') +def profile(): + db_sess = db_session.create_session() + 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': [], 'like': None, 'is_like': 0, + 'author': current_user} + 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 + like = db_sess.query(Like).filter(Like.post == i.id).all() + if like: + emotion['like'] = len(like) + if db_sess.query(Like).filter(Like.post == i.id, Like.user == current_user.id).first(): + emotion['is_like'] = 1 + emotion_pub.append(emotion) + return render_template('profile.html', title='Профиль', pub_post=pub_post, emotion_pub=emotion_pub) + + @app.route('/new_like///') def new_like(user_id, post_id, ret_href): session = db_session.create_session() @@ -592,11 +622,6 @@ def about(): return render_template('about.html', title='О нас') -@app.route('/profile') -def profile(): - return render_template('profil.html', title='Профиль') - - def main(): db_session.global_init("db/moona_data.db") app.run() diff --git a/static/app_image/post_photo/Duvakin_post_2.png b/static/app_image/post_photo/Duvakin_post_2.png deleted file mode 100644 index 70817ef..0000000 Binary files a/static/app_image/post_photo/Duvakin_post_2.png and /dev/null differ diff --git a/static/css/profile.css b/static/css/profile.css new file mode 100644 index 0000000..d546a52 --- /dev/null +++ b/static/css/profile.css @@ -0,0 +1,46 @@ +.profile_header_photo_img { + border-radius: 50%; + border: 3px solid #ffffff; + margin-top: 40px; + margin-left: 15%; +} +.profile_header_name { + text-align: right; + color: #ffffff; + margin-right: 25px; +} +.profile_header { + width: 90%; +} +.all_profile { + margin-left: 10%; + width: 85%; + margin-right: 5%; + background-color: #66c0e9; + margin-top: 55px; + border-radius: 50px; +} +.row_centre, .row_right { + width: 33%; +} +table { + width: 99%; + margin-left: 10%; + margin-right: 10%; +} +.profile_header_photo_img { + float:right; + margin-right: 5px; +} +.row_left { + color: #ffffff; + width: 20%; +} +.user_posts { + margin-top: 50px; +} +.user_posts { + width: 35%; + margin-right: auto; + margin-left: auto; +} \ No newline at end of file diff --git a/templates/profile.html b/templates/profile.html new file mode 100644 index 0000000..489e705 --- /dev/null +++ b/templates/profile.html @@ -0,0 +1,128 @@ + + +{% extends "base.html" %} + +{% block content %} +
+
+ + + + +
+ {% if current_user.about %} +

О себе:

+
+ {{current_user.about}} +
+ {% endif %} + +
+ + +

{{current_user.name}}

+
+
+
+
+

Опубликованные посты

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

{{item.name}}

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

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

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

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

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

+
+ +
+

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

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

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

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

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