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