-
Notifications
You must be signed in to change notification settings - Fork 0
/
manage.py
executable file
·56 lines (45 loc) · 1.77 KB
/
manage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import coverage
import os
import forgery_py as faker
from flask_script import Manager
from flask_migrate import Migrate, MigrateCommand
from app import app, db, models, app_sheduler
from app.models import User, Activity
from app.ground.helper import update_grounds_dataset
from sqlalchemy.exc import IntegrityError
from datetime import datetime
# Initializing the manager
manager = Manager(app)
# Initialize Flask Migrate
migrate = Migrate(app, db)
# Add the flask migrate
manager.add_command('db', MigrateCommand)
@manager.command
def load_grounds():
update_grounds_dataset()
@manager.command
def dummy():
# Create a user if they do not exist.
user1 = User.query.filter_by(email="user1@test.com").first()
if not user1:
user1 = User("user1@test.com", "password", "Александр", "Пономарев", datetime(1997, 4, 30))
user1.save()
user2 = User.query.filter_by(email="user2@test.com").first()
if not user2:
user2 = User("user2@test.com", "password", "Николай", "Курчатов", datetime(1997, 4, 15))
user2.save()
user3 = User.query.filter_by(email="user3@test.com").first()
if not user3:
user3 = User("user3@test.com", "password", "Матвей", "Кравцов", datetime(1997, 7, 6))
user3.save()
user4 = User.query.filter_by(email="user4@test.com").first()
if not user4:
user4 = User("user4@test.com", "password", "Дмитрий", "Жаров", datetime(1996, 12, 15))
user4.save()
user5 = User.query.filter_by(email="user5@test.com").first()
if not user5:
user5 = User("user5@test.com", "password", "Андрей", "Шумилкин", datetime(1997, 9, 13))
user5.save()
# Run the manager
if __name__ == '__main__':
manager.run()