diff --git a/data/diary_post.py b/data/diary_post.py index e4aabf2..d4f896b 100644 --- a/data/diary_post.py +++ b/data/diary_post.py @@ -18,5 +18,4 @@ class DiaryPost(SqlAlchemyBase, UserMixin): public = sqlalchemy.Column(sqlalchemy.Boolean, nullable=True) pos_emot = sqlalchemy.Column(sqlalchemy.Text, nullable=True) nig_emot = sqlalchemy.Column(sqlalchemy.Text, nullable=True) - case = sqlalchemy.Column(sqlalchemy.Text, nullable=True) link = sqlalchemy.Column(sqlalchemy.Text, nullable=True) diff --git a/db/moona_data.db b/db/moona_data.db index d0ac84a..51a15b6 100644 Binary files a/db/moona_data.db and b/db/moona_data.db differ diff --git a/documents/шаблоны/Цвета.txt b/documents/шаблоны/Цвета.txt index 8bea9ed..07679ad 100644 --- a/documents/шаблоны/Цвета.txt +++ b/documents/шаблоны/Цвета.txt @@ -1,3 +1,5 @@ #1daff0 #a9e4ff -#42e6ec \ No newline at end of file +#42e6ec +#c5f1ff +#7fc3ff \ No newline at end of file diff --git a/forms/post.py b/forms/post.py new file mode 100644 index 0000000..3c68a1c --- /dev/null +++ b/forms/post.py @@ -0,0 +1,14 @@ +from flask_wtf import FlaskForm +from flask_wtf.file import FileAllowed +from wtforms import StringField, TextAreaField, FileField, BooleanField +from wtforms.validators import DataRequired + + +class AddPost(FlaskForm): + name = StringField('Название') + text = TextAreaField('Расскажите, что нового?') + photo = FileField('Прикрепите фото', validators=[FileAllowed(['jpg', 'png'])]) + public = BooleanField('Опубликовать?') + pos_emot = TextAreaField('Какие позитивные эмоции вы испытываете?') + nig_emot = TextAreaField('Какие негативные эмоции вы испытываете?') + link = TextAreaField('Вы можете оставить тут ссылки через пробел') diff --git a/forms/register.py b/forms/register.py index 945c9d8..e0be1fa 100644 --- a/forms/register.py +++ b/forms/register.py @@ -9,7 +9,7 @@ class RegisterForm(FlaskForm): name = StringField('Имя', validators=[DataRequired()]) surname = StringField('Фамилия', validators=[DataRequired()]) login = StringField('Логин', validators=[DataRequired()]) - age = IntegerField('Age', validators=[DataRequired()]) + age = IntegerField('Возраст', validators=[DataRequired()]) about = TextAreaField('Расскажите о себе', default='') photo = FileField('Фото', validators=[FileAllowed(['jpg', 'png'])]) password = PasswordField('Пароль', validators=[DataRequired()]) diff --git a/main.py b/main.py index e403870..56cf19e 100644 --- a/main.py +++ b/main.py @@ -42,11 +42,19 @@ def main_page(): return render_template('base.html', title='moona') +@app.route('/add_post', methods=['GET', 'POST']) +def add_post(): + return render_template('post.html') + + @app.route('/diary', methods=['GET', 'POST']) def diary(): db_sess = db_session.create_session() - posts = db_sess.query(DiaryPost).filter(DiaryPost.author == current_user.id).all() - return render_template('diary.html', title='moona', item=posts) + if current_user.is_authenticated: + posts = db_sess.query(DiaryPost).filter(DiaryPost.author == current_user.id).all() + else: + posts = None + return render_template('diary.html', title='moona', post=posts) @app.route('/logout') @@ -83,6 +91,7 @@ def confirmation(): if not send_msg: secret_code = secret_key() mail(f'Ваш секретный код: {secret_code}', form.email.data, 'Moona Код') + print(secret_code) send_msg = True if conf.validate_on_submit(): if str(conf.code_key.data).strip() == str(secret_code).strip(): diff --git a/static/css/diary.css b/static/css/diary.css index fb960fb..1f9b089 100644 --- a/static/css/diary.css +++ b/static/css/diary.css @@ -16,4 +16,33 @@ text-align: center; } #image { width: 70%; +} +#all_my_post { +width: 30%; +margin-left: auto; + margin-right: auto; +} +#my_post { +text-align: center; +margin-left: auto; + margin-right: auto; + margin-top: 25px; + background-color: #7fc3ff; + border-radius: 22px; +} +.my_author, .my_post_zag { +text-align: center; +margin-left: auto; + margin-right: auto; + margin-top: 25px; +} +#pub, #private { +width: 60%; +height: 10%; +margin-left: auto; + margin-right: auto; +} +#add_post { +margin-top: 20px; +margin-left: 85%; } \ No newline at end of file diff --git a/static/img/user_photo/Duvakin_logo.png b/static/img/user_photo/Duvakin_logo.png new file mode 100644 index 0000000..ab5bf79 Binary files /dev/null and b/static/img/user_photo/Duvakin_logo.png differ diff --git a/templates/diary.html b/templates/diary.html index 0b9c9b1..4c75a09 100644 --- a/templates/diary.html +++ b/templates/diary.html @@ -4,47 +4,58 @@ {% block content %} {% if current_user.is_authenticated %}
+ Добавить + запись +

Мои записи

+
{% for item in post %} -
-

{{item.name}}

- {{item.text}} +
+

{{item.name}}

+ {{item.text}} + {% if item.pos_emot != None %}
- {% for item2 in item.pos_emot.split('%$%') %} + {% for item2 in item.pos_emot %} {{item2}} {% endfor %}
-
- {% for item2 in item.nig_emot.split('%$%') %} - {{item2}} - {% endfor %} -
-
- {% for item2 in item.case.split('%$%') %} - {{item2}} - {% endfor %} -
- {% if item.photo != '' %} -
- -
{% endif %} - {% if item.link != '' %} + {% if item.nig_emot != None %} +
+ {% 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 %} +
+ +
+ {% endif %} + {% if item.link != None %} {% for item2 in item.link %} {% endfor %} {% endif %} - {% if item.public == 1 %} -
Запись опубликована
+ {% if item.public == 1 or item.public == 'True' %} + {% else %} -
Запись приватная
+ {% endif %} -
{{ current_user.name }}
+ {{item.date}}
{% endfor %}
diff --git a/templates/post.html b/templates/post.html new file mode 100644 index 0000000..c3e1875 --- /dev/null +++ b/templates/post.html @@ -0,0 +1,18 @@ + +{% extends "base.html" %} + +{% block content %} +{% if current_user.is_authenticated %} + +{% else %} +
+
+

Вы не авторизованы в системе

+

Поэтому вам не доступна эта страница

Но вы можете посмотреть + публикации других пользователей в разделе Главная или Публикации +

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