Compare commits

..

No commits in common. "70395b4efec811a5e6199e9f3649715394bc2395" and "c667cc2ab0d1246cdb289a6a90970853a5c695c0" have entirely different histories.

141 changed files with 404 additions and 1004 deletions

11
.gitignore vendored
View File

@ -1,7 +1,4 @@
/moona/documents/
/moona/documents
/moona/db/moona_data.db
/moona/main.log
/.gitignore
__pycache__
/protect.moona
/documents/voucher_moonadiary.ru.pdf
/db/moona_data.db
/main.log
/.gitignore

View File

@ -1,36 +1,21 @@
# P.S.
Это мой первый сайт, который я разрабатывал вместе с Дарьей Толменевой, когда мы учились в Яндекс Лицее.
# MOONA
![alt text](https://github.com/AndreiDuvakin/WebServerProject/blob/main/static/img/НадписьMoona.png)
**moona** это сайт-дневник, который позволяет поделится своими мыслями с другими пользователями. На сайте после регистрации, можно добавлять записи в свой личный дневник и при желании делать запись доступной для всех пользователей сайта.
![string_moona.png](moona/static/img/string_moona.png)
**moona** это сайт-дневник, который позволяет поделится своими мыслями с другими пользователями. На сайте после
регистрации, можно добавлять записи в свой личный дневник и при желании делать запись доступной для всех пользователей
сайта.
Moona выполнена в светло-голубых тонах, чтобы пользователей ничего не отвлекало от использования нашего сайта. На нашем сайте каждый сможет найти что-то подходящее для себя: каждый в праве писать посты для всех или только для себя.
Moona выполнена в светло-голубых тонах, чтобы пользователей ничего не отвлекало от использования нашего сайта. На нашем
сайте каждый сможет найти что-то подходящее для себя: каждый в праве писать посты для всех или только для себя.
Чуть позже здесь появятся картинки нашего сайта с окончательным дизайном, нужно лишь чуть чуть подождать
Чуть позже здесь появятся картинки нашего сайта с окончательным дизайном, нужно лишь чуть чуть подождать
Посмотреть наш сайт вы можете перейдя по ссылке https://moona.net.ru/diary/
Посмотреть наш сайт вы можете перейдя по ссылке https://moonadiary.ru/
____
# Контактики
### Email:
### Email:
- andrei@duvakin.ru
- tolmenevadarya@yandex.ru
- moonadiary@yandex.ru (оффициальная почта)
### VK:
- https://vk.com/andreiduvakin
- https://vk.com/s_plombir19
### Telegram:
- @andrei_duvakin
- @DinPg

View File

@ -25,7 +25,6 @@ class User(SqlAlchemyBase, UserMixin):
default=date.today())
role = sqlalchemy.Column(sqlalchemy.String, nullable=True)
activity = sqlalchemy.Column(sqlalchemy.Date, nullable=True)
birthday = sqlalchemy.Column(sqlalchemy.Date, nullable=True)
def check_password(self, password):
return check_password_hash(self.password, password)

BIN
db/moona_data.db Normal file

Binary file not shown.

View File

@ -1,12 +0,0 @@
version: '3.8'
services:
app_moona:
build:
context: ./moona
volumes:
- ./moona/db:/app/db
- ./moona/static:/app/static
environment:
- SECRET_KEY=your-secret-key
restart: always

BIN
documents/moona.docx Normal file

Binary file not shown.

BIN
documents/moona.pptx Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 958 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 KiB

View File

Before

Width:  |  Height:  |  Size: 798 KiB

After

Width:  |  Height:  |  Size: 798 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 972 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

Binary file not shown.

View File

Before

Width:  |  Height:  |  Size: 1.0 MiB

After

Width:  |  Height:  |  Size: 1.0 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 MiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

View File

@ -0,0 +1,5 @@
#1daff0
#a9e4ff
#42e6ec
#c5f1ff
#7fc3ff

View File

@ -1,6 +1,6 @@
from flask_wtf import FlaskForm
from flask_wtf.file import FileAllowed
from wtforms import EmailField, StringField, PasswordField, SubmitField, FileField, DateField, TextAreaField
from wtforms import EmailField, StringField, PasswordField, SubmitField, FileField, IntegerField, TextAreaField
from wtforms.validators import DataRequired
@ -9,7 +9,7 @@ class RegisterForm(FlaskForm):
name = StringField('Имя', validators=[DataRequired()])
surname = StringField('Фамилия', validators=[DataRequired()])
login = StringField('Логин', validators=[DataRequired()])
birthday = DateField('Дата рождения', validators=[DataRequired()])
age = IntegerField('Возраст')
about = TextAreaField('Расскажите о себе', default='')
photo = FileField('Фото', validators=[FileAllowed(['jpg', 'png'], 'Images only!')])
password = PasswordField('Пароль', validators=[DataRequired()])

24
main.log Normal file
View File

@ -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

View File

@ -28,7 +28,7 @@ from forms.register import RegisterForm, Confirmation
from post import mail
app = Flask(__name__)
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY', 'default_key_for_dev')
app.config['SECRET_KEY'] = 'moona_secret_key'
logging.basicConfig(filename='main.log')
login_manager = LoginManager()
login_manager.init_app(app)
@ -86,120 +86,58 @@ def main_page():
@app.route('/login', methods=['GET', 'POST'])
def login():
if not current_user.is_authenticated:
redir = request.args.get('redir') if request.args.get('redir') else False
form = LoginForm()
if form.validate_on_submit():
db_sess = db_session.create_session()
user = db_sess.query(User).filter(User.email == form.email.data).first()
if user and user.check_password(form.password.data):
login_user(user, remember=form.remember_me.data)
if redir:
return redirect(f'/{redir}')
else:
return redirect('/')
return render_template('main/login.html',
message="Неправильный логин или пароль",
form=form)
return render_template('main/login.html', title='Авторизация', form=form, message='')
else:
return redirect('/')
form = LoginForm()
if form.validate_on_submit():
db_sess = db_session.create_session()
user = db_sess.query(User).filter(User.email == form.email.data).first()
if user and user.check_password(form.password.data):
login_user(user, remember=form.remember_me.data)
return redirect('/')
return render_template('main/login.html',
message="Неправильный логин или пароль",
form=form)
return render_template('main/login.html', title='Авторизация', form=form, message='')
@app.route('/register', methods=['GET', 'POST'])
def register():
if not current_user.is_authenticated:
form = RegisterForm()
form.simple = True
if form.validate_on_submit():
if form.password.data != form.password2.data:
return render_template('main/register.html', title='Регистрация',
form=form,
message="Пароли не совпадают")
data_session = db_session.create_session()
if data_session.query(User).filter(User.login == form.login.data).first():
return render_template('main/register.html', title='Регистрация',
form=form,
message="Такой пользователь уже есть")
if data_session.query(User).filter(User.email == form.email.data).first():
return render_template('main/register.html', title='Регистрация',
form=form,
message="Такая почта уже есть")
if form.photo.data:
photo = save_photo(form.photo.data, form.login.data)
else:
photo = False
session['ps'] = form.password.data
return redirect(
url_for('confirmation', photo=photo, name=form.name.data, surname=form.surname.data,
login=form.login.data,
birthday=form.birthday.data, about=form.about.data, email=form.email.data, form=True))
return render_template('main/register.html', title='Регистрация', form=form, message='')
else:
return redirect('/')
@app.route('/user/<string:login>', methods=['GET', 'POST'])
def profile(login):
if current_user.is_authenticated and current_user.login == login:
message = request.args.get('message') if request.args.get('message') else ''
form = RegisterForm()
if form.del_photo.data:
data_session = db_session.create_session()
user = data_session.query(User).filter(User.id == current_user.id).first()
os.remove(user.photo)
user.photo = '/static/img/None_logo.png'
data_session.commit()
data_session.close()
return redirect(f'/user/{login}')
if request.method == 'GET':
form.email.data = current_user.email
form.name.data = current_user.name
form.surname.data = current_user.surname
form.birthday.data = current_user.birthday
form.about.data = current_user.about
form.photo.data = current_user.photo if current_user.photo and 'None' not in current_user.photo else None
if form.submit2.data:
data_session = db_session.create_session()
user = data_session.query(User).filter(User.id == current_user.id).first()
if user:
if form.photo.data != current_user.photo:
if form.photo.data:
user.photo = save_photo(form.photo.data, login)
user.name = form.name.data
user.surname = form.surname.data
user.birthday = form.birthday.data
user.about = form.about.data
data_session.commit()
data_session.close()
if form.email.data != current_user.email:
if data_session.query(User).filter(User.email == form.email.data).first():
return redirect(f'/user/{login}?message=Такая почта уже есть')
session['ps'] = None
return redirect(
url_for('confirmation', email_conf=True, email=form.email.data, form=True)
)
return redirect(f'/user/{login}')
else:
abort(404)
return render_template('main/profile.html', title='Профиль', form=form, message=message)
elif current_user.is_authenticated and current_user.login != login:
pass
else:
return redirect('/login')
form = RegisterForm()
form.simple = True
if form.validate_on_submit():
if form.password.data != form.password2.data:
return render_template('main/register.html', title='Регистрация',
form=form,
message="Пароли не совпадают")
data_session = db_session.create_session()
if data_session.query(User).filter(User.login == form.login.data).first():
return render_template('main/register.html', title='Регистрация',
form=form,
message="Такой пользователь уже есть")
if data_session.query(User).filter(User.email == form.email.data).first():
return render_template('main/register.html', title='Регистрация',
form=form,
message="Такая почта уже есть")
if form.photo.data:
photo = save_photo(form.photo.data, form.login.data)
else:
photo = False
session['ps'] = form.password.data
return redirect(
url_for('confirmation', photo=photo, name=form.name.data, surname=form.surname.data, login=form.login.data,
age=form.age.data, about=form.about.data, email=form.email.data, form=True))
return render_template('main/register.html', title='Регистрация', form=form, message='')
@app.route('/confirmation', methods=['GET', 'POST'])
def confirmation():
if request.args.get('form'):
app_school = request.args.get('app_school') if request.args.get('app_school') else False
email_conf = request.args.get('email_conf') if request.args.get('email_conf') else False
data_session = db_session.create_session()
form = RegisterForm(
name=request.args.get('name'),
surname=request.args.get('surname'),
login=request.args.get('login'),
birthday=request.args.get('birthday'),
age=request.args.get('age'),
about=request.args.get('about'),
email=request.args.get('email'),
password=session['ps']
@ -225,59 +163,47 @@ def confirmation():
conf = Confirmation()
if conf.validate_on_submit():
if str(conf.code_key.data).strip() == str(session['secret_code']).strip():
if not email_conf:
if form.photo.data:
user = User(
name=form.name.data,
surname=form.surname.data,
login=form.login.data,
birthday=datetime.datetime.strptime(form.birthday.data, "%Y-%m-%d").date(),
about=form.about.data,
email=form.email.data,
photo=save_photo(session['photo'], form.login.data),
role='user'
)
else:
user = User(
name=form.name.data,
surname=form.surname.data,
login=form.login.data,
birthday=datetime.datetime.strptime(form.birthday.data, "%Y-%m-%d").date(),
about=form.about.data,
email=form.email.data,
role='user',
photo='/static/img/None_logo.png'
)
user.set_password(form.password.data)
data_session.add(user)
data_session.commit()
data_session.close()
session['send_msg'] = False
if app_school:
return redirect('/safeappschool/login')
else:
return redirect('/login')
if form.photo.data:
user = User(
name=form.name.data,
surname=form.surname.data,
login=form.login.data,
age=form.age.data,
about=form.about.data,
email=form.email.data,
photo=session['photo'],
role='user'
)
else:
user = data_session.query(User).filter(User.id == current_user.id).first()
if user:
user.email = form.email.data
data_session.commit()
data_session.close()
return redirect(f'/user/{current_user.login}')
else:
abort(404)
user = User(
name=form.name.data,
surname=form.surname.data,
login=form.login.data,
age=form.age.data,
about=form.about.data,
email=form.email.data,
role='user',
photo='../../static/img/None_logo.png'
)
user.set_password(form.password.data)
data_session.add(user)
data_session.commit()
session['send_msg'] = False
if app_school:
return redirect('/safeappschool/login')
else:
return redirect('/login')
else:
session['no_code'] = True
if app_school:
return render_template('safe_app_school/confirmation.html', title='Подтверждение', form=conf,
return render_template('simple/simple_confirmation.html', title='Подтверждение', form=conf,
message='Коды не совпадают')
else:
return render_template('main/confirmation_reg.html', title='Подтверждение', form=conf,
message='Коды не совпадают')
else:
if app_school:
return render_template('safe_app_school/confirmation.html', title='Подтверждение', form=conf,
message='')
return render_template('simple/simple_confirmation.html', title='Подтверждение', form=conf, message='')
else:
return render_template('main/confirmation_reg.html', title='Подтверждение', form=conf, message='')
else:
@ -287,12 +213,8 @@ def confirmation():
@app.route('/logout')
@login_required
def logout():
path = request.args.get('path')
logout_user()
if not path:
return redirect("/")
else:
return redirect(f'/{path}')
return redirect("/")
@app.route('/safeappschool')
@ -310,54 +232,47 @@ def safe_app_school_main():
@app.route('/safeappschool/login', methods=['GET', 'POST'])
def safe_app_school_login():
if current_user.is_authenticated:
return redirect('/safeappschool/main')
else:
form = LoginForm()
if form.validate_on_submit():
db_sess = db_session.create_session()
user = db_sess.query(User).filter(User.email == form.email.data).first()
if user and user.check_password(form.password.data):
login_user(user, remember=form.remember_me.data)
return redirect('/safeappschool/main')
return render_template('/safe_app_school/login.html',
message="Неправильный логин или пароль",
form=form)
return render_template('/safe_app_school/login.html', title='Вход', form=form, message='')
form = LoginForm()
if form.validate_on_submit():
db_sess = db_session.create_session()
user = db_sess.query(User).filter(User.email == form.email.data).first()
if user and user.check_password(form.password.data):
login_user(user, remember=form.remember_me.data)
return redirect('/safeappschool/main')
return render_template('/simple/simple_login.html',
message="Неправильный логин или пароль",
form=form)
return render_template('/simple/simple_login.html', title='Вход', form=form, message='')
@app.route('/safeappschool/register', methods=['GET', 'POST'])
def safe_app_school_register():
if current_user.is_authenticated:
return redirect('/safeappschool/main')
else:
form = RegisterForm()
form.simple = True
if form.validate_on_submit():
if form.password.data != form.password2.data:
return render_template('simple/simple_register.html', title='Регистрация',
form=form,
message="Пароли не совпадают")
data_session = db_session.create_session()
if data_session.query(User).filter(User.login == form.login.data).first():
return render_template('safe_app_school/register.html', title='Регистрация',
form=form,
message="Такой пользователь уже есть")
if data_session.query(User).filter(User.email == form.email.data).first():
return render_template('safe_app_school/register.html', title='Регистрация',
form=form,
message="Такая почта уже есть")
if form.photo.data:
photo = save_photo(form.photo.data, form.login.data)
else:
photo = False
session['ps'] = form.password.data
return redirect(
url_for('confirmation', photo=photo, name=form.name.data, surname=form.surname.data,
login=form.login.data,
birthday=form.birthday.data, about=form.about.data, email=form.email.data, form=True,
app_school=True))
return render_template('safe_app_school/register.html', title='Регистрация', form=form, message='')
form = RegisterForm()
form.simple = True
if form.validate_on_submit():
if form.password.data != form.password2.data:
return render_template('simple/simple_register.html', title='Регистрация',
form=form,
message="Пароли не совпадают")
data_session = db_session.create_session()
if data_session.query(User).filter(User.login == form.login.data).first():
return render_template('simple/simple_register.html', title='Регистрация',
form=form,
message="Такой пользователь уже есть")
if data_session.query(User).filter(User.email == form.email.data).first():
return render_template('simple/simple_register.html', title='Регистрация',
form=form,
message="Такая почта уже есть")
if form.photo.data:
photo = save_photo(form.photo.data, form.login.data)
else:
photo = False
session['ps'] = form.password.data
return redirect(
url_for('confirmation', photo=photo, name=form.name.data, surname=form.surname.data,
login=form.login.data,
age=form.age.data, about=form.about.data, email=form.email.data, form=True, app_school=True))
return render_template('simple/simple_register.html', title='Регистрация', form=form, message='')
@app.route('/safeappschool/about')
@ -407,11 +322,11 @@ def safe_app_school_go(point):
with open('static/js/safe_app_school/mapbasics_templates.js', 'r', encoding='utf-8') as file:
new_file = file.read().split('<point1>')
new_file = new_file[
0] + f'\'{str(address.home_address).strip() if point == "school" else str(address.school_address).strip()}\'' \
0] + f'\'{str(address.home_address).strip() if point == "home" else str(address.school_address).strip()}\'' \
+ new_file[1]
new_file = new_file.split('<point2>')
new_file = new_file[
0] + f'\'{str(address.school_address).strip() if point == "school" else str(address.home_address).strip()}\'' + \
0] + f'\'{str(address.school_address).strip() if point == "home" else str(address.home_address).strip()}\'' + \
new_file[1]
with open(f'static/js/safe_app_school/{str(current_user.id)}mapbasics.js', 'w',
encoding='utf-8') as new_js:
@ -449,7 +364,7 @@ def edit_profile(logins):
form = RegisterForm()
session = db_session.create_session()
ph_f = False
if 'None_logo' not in current_user.photo:
if current_user.photo != '../../static/img/None_logo.png':
photo = current_user.photo
ph_f = True
else:
@ -457,6 +372,7 @@ def edit_profile(logins):
if form.del_photo.data:
help_arg = photo
ph_f = False
photo = '../../static/img/None_logo.png'
if form.submit2.data:
user = session.query(User).filter(User.login == logins).first()
if user.email != form.email.data:
@ -472,12 +388,11 @@ def edit_profile(logins):
return redirect('/diary/confirmation')
user.name = form.name.data
user.surname = form.surname.data
user.birthday = form.birthday.data
user.age = form.age.data
user.about = form.about.data
photo = '../../static/img/None_logo.png'
if not ph_f and form.photo.data:
photo = save_photo(form.photo.data, logins)
if help_arg == photo:
if help_arg:
os.remove(help_arg)
help_arg = False
photo = '../../static/img/None_logo.png'
@ -495,7 +410,7 @@ def edit_profile(logins):
form.name.data = current_user.name
form.surname.data = current_user.surname
form.login.data = logins
form.birthday.data = current_user.birthday
form.age.data = current_user.age
form.about.data = current_user.about
form.password.data = None
form.password2.data = None
@ -508,7 +423,7 @@ def edit_profile(logins):
@app.route('/diary/profile')
def diary_profile():
def profile():
if current_user.is_authenticated:
global help_arg_2
db_sess = db_session.create_session()
@ -813,7 +728,7 @@ def post_edit(id):
post_exc.nig_emot = post_ed.nig_emot.data
post_exc.link = post_ed.link.data
if help_arg:
os.remove(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,
@ -847,7 +762,7 @@ def post_deleted(id):
pos = session.query(DiaryPost).filter(DiaryPost.id == id).first()
if pos:
if pos.photo:
os.remove(pos.photo)
os.remove(pos.photo[3:])
likes = session.query(Like).filter(Like.post == pos.id).all()
if likes:
list(map(lambda i: session.delete(i), likes))
@ -1000,11 +915,172 @@ def diary_logout():
return redirect("/diary/")
@app.route('/diary/login', methods=['GET', 'POST'])
def diary_login():
form = LoginForm()
if form.validate_on_submit():
db_sess = db_session.create_session()
user = db_sess.query(User).filter(User.email == form.email.data).first()
if user and user.check_password(form.password.data):
login_user(user, remember=form.remember_me.data)
return redirect("/diary/")
return render_template('diary/login.html',
message="Неправильный логин или пароль",
form=form)
return render_template('diary/login.html', title='Авторизация', form=form, message='')
@app.route('/diary/confirmation', methods=['GET', 'POST'])
def diary_onfirmation():
global help_arg
if help_arg:
global send_msg
global secret_code
global photo
global help_arg_2
session = db_session.create_session()
if not help_arg_2:
form = help_arg
if not send_msg:
secret_code = secret_key()
mail(f'Ваш секретный код: {secret_code}', form.email.data, 'Moona Код')
send_msg = True
conf = Confirmation()
if conf.validate_on_submit():
if str(conf.code_key.data).strip() == str(secret_code).strip():
if form.photo.data:
user = User(
name=form.name.data,
surname=form.surname.data,
login=form.login.data,
age=form.age.data,
about=form.about.data,
email=form.email.data,
photo=photo,
role='user'
)
else:
user = User(
name=form.name.data,
surname=form.surname.data,
login=form.login.data,
age=form.age.data,
about=form.about.data,
email=form.email.data,
role='user',
photo='../../static/img/None_logo.png'
)
user.set_password(form.password.data)
session.add(user)
session.commit()
send_msg = False
help_arg = False
if form.simple:
return redirect('/diary/simple/can_close')
else:
return redirect('/diary/login')
else:
if form.simple:
return render_template('simple/simple_confirmation.html', title='Подтверждение', form=conf,
message='Коды не совпадают')
else:
return render_template('diary/confirmation_reg.html', title='Подтверждение', form=conf,
message='Коды не совпадают')
if form.simple:
return render_template('simple/simple_confirmation.html', title='Подтверждение', form=conf,
message='Коды не совпадают')
else:
return render_template('diary/confirmation_reg.html', title='Подтверждение', form=conf, message='')
else:
conf = Confirmation()
if not send_msg:
secret_code = secret_key()
mail(f'Ваш секретный код: {secret_code}', help_arg_2, 'Moona Код')
send_msg = True
if conf.validate_on_submit():
if str(conf.code_key.data).strip() == str(secret_code).strip():
user = session.query(User).filter(User.id == current_user.id).first()
user.email = help_arg_2
help_arg_2 = 'EditEmail'
session.commit()
send_msg = False
help_arg = False
return redirect('/diary/profile')
if form.simple:
return render_template('simple_confirmation.html', title='Подтверждение', form=conf,
message='Коды не совпадают')
else:
return render_template('diary/confirmation_reg.html', title='Подтверждение', form=conf, message='')
else:
return redirect('/diary/')
@app.route('/diary/register', methods=['GET', 'POST'])
def diary_register():
global help_arg
global photo
form = RegisterForm()
if form.validate_on_submit():
if form.password.data != form.password2.data:
return render_template('diary/register.html', title='Регистрация',
form=form,
message="Пароли не совпадают")
session = db_session.create_session()
if session.query(User).filter(User.login == form.login.data).first():
return render_template('diary/register.html', title='Регистрация',
form=form,
message="Такой пользователь уже есть")
if session.query(User).filter(User.email == form.email.data).first():
return render_template('diary/register.html', title='Регистрация',
form=form,
message="Такая почта уже есть")
help_arg = form
if form.photo.data:
photo = save_photo(form.photo.data, form.login.data)
return redirect('/diary/confirmation')
return render_template('diary/register.html', title='Регистрация', form=form, message='')
@app.route('/diary/about_us')
def about():
return render_template('diary/about.html', title='О нас')
@app.route('/diary/recovery', methods=['GET', 'POST'])
def recovery():
global send_msg
global secret_code
global help_arg
global user_email
form = RecoveryForm()
conf = Conf()
finish = Finish()
session = db_session.create_session()
if form.validate_on_submit() and form.email.data:
user_email = form.email.data
if not send_msg:
secret_code = secret_key()
mail(f'Ваш секретный код: {secret_code}', form.email.data, 'Восстановление пароля')
send_msg = True
return render_template('diary/recovery.html', title='Восстановление пароля', form=conf, message='', s='2')
if conf.validate_on_submit():
if str(conf.code_key.data).strip() == str(secret_code).strip():
help_arg = True
return render_template('diary/recovery.html', title='Восстановление пароля', form=finish, message='', s='3')
if help_arg:
if finish.validate_on_submit():
db_sess = db_session.create_session()
user = db_sess.query(User).filter(User.email == user_email).first()
user.set_password(finish.password.data)
user2 = session.merge(user)
session.add(user2)
session.commit()
send_msg = False
return redirect('/diary/login')
return render_template('diary/recovery.html', title='Восстановление пароля', form=form, message='', s='1')
@app.route('/school_app_check_auth', methods=['POST'])
def check_auth():
req = request.json

View File

@ -1,15 +0,0 @@
FROM python:3.10-slim
RUN apt-get update && apt-get install -y \
libpq-dev \
&& rm -rf /var/lib/apt/lists/*
WORKDIR /app
COPY requirements.txt .
RUN pip install --no-cache-dir -r requirements.txt
COPY . .
CMD ["python", "main.py"]

View File

@ -1,4 +0,0 @@
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

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 513 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 90 KiB

View File

@ -1,60 +0,0 @@
.profile {
width: 70%;
margin-left: auto;
margin-right: auto;
}
.head {
width: 80%;
margin-left: 10%;
margin-right: 10%;
}
.user_photo {
border-radius: 50%;
width: 35%;
margin-left: 32%;
margin-right: 32%;
border: 5px solid #ffffff;
transition: box-shadow 1s ease-in, border 1s ease-in;
}
.user_photo:hover {
border: 2px solid #ffffff;
box-shadow: 0px 0px 50px #fff;
}
.user_name {
text-align: center;
color: white;
margin-left: 27%;
margin-right: 27%;
width: 46%;
height: auto;
margin-top: 15px;
transition: font-size 1s ease-in, text-shadow 1s ease-in;
}
.user_name:hover {
font-size: 45;
text-shadow: 0px 0px 20px #ffffff;
}
.photo_buttons {
margin-top: 5px;
margin-left: 15px;
}
.submit_button {
margin-top: 5px;
margin-left: 45%;
}
.back {
background: linear-gradient(45deg, #d1c3fc, #9bc4fc);
border-radius: 19px;
border: 2px solid #ffffff;
width: 10%;
margin-left: 12px;
height: 42px;
color: #ffffff;
transition: box-shadow 1s ease-in, border 0.3s ease-in, background 2s ease-in;
}
.back:hover
{
border: 4px solid #ffffff;
box-shadow: 0px 0px 50px #fff;
background: rgb(0, 222, 0);
}

View File

@ -1,70 +0,0 @@
.divlog {
margin-left: 10%;
margin-right: auto;
width: 80%;
height: 50%;
margin-top: 35px;
}
.title {
font-size: 3.5vw;
text-align: center;
color: white;
width: auto;
height: auto;
margin-top: 15px;
transition: font-size 0.5s ease-in, text-shadow 1s ease-in;
}
.title:hover {
font-size: 4vw;
text-shadow: 0px 0px 20px #ffffff;
}
input[type=text], input[type=email], input[type=password], input[type=file], input[type=number]{
padding:10px;
border:10;
box-shadow:0 0 15px 4px rgba(0,0,0,0.06);
border-radius:10px;
}
textarea {
width:100%;
resize: vertical;
padding:10px;
border-radius:10px;
border:10;
box-shadow:0 0 15px 4px rgba(0,0,0,0.06);
height:150px;
}
.but {
margin: 40px;
}
.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%;
}
.back {
margin-top: 5%;
background: linear-gradient(45deg, #d1c3fc, #9bc4fc);
border-radius: 22px;
border: 2px solid #ffffff;
width: 20%;
margin-left: 40%;
height: 8%;
font-size: 1.5vw;
}
.back_text {
margin-top: 4%;
text-align: center;
}

View File

@ -1,61 +0,0 @@
.header_title {
font-size: 3.5vw;
text-align: center;
color: white;
width: auto;
height: auto;
margin-top: 15px;
transition: font-size 0.5s ease-in, text-shadow 1s ease-in;
}
.header_title:hover {
font-size: 4vw;
text-shadow: 0px 0px 20px #ffffff;
}
form {
width: 80%;
margin-left: 10%;
margin-right: 10%;
}
.page, .form-control, .form-label {
width: 70%;
margin-left: 15%;
margin-right: 15%;
}
.box {
margin-left: 20%;
}
.login_form {
width: 70%;
margin-left: 15%;
margin-right: 15%;
display: flex;
flex-flow: column;
}
.buttons_from {
width: 100%;
margin-left: 15%;
display: flex;
justify-content: space-evenly;
flex-wrap: wrap;
}
.button {
margin-top: 5px;
width: auto;
height: auto;
display: flex;
align-self: stretch;
}
.text_button {
margin-top: auto;
width: 90%;
height: 90%;
font-size: 1.2vw;
}
.apk {
width: 40%;
margin-left: 25%;
margin-right: 30%;
}
.text_apk {
text-align: center;
}

View File

@ -1,70 +0,0 @@
.divlog {
margin-left: 10%;
margin-right: auto;
width: 80%;
height: 50%;
margin-top: 35px;
}
.title {
font-size: 3.5vw;
text-align: center;
color: white;
width: auto;
height: auto;
margin-top: 15px;
transition: font-size 0.5s ease-in, text-shadow 1s ease-in;
}
.title:hover {
font-size: 4vw;
text-shadow: 0px 0px 20px #ffffff;
}
input[type=text], input[type=email], input[type=password], input[type=file], input[type=number]{
padding:10px;
border:10;
box-shadow:0 0 15px 4px rgba(0,0,0,0.06);
border-radius:10px;
}
textarea {
width:100%;
resize: vertical;
padding:10px;
border-radius:10px;
border:10;
box-shadow:0 0 15px 4px rgba(0,0,0,0.06);
height:150px;
}
.but {
margin: 40px;
}
.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%;
}
.back {
margin-top: 5%;
background: linear-gradient(45deg, #d1c3fc, #9bc4fc);
border-radius: 22px;
border: 2px solid #ffffff;
width: 20%;
margin-left: 40%;
height: 8%;
font-size: 1.5vw;
}
.back_text {
margin-top: 4%;
text-align: center;
}

View File

@ -1,87 +0,0 @@
<link rel="stylesheet" href="../../static/css/main/profile.css">
{% extends "main/base.html" %}
{% block content %}
<input type="button" class="back" onclick="history.back();" value="Назад"/>
<div class="profile">
<div class="head">
<img class="user_photo" src="../{{current_user.photo}}">
<h2 class="user_name">{{current_user.name}}</h2>
</div>
<div class="body">
<form class="row g-3" action="" method="POST" enctype="multipart/form-data">
{{ form.hidden_tag() }}
{{ form.csrf_token }}
<div class="col-md-6">
<label class="form-label">{{ form.name.label }}</label>
{{ form.name(class="form-control", type="text") }}
{% for error in form.name.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="col-md-6">
<label class="form-label">{{ form.surname.label }}</label>
{{ form.surname(class="form-control", type="text") }}
{% for error in form.surname.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="col-md-4">
<label class="form-label">{{ form.email.label }}</label>
{{ form.email(class="form-control", type="email") }}
{% for error in form.email.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="col-md-4">
<label class="form-label">{{ form.birthday.label }}</label>
{{ form.birthday(class="form-control", type="date") }}
{% for error in form.birthday.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="col-12">
<label class="form-label">{{ form.about.label }}</label>
{{ form.about(class="form-control", type="textarea") }}
{% for error in form.about.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="photo_buttons">
{% if form.photo.data %}
{{ form.del_photo(type="submit", class="btn btn-primary") }}
{% for error in form.del_photo.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
{% else %}
{{ form.photo.label }}<br>
{{ form.photo(class="form-control") }}<br>
{% for error in form.photo.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
{% endif %}
</div>
<div class="submit_button">
<p>{{ form.submit2(type="submit", class="btn btn-primary", style="background-color:#38aaff") }}</p>
{% if message != '' %}
<div class="alert alert-danger" role="alert">{{ message }}</div>
{% endif %}
</div>
</form>
</div>
</div>
{% endblock %}

View File

@ -1,87 +0,0 @@
<link rel="stylesheet" href="../../static/css/main/profile.css">
{% extends "main/base.html" %}
{% block content %}
<input type="button" class="back" onclick="history.back();" value="Назад"/>
<div class="profile">
<div class="head">
<img class="user_photo" src="../{{current_user.photo}}">
<h2 class="user_name">{{current_user.name}}</h2>
</div>
<div class="body">
<form class="row g-3" action="" method="POST" enctype="multipart/form-data">
{{ form.hidden_tag() }}
{{ form.csrf_token }}
<div class="col-md-6">
<label class="form-label">{{ form.name.label }}</label>
{{ form.name(class="form-control", type="text") }}
{% for error in form.name.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="col-md-6">
<label class="form-label">{{ form.surname.label }}</label>
{{ form.surname(class="form-control", type="text") }}
{% for error in form.surname.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="col-md-4">
<label class="form-label">{{ form.email.label }}</label>
{{ form.email(class="form-control", type="email") }}
{% for error in form.email.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="col-md-4">
<label class="form-label">{{ form.birthday.label }}</label>
{{ form.birthday(class="form-control", type="date") }}
{% for error in form.birthday.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="col-12">
<label class="form-label">{{ form.about.label }}</label>
{{ form.about(class="form-control", type="textarea") }}
{% for error in form.about.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="photo_buttons">
{% if form.photo.data %}
{{ form.del_photo(type="submit", class="btn btn-primary") }}
{% for error in form.del_photo.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
{% else %}
{{ form.photo.label }}<br>
{{ form.photo(class="form-control") }}<br>
{% for error in form.photo.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
{% endif %}
</div>
<div class="submit_button">
<p>{{ form.submit2(type="submit", class="btn btn-primary", style="background-color:#38aaff") }}</p>
{% if message != '' %}
<div class="alert alert-danger" role="alert">{{ message }}</div>
{% endif %}
</div>
</form>
</div>
</div>
{% endblock %}

View File

@ -1,29 +0,0 @@
<link rel="stylesheet" href="../../static/css/safe_app_school/confirmation.css">
{% extends "safe_app_school/base.html" %}
{% block content %}
<div class="back">
<a href="/safeappschool/main"><p class="back_text" style="color: #ffffff">Назад</p></a>
</div>
<div class="divlog">
<h1 class="title">Подтверждение почты</h1>
<form action="" method="post">
{{ form.hidden_tag() }}
{{ form.csrf_token }}
<h3>Мы отправили секретный код вам на почту</h3>
<p>
{{ form.code_key.label }}<br>
{{ form.code_key(class="form-control") }}<br>
{% for error in form.code_key.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</p>
<p>{{ form.submit(type="submit", class="btn btn-primary") }}</p>
{% if message != '' %}
<div class="alert alert-danger" role="alert">{{ message }}</div>
{% endif %}
</form>
</div>
{% endblock %}

View File

@ -1,49 +0,0 @@
<link rel="stylesheet" href="../../static/css/safe_app_school/login.css">
{% extends "safe_app_school/base.html" %}
{% block content %}
<h1 class="header_title">Авторизация</h1>
<div class="page">
<form class="row g-2" action="" method="post">
{{ form.hidden_tag() }}
<div class="login_form">
<div>
<label class="form-label">{{ form.email.label }}</label>
{{ form.email(class="form-control", type="email") }}
{% for error in form.email.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div>
<label class="form-label">{{ form.password.label }}</label>
{{ form.password(class="form-control", type="password") }}
{% for error in form.password.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div>
<div class="box">{{ form.remember_me(class="form-check-input")}} {{ form.remember_me.label }}<br></div>
{% for error in form.remember_me.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="buttons_from">{{ form.submit(type="submit", class="btn btn-primary button") }}
<a class="btn btn-primary button" type="submit"
href="/safeappschool/register"><strong class="text_button">Регистрация</strong></a>
<a class="btn btn-primary button" type="submit" href="/recovery"><strong class="text_button">Забыли
пароль</strong></a>
</div>
{% if message != '' %}
<div class="alert alert-danger" role="alert">{{ message }}</div>
{% endif %}
</div>
</form>
<div class="apk"><a href="../../static/apk/SafeAppSchool.apk"><p class="text_apk">Скачать приложение для Android</p></a></div>
</div>
{% endblock %}

View File

@ -1,84 +0,0 @@
<link rel="stylesheet" href="../../static/css/safe_app_school/register.css">
{% extends "safe_app_school/base.html" %}
{% block content %}
<div class="back">
<a href="/safeappschool/main"><p class="back_text" style="color: #ffffff">Назад</p></a>
</div>
<div class="divlog">
<h1 class="title">Регистрация</h1>
<form class="row g-3" action="" method="POST" enctype="multipart/form-data">
{{ form.hidden_tag() }}
{{ form.csrf_token }}
<div class="col-md-6">
<label class="form-label">{{ form.name.label }}</label>
{{ form.name(class="form-control", type="text") }}
{% for error in form.name.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="col-md-6">
<label class="form-label">{{ form.surname.label }}</label>
{{ form.surname(class="form-control", type="text") }}
{% for error in form.surname.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="col-md-4">
<label class="form-label">{{ form.email.label }}</label>
{{ form.email(class="form-control", type="email") }}
{% for error in form.email.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="col-md-4">
<label class="form-label">{{ form.birthday.label }}</label>
{{ form.birthday(class="form-control", type="date") }}
{% for error in form.birthday.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="col-md-4">
<label class="form-label">{{ form.password.label }}</label>
{{ form.password(class="form-control", type="password") }}
{% for error in form.password.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="col-md-4">
<label class="form-label">{{ form.password2.label }}</label>
{{ form.password2(class="form-control", type="password") }}
{% for error in form.password2.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="col-md-6">
<label class="form-label">{{ form.login.label }}</label>
{{ form.login(class="form-control", type="text") }}
{% for error in form.login.errors %}
<div class="alert alert-danger" role="alert">
{{ error }}
</div>
{% endfor %}
</div>
<div class="but">
<p>{{ form.submit(type="submit", class="btn btn-primary", style="background-color:#38aaff") }}</p>
{% if message != '' %}
<div class="alert alert-danger" role="alert">{{ message }}</div>
{% endif %}
</div>
</form>
</div>
{% endblock %}

View File

@ -15,9 +15,7 @@ def mail(msg, to, topic='No temes'):
mailServer.ehlo()
mailServer.starttls()
mailServer.ehlo()
auth = open('../protect.moona', 'r', encoding='utf-8').read().split()
login, password = auth[0], auth[1]
mailServer.login(login, password)
mailServer.login('moonadiary', 'fiX-2Vb-6a2-kCi')
mailServer.ehlo()
mailServer.send_message(em)
mailServer.quit()

View File

Before

Width:  |  Height:  |  Size: 141 KiB

After

Width:  |  Height:  |  Size: 141 KiB

View File

Before

Width:  |  Height:  |  Size: 198 KiB

After

Width:  |  Height:  |  Size: 198 KiB

View File

Before

Width:  |  Height:  |  Size: 245 KiB

After

Width:  |  Height:  |  Size: 245 KiB

View File

Before

Width:  |  Height:  |  Size: 378 KiB

After

Width:  |  Height:  |  Size: 378 KiB

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

View File

Before

Width:  |  Height:  |  Size: 2.7 MiB

After

Width:  |  Height:  |  Size: 2.7 MiB

View File

@ -14,9 +14,4 @@ body {
margin-right: auto;
text-align: center;
margin-top: 50px;
}
.user {
background: linear-gradient(45deg, #d1c3fc, #9bc4fc);
border-radius: 19px;
border: 2px solid #ffffff;
}

View File

@ -36,12 +36,8 @@
width: 10%;
margin-left: 12px;
height: 42px;
color: #ffffff;
transition: box-shadow 1s ease-in, border 0.3s ease-in, background 2s ease-in;
}
.back:hover
{
border: 4px solid #ffffff;
box-shadow: 0px 0px 50px #fff;
background: rgb(0, 222, 0);
.back_text {
margin-top: 7%;
text-align: center;
}

View File

@ -41,12 +41,8 @@
width: 10%;
margin-left: 12px;
height: 42px;
color: #ffffff;
transition: box-shadow 1s ease-in, border 0.3s ease-in, background 2s ease-in;
}
.back:hover
{
border: 4px solid #ffffff;
box-shadow: 0px 0px 50px #fff;
background: rgb(0, 222, 0);
.back_text {
margin-top: 7%;
text-align: center;
}

View File

@ -70,9 +70,9 @@
height: 60px;
}
.user {
background: linear-gradient(45deg, #d1c3fc, #9bc4fc);
border-radius: 19px;
border: 2px solid #ffffff;
background: linear-gradient(45deg, #d1c3fc, #9bc4fc);
}
.button {
width: 160px;

View File

@ -36,12 +36,8 @@
width: 10%;
margin-left: 12px;
height: 42px;
color: #ffffff;
transition: box-shadow 1s ease-in, border 0.3s ease-in, background 2s ease-in;
}
.back:hover
{
border: 4px solid #ffffff;
box-shadow: 0px 0px 50px #fff;
background: rgb(0, 222, 0);
.back_text {
margin-top: 7%;
text-align: center;
}

View File

@ -49,12 +49,4 @@
}
.button_block {
width: 35%;
}
.apk {
width: 40%;
margin-left: 30%;
margin-right: 30%;
}
.text_apk {
text-align: center;
}

View File

@ -13,9 +13,9 @@
text-align: center;
}
.page {
width: 90%;
margin-left: 5%;
margin-right: 5%;
width: 70%;
margin-left: 15%;
margin-right: 15%;
}
.header_title {
font-size: 2.5vw;
@ -43,4 +43,7 @@
.header_button_text {
text-align: center;
color: #ffffff;
}
body {
margin-bottom: 10%;
}

View File

@ -40,7 +40,4 @@ form {
.back_text {
margin-top: 4%;
text-align: center;
}
.logout_btn {
width: 40%;
}

View File

Before

Width:  |  Height:  |  Size: 25 KiB

After

Width:  |  Height:  |  Size: 25 KiB

BIN
static/img/MoonCcircl.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 798 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 2.4 MiB

After

Width:  |  Height:  |  Size: 2.4 MiB

View File

Before

Width:  |  Height:  |  Size: 2.7 MiB

After

Width:  |  Height:  |  Size: 2.7 MiB

View File

Before

Width:  |  Height:  |  Size: 113 KiB

After

Width:  |  Height:  |  Size: 113 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 32 KiB

After

Width:  |  Height:  |  Size: 32 KiB

View File

Before

Width:  |  Height:  |  Size: 584 KiB

After

Width:  |  Height:  |  Size: 584 KiB

View File

Before

Width:  |  Height:  |  Size: 411 KiB

After

Width:  |  Height:  |  Size: 411 KiB

View File

Before

Width:  |  Height:  |  Size: 38 KiB

After

Width:  |  Height:  |  Size: 38 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 MiB

After

Width:  |  Height:  |  Size: 1.3 MiB

Some files were not shown because too many files have changed in this diff Show More