Исправлено сохранение фотографий для постов
This commit is contained in:
parent
5a367a5df4
commit
f64e568bf6
BIN
db/moona_data.db
BIN
db/moona_data.db
Binary file not shown.
@ -11,7 +11,7 @@ class RegisterForm(FlaskForm):
|
|||||||
login = StringField('Логин', validators=[DataRequired()])
|
login = StringField('Логин', validators=[DataRequired()])
|
||||||
age = IntegerField('Возраст', validators=[DataRequired()])
|
age = IntegerField('Возраст', validators=[DataRequired()])
|
||||||
about = TextAreaField('Расскажите о себе', default='')
|
about = TextAreaField('Расскажите о себе', default='')
|
||||||
photo = FileField('Фото', validators=[FileAllowed(['jpg', 'png'])])
|
photo = FileField('Фото', validators=[FileAllowed(['jpg', 'png'], 'Images only!')])
|
||||||
password = PasswordField('Пароль', validators=[DataRequired()])
|
password = PasswordField('Пароль', validators=[DataRequired()])
|
||||||
password2 = PasswordField('Повторите пароль', validators=[DataRequired()])
|
password2 = PasswordField('Повторите пароль', validators=[DataRequired()])
|
||||||
submit = SubmitField('Регистрация')
|
submit = SubmitField('Регистрация')
|
||||||
|
|||||||
11
main.py
11
main.py
@ -275,14 +275,12 @@ def add_question():
|
|||||||
@app.route('/post/<int:id>', methods=['GET', 'POST'])
|
@app.route('/post/<int:id>', methods=['GET', 'POST'])
|
||||||
def post_edit(id):
|
def post_edit(id):
|
||||||
global photo
|
global photo
|
||||||
|
global help_arg
|
||||||
post_ed = AddPost()
|
post_ed = AddPost()
|
||||||
ph_f = False
|
ph_f = False
|
||||||
if post_ed.del_photo.data:
|
if post_ed.del_photo.data:
|
||||||
session = db_session.create_session()
|
help_arg = photo
|
||||||
post_exc = session.query(DiaryPost).filter(DiaryPost.id == id,
|
photo = None
|
||||||
DiaryPost.author == current_user.id).first()
|
|
||||||
post_exc.photo = None
|
|
||||||
session.commit()
|
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
session = db_session.create_session()
|
session = db_session.create_session()
|
||||||
post_exc = session.query(DiaryPost).filter(DiaryPost.id == id,
|
post_exc = session.query(DiaryPost).filter(DiaryPost.id == id,
|
||||||
@ -312,6 +310,9 @@ def post_edit(id):
|
|||||||
post_exc.pos_emot = post_ed.pos_emot.data
|
post_exc.pos_emot = post_ed.pos_emot.data
|
||||||
post_exc.nig_emot = post_ed.nig_emot.data
|
post_exc.nig_emot = post_ed.nig_emot.data
|
||||||
post_exc.link = post_ed.link.data
|
post_exc.link = post_ed.link.data
|
||||||
|
if help_arg:
|
||||||
|
os.remove(help_arg[3:])
|
||||||
|
help_arg = False
|
||||||
if post_ed.photo.data:
|
if post_ed.photo.data:
|
||||||
post_exc.photo = save_photo(post_ed.photo.data, current_user.login, post=True, id_post=post_exc.id)
|
post_exc.photo = save_photo(post_ed.photo.data, current_user.login, post=True, id_post=post_exc.id)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Binary file not shown.
|
Before Width: | Height: | Size: 2.7 MiB After Width: | Height: | Size: 1.8 MiB |
@ -1,15 +1,13 @@
|
|||||||
.divlog {
|
.divlog {
|
||||||
margin-left: auto;
|
margin-left: 10%;
|
||||||
margin-right: auto;
|
margin-right: auto;
|
||||||
width: 80%;
|
width: 80%;
|
||||||
height: 50%
|
height: 50%;
|
||||||
|
margin-top: 35px;
|
||||||
}
|
}
|
||||||
.title {
|
.title {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
#buttons {
|
|
||||||
margin-left: -4%;
|
|
||||||
}
|
|
||||||
input[type=text], input[type=email], input[type=password], input[type=file], input[type=number]{
|
input[type=text], input[type=email], input[type=password], input[type=file], input[type=number]{
|
||||||
padding:10px;
|
padding:10px;
|
||||||
border:10;
|
border:10;
|
||||||
@ -31,3 +29,18 @@ textarea {
|
|||||||
.box {
|
.box {
|
||||||
margin-left: 20px;
|
margin-left: 20px;
|
||||||
}
|
}
|
||||||
|
.zag_auth {
|
||||||
|
margin-left: 20%;
|
||||||
|
}
|
||||||
|
#but_log1, #but_log2, #but_log3 {
|
||||||
|
width: 24%;
|
||||||
|
}
|
||||||
|
#but_log2 {
|
||||||
|
background-color: #16b8f5;
|
||||||
|
}
|
||||||
|
#but_log2, #but_log3 {
|
||||||
|
margin-left: 3%;
|
||||||
|
}
|
||||||
|
#divlog {
|
||||||
|
margin-left: 20%;
|
||||||
|
}
|
||||||
@ -2,8 +2,8 @@
|
|||||||
{% extends "base.html" %}
|
{% extends "base.html" %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="divlog">
|
<div class="divlog" id="divlog">
|
||||||
<h1>Авторизация</h1>
|
<h1 class="zag_auth">Авторизация</h1>
|
||||||
<form class="row g-2" action="" method="post">
|
<form class="row g-2" action="" method="post">
|
||||||
{{ form.hidden_tag() }}
|
{{ form.hidden_tag() }}
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
@ -32,10 +32,11 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</div>
|
</div>
|
||||||
<div class="col-sm-10" id="buttons">
|
<div class="col-sm-10" id="buttons">{{ form.submit(type="submit", class="btn btn-primary", id="but_log1") }}
|
||||||
<ul>{{ form.submit(type="submit", class="btn btn-primary", style="background-color:#38aaff") }}</ul>
|
<a class="btn btn-primary" id="but_log3" type="submit"
|
||||||
<ul><a class="btn btn-primary" style="background-color:#38aaff" type="submit" href="/recovery"><strong>Забыли
|
href="/register"><strong>Регистрация</strong></a>
|
||||||
пароль</strong></a></ul>
|
<a class="btn btn-primary" type="submit" id="but_log2" href="/recovery"><strong>Забыли
|
||||||
|
пароль</strong></a>
|
||||||
</div>
|
</div>
|
||||||
{% if message != '' %}
|
{% if message != '' %}
|
||||||
<div class="alert alert-danger" role="alert">{{ message }}</div>
|
<div class="alert alert-danger" role="alert">{{ message }}</div>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user