Тестовое изменение главной страницы
This commit is contained in:
parent
1cd82b771b
commit
be019a00d2
24
main.log
24
main.log
@ -0,0 +1,24 @@
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 2
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
WARNING:waitress.queue:Task queue depth is 1
|
||||
99
main.py
99
main.py
@ -72,104 +72,7 @@ def load_user(user_id):
|
||||
|
||||
@app.route('/')
|
||||
def main_page():
|
||||
session = db_session.create_session()
|
||||
for_you = sorted(session.query(DiaryPost).filter(DiaryPost.public == 1).all(),
|
||||
key=lambda x: (len(x.text), 1 if x.photo else 0, -(x.date - datetime.datetime.now()).days))
|
||||
if len(for_you) > 50:
|
||||
for_you_post = choices(for_you, k=80)
|
||||
else:
|
||||
for_you_post = set(for_you)
|
||||
emotion_for_you = []
|
||||
for i in for_you_post:
|
||||
emotion = {id: i.id, 'pos_emot': [], 'nig_emot': [], 'link': [],
|
||||
'author': session.query(User).filter(User.id == i.author).first(), 'like': None, 'is_like': 0}
|
||||
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 = session.query(Like).filter(Like.post == i.id).all()
|
||||
if like:
|
||||
emotion['like'] = len(like)
|
||||
if current_user.is_authenticated:
|
||||
if session.query(Like).filter(Like.post == i.id, Like.user == current_user.id).first():
|
||||
emotion['is_like'] = 1
|
||||
emotion_for_you.append(emotion)
|
||||
if current_user.is_authenticated:
|
||||
try:
|
||||
you_like_that = sorted(
|
||||
list(map(lambda x: session.query(DiaryPost).filter(DiaryPost.id == x, DiaryPost.public == 1).first(),
|
||||
map(lambda x: x.post,
|
||||
session.query(Like).filter(Like.user == current_user.id).all()))),
|
||||
key=lambda x: (
|
||||
len(x.text), 1 if x.photo else 0, -(x.date - datetime.datetime.now()).days))
|
||||
except Exception:
|
||||
you_like_that = []
|
||||
emotion_you_like_that = []
|
||||
for i in you_like_that:
|
||||
emotion = {id: i.id, 'pos_emot': [], 'nig_emot': [], 'link': [],
|
||||
'author': session.query(User).filter(User.id == i.author).first(), 'like': None, 'is_like': 0}
|
||||
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 = session.query(Like).filter(Like.post == i.id).all()
|
||||
if like:
|
||||
emotion['like'] = len(like)
|
||||
if current_user.is_authenticated:
|
||||
if session.query(Like).filter(Like.post == i.id, Like.user == current_user.id).first():
|
||||
emotion['is_like'] = 1
|
||||
emotion_you_like_that.append(emotion)
|
||||
quest = session.query(Answer).filter(Answer.user == current_user.id).all()
|
||||
try:
|
||||
days_reg = current_user.data_reg - datetime.date.today()
|
||||
days_reg = abs(days_reg.days) + 1
|
||||
if quest:
|
||||
post_quest = session.query(Quest).filter(Quest.id.in_([i.id_question for i in quest])).all()
|
||||
else:
|
||||
post_quest = []
|
||||
max_quests = len(session.query(Quest).all())
|
||||
while len(post_quest) < days_reg and max_quests > len(post_quest):
|
||||
post_quest.append(
|
||||
session.query(Quest).filter(Quest.id.notin_([i.id for i in post_quest])).first())
|
||||
ans = []
|
||||
for i in post_quest:
|
||||
if i is not None:
|
||||
ans_id = session.query(Answer).filter(
|
||||
Answer.id_question == i.id, Answer.user == current_user.id).first()
|
||||
if ans_id is not None:
|
||||
ans.append(ans_id)
|
||||
post_quest = post_quest[::-1]
|
||||
ans = ans[::-1]
|
||||
ans2 = {}
|
||||
for i in ans:
|
||||
ans2[i.id_question] = i
|
||||
except Exception:
|
||||
ans2 = []
|
||||
else:
|
||||
you_like_that = []
|
||||
emotion_you_like_that = None
|
||||
post_quest = []
|
||||
ans2 = None
|
||||
return render_template('main.html', title='moona', for_me_post=for_you_post, emotion_for_you=emotion_for_you,
|
||||
you_like_that=you_like_that, emotion_you_like_that=emotion_you_like_that,
|
||||
question=post_quest,
|
||||
ans=ans2)
|
||||
return render_template('main.html', title='moona')
|
||||
|
||||
|
||||
@app.route('/edit_profile/<string:logins>', methods=['GET', 'POST'])
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
.navbar-brand {
|
||||
font-family: 'Montserrat Alternates', sans-serif;
|
||||
background-color: #f0ffff;
|
||||
}
|
||||
body {
|
||||
font-family: 'Comfortaa', cursive;
|
||||
font-family: 'Comfortaa', cursive, sans-serif;
|
||||
background-color: #f0ffff;
|
||||
}
|
||||
.user_img {
|
||||
|
||||
@ -1,49 +1,50 @@
|
||||
#add_post {
|
||||
margin-top: 20px;
|
||||
margin-left: 83%;
|
||||
body {
|
||||
background-image: url('../img/back_moona.png');
|
||||
}
|
||||
.row1, .row2, .row3 {
|
||||
width: 33%;
|
||||
display:inline-block;
|
||||
vertical-align: top;
|
||||
margin-top: 39px;
|
||||
}
|
||||
.rowdiv1, .rowdiv2, .rowdiv3 {
|
||||
width: 95%;
|
||||
}
|
||||
.post_zag, .card-text, .card-body, .post_zag, .author {
|
||||
width: 90%;
|
||||
.header, .body {
|
||||
width: 80%;
|
||||
margin-left: auto;
|
||||
margin-right: auto;
|
||||
}
|
||||
.body {
|
||||
margin-top: 5%;
|
||||
}
|
||||
.header_logo {
|
||||
width: 60%;
|
||||
margin-left: 20%;
|
||||
margin-right: 20%;
|
||||
}
|
||||
.header_title {
|
||||
text-align: center;
|
||||
color: white;
|
||||
margin-left: 27%;
|
||||
margin-right: 27%;
|
||||
width: 46%;
|
||||
height: auto;
|
||||
margin-top: 15px;
|
||||
}
|
||||
.post {
|
||||
background-color: #7fc3ff;
|
||||
border-radius: 50px;
|
||||
width: 90%;
|
||||
height: 95%;
|
||||
margin-bottom: 20px;
|
||||
.article_one {
|
||||
width: 100%;
|
||||
height: 27%;
|
||||
max-height: 27%;
|
||||
display: flex;
|
||||
justify-content: space-around;
|
||||
}
|
||||
details {
|
||||
color: #ffffff;
|
||||
}
|
||||
#main_table {
|
||||
margin-left: 10%;
|
||||
margin-right: auto;
|
||||
width: 90%;
|
||||
}
|
||||
.question {
|
||||
background-color:#7fc3ff;
|
||||
.article_one_text_back {
|
||||
width: 50%;
|
||||
background: linear-gradient(45deg, #d1c3fc, #9bc4fc);
|
||||
border-radius: 22px;
|
||||
width: 90%;
|
||||
margin-left: 10px;
|
||||
height: 94%;
|
||||
}
|
||||
.is_ans {
|
||||
background-color:#ddefff;
|
||||
border:2px solid #ffffff;
|
||||
border-radius: 25px;
|
||||
width: 95%;
|
||||
.article_one_text {
|
||||
width: 94%;
|
||||
height: 94%;
|
||||
margin-top: 3%;
|
||||
margin-left: 3%;
|
||||
overflow: auto;
|
||||
color: white;
|
||||
text-align: justify;
|
||||
}
|
||||
.but {
|
||||
width: 80%;
|
||||
.article_one_image {
|
||||
height: 100%;
|
||||
}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 42 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 813 KiB |
@ -2,259 +2,18 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<table class="but">
|
||||
<tr>
|
||||
<td style="width: 110%;">
|
||||
<h1 class="upp_zag">Главная</h1>
|
||||
</td>
|
||||
{% if current_user.is_authenticated %}
|
||||
<td>
|
||||
<a href="/add_post" id="add_post" class="btn btn-primary"
|
||||
style="background-color:#1daff0;border-radius: 15px;"><strong>Добавить
|
||||
запись</strong></a>
|
||||
</td>
|
||||
{% endif %}
|
||||
</tr>
|
||||
</table>
|
||||
<table id="main_table">
|
||||
<th class="row1">
|
||||
<div class="rowdiv1">
|
||||
<h1 class="my_post_zag">Вопросы дня</h1>
|
||||
<div class="my_post">
|
||||
<div class="question">
|
||||
{% for item in question %}
|
||||
<a href="/answer_quest/{{item.id}}" class="btn quest_block">
|
||||
{% if item.id in ans %}
|
||||
<div class="is_ans">
|
||||
<strong>{{item.quest}}</strong>
|
||||
<div class="alert alert-success" role="alert" style="border-radius: 25px;">Ответ есть</div>
|
||||
<strong>{{ans[item.id].answer}}</strong>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="is_ans">
|
||||
<strong>{{item.quest}}</strong>
|
||||
<div class="alert alert-danger" role="alert" style="border-radius: 25px;">Ответа нет</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</a>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
<div class="header">
|
||||
<img class="header_logo" src="../static/img/string_moona_no_back.png" width="50%">
|
||||
<h2 class="header_title">Добро пожаловать в moona - ваш проводник в мир оптимизма, дружелюбия и единения!</h2>
|
||||
</div>
|
||||
<div class="body">
|
||||
<div class="article_one">
|
||||
<div class="article_one_text_back">
|
||||
<p class="article_one_text">У всех нас бывают черные и белые полосы, хорошее и плохое настроение, мы переживаем плохие моменты нашей
|
||||
жизни и радуемся приятным мелочам. Однако многие не знают или забывают про такую вещь, как личный дневник, а
|
||||
ведь у него есть множество плюсов</p>
|
||||
</div>
|
||||
</th>
|
||||
<th class="row2">
|
||||
<div class="rowdiv2">
|
||||
<h2 class="post_zag">Вам будет интересно</h2>
|
||||
{% if for_me_post != [] %}
|
||||
{% for item in for_me_post %}
|
||||
<div class="card-body post">
|
||||
<details>
|
||||
<summary>
|
||||
{% if item.name != None %}
|
||||
<h3 class="card-title post_zag" style="color:#c5f1ff">{{item.name}}</h3>
|
||||
{% endif %}
|
||||
</summary>
|
||||
{% if item.text != None %}
|
||||
<strong class="card-text" style="color:#ffffff">{{item.text}}</strong>
|
||||
{% endif %}
|
||||
</details>
|
||||
{% if emotion_for_you[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_for_you[loop.index0]['pos_emot'] %}
|
||||
<p class="alert alert-success" role="alert"
|
||||
style="border-radius: 22px;">{{item2}}</p>
|
||||
{% endfor %}
|
||||
</details>
|
||||
</div>
|
||||
<p></p>
|
||||
{% endif %}
|
||||
{% if emotion_for_you[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_for_you[loop.index0]['nig_emot'] %}
|
||||
<p class="alert alert-danger" role="alert"
|
||||
style="border-radius: 22px;">{{item2}}</p>
|
||||
{% 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 current_user.is_authenticated %}
|
||||
<div class="like">
|
||||
<a type="button"
|
||||
href="/new_like/{{current_user.id}}/{{item.id}}/main">
|
||||
{% if emotion_for_you[loop.index0]['is_like'] %}
|
||||
<img src="../static/img/like_add.png" width="117" height="100">
|
||||
{% else %}
|
||||
<img src="../static/img/like.png" width="94" height="80">
|
||||
{% endif %}
|
||||
</a>
|
||||
{% if emotion_for_you[loop.index0]['like'] != None %}
|
||||
<p style="color:#ffffff">{{emotion_for_you[loop.index0]['like']}}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if emotion_for_you[loop.index0]['link'] != None %}
|
||||
<details>
|
||||
<summary class="emot_block">
|
||||
<strong class="emot_block">Ссылки</strong>
|
||||
</summary>
|
||||
<p></p>
|
||||
{% for item2 in emotion_for_you[loop.index0]['link'] %}
|
||||
<div class="link">
|
||||
<p><a class="alert alert-light" role="alert" href="{{ item2 }}" style="border-radius: 22px;">Ссылка
|
||||
{{ loop.index }}</a></p>
|
||||
</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_for_you[loop.index0]['author'].photo }}" width="40" height="40"
|
||||
style="border-radius: 22px">
|
||||
<strong style="color: #ffffff">{{ emotion_for_you[loop.index0]['author'].name }}</strong>
|
||||
</div>
|
||||
<strong style="color:#ffffff">{{item.date}}</strong>
|
||||
{% if current_user.is_authenticated %}
|
||||
{% if current_user.role == 'admin' %}
|
||||
<a style="border-radius: 15px;" href="/post_deleted/{{ item.id }}" class="btn btn-danger">
|
||||
Удалить
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="bad_centre" style="background-color:#1daff0; border-radius: 22px;color:#ffffff">
|
||||
<p class="hz1">Ничего не нашлось :с</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</th>
|
||||
<th class="row3">
|
||||
<div class="rowdiv3">
|
||||
<h2 class="post_zag">Вам понравились эти посты</h2>
|
||||
{% if you_like_that != [] %}
|
||||
{% for item in you_like_that %}
|
||||
<div class="card-body post">
|
||||
<details>
|
||||
<summary>
|
||||
{% if item.name != None %}
|
||||
<h3 class="card-title post_zag" style="color:#c5f1ff">{{item.name}}</h3>
|
||||
{% endif %}
|
||||
</summary>
|
||||
{% if item.text != None %}
|
||||
<strong class="card-text" style="color:#ffffff">{{item.text}}</strong>
|
||||
{% endif %}
|
||||
</details>
|
||||
{% if emotion_you_like_that[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_you_like_that[loop.index0]['pos_emot'] %}
|
||||
<p class="alert alert-success" role="alert"
|
||||
style="border-radius: 22px;">{{item2}}</p>
|
||||
{% endfor %}
|
||||
</details>
|
||||
</div>
|
||||
<p></p>
|
||||
{% endif %}
|
||||
{% if emotion_you_like_that[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_you_like_that[loop.index0]['nig_emot'] %}
|
||||
<p class="alert alert-danger" role="alert"
|
||||
style="border-radius: 22px;">{{item2}}</p>
|
||||
{% 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 current_user.is_authenticated %}
|
||||
<div class="like">
|
||||
<a type="button"
|
||||
href="/new_like/{{current_user.id}}/{{item.id}}/main">
|
||||
{% if emotion_you_like_that[loop.index0]['is_like'] %}
|
||||
<img src="../static/img/like_add.png" width="117" height="100">
|
||||
{% else %}
|
||||
<img src="../static/img/like.png" width="94" height="80">
|
||||
{% endif %}
|
||||
</a>
|
||||
{% if emotion_you_like_that[loop.index0]['like'] != None %}
|
||||
<p style="color:#ffffff">{{emotion_you_like_that[loop.index0]['like']}}</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
{% if emotion_you_like_that[loop.index0]['link'] != None %}
|
||||
<details>
|
||||
<summary class="emot_block">
|
||||
<strong class="emot_block">Ссылки</strong>
|
||||
</summary>
|
||||
<p></p>
|
||||
{% for item2 in emotion_you_like_that[loop.index0]['link'] %}
|
||||
<div class="link">
|
||||
<p><a class="alert alert-light" role="alert" href="{{ item2 }}" style="border-radius: 22px;">Ссылка
|
||||
{{ loop.index }}</a></p>
|
||||
</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_you_like_that[loop.index0]['author'].photo }}" width="40" height="40"
|
||||
style="border-radius: 22px">
|
||||
<strong style="color: #ffffff">{{ emotion_you_like_that[loop.index0]['author'].name }}</strong>
|
||||
</div>
|
||||
<strong style="color:#ffffff">{{item.date}}</strong>
|
||||
{% if current_user.is_authenticated %}
|
||||
{% if current_user.role == 'admin' %}
|
||||
<a style="border-radius: 15px;" href="/post_deleted/{{ item.id }}" class="btn btn-danger">
|
||||
Удалить
|
||||
</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="bad_centre" style="background-color:#1daff0; border-radius: 22px;color:#ffffff">
|
||||
<p class="hz1">Ничего не нашлось :с</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</th>
|
||||
</table>
|
||||
<img class="article_one_image" src="../static/img/neon_man.png">
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
Loading…
x
Reference in New Issue
Block a user