def push_to_mautic(): from models import User, College with app.app_context(): users = (User.query .outerjoin(User.college) .options(contains_eager( User.college ).load_only(College.college_name)) .options(load_only(User.email, User.full_name, User.phone_no, User.is_active, User.created_date )) .all()) for user in tqdm(users): college = user.college.college_name if user.college is not None else None mautic.API.contacts.create_contact(firstname=user.full_name, lastname=None, email=user.email, phone=user.phone_no, is_active=user.is_active, join_date=user.created_date, college_name=college)
def create_link(): if not current_user.is_authenticated: return redirect(url_for('index')) form = LinkForm() if form.validate_on_submit(): email = form.email.data user = User.query.filter_by(email=email).first() if user is None: user = User(email=email) user.set_token(email) db.session.add(user) db.session.commit() text_msg = f""" Login requested for email {user.email}, unique link is {request.url_root}login/{user.token} """ flash(text_msg) try: with app.app_context(): msg = Message( subject="Magic link !!!", sender=app.config.get("MAIL_USERNAME"), recipients=[email], body=text_msg ) mail.send(msg) except Exception as e: print(e) return redirect(url_for('links')) return render_template('create_link.html', title='Create link', form=form)
def setUp(self): app = create_app('testing') # http://flask-sqlalchemy.pocoo.org/2.3/contexts/ self.context = app.app_context() self.context.push() db.create_all() self.runner = app.test_cli_runner() self.client = app.test_client()
def create_tags(): from wsgi import app with app.app_context(): tags = ('flask', 'django', 'python', 'gb') for tag in tags: db.session.add(Tag(name=tag)) db.session.commit() print('create tags!')
def setUp(self): app.config['TESTING'] = True app.config['WTF_CSRF_ENABLED'] = False app.config['DEBUB'] = True self.app = app.test_client() self.app_context = app.app_context() self.app_context.push() db.create_all()
def get_hashed_passwords(input_csv, output_csv): """ Get hashes for a csv of plaintext passwords. :param input_csv: :param output_csv: :return: """ with app.app_context(): get_hashed_passes_csv(input_csv, output_csv)
def migrate_to_allow_jumps(): """ """ with app.app_context(): for test in tqdm(Test.query.all()): if test.type == "CAT": test.allow_section_jumps = False else: test.allow_section_jumps = True db.session.commit()
def send_msg(rid): with app.app_context(): # print(User.query.all()) token_url = 'https://api.weixin.qq.com/cgi-bin/token' token = store.get('access_token') if token: token = token.decode(encoding='utf-8') if not token: appid = app.config.get('APPID') secret = app.config.get('SECRET') res = requests.get(token_url, params={ "grant_type": "client_credential", "appid": appid, "secret": secret }) data = json.loads(res.text) print(res.text) try: token = data['access_token'] store.set("access_token", token, 60 * 60 * 2) except: return # print('to') print('send template message to ' + u.name + datetime.datetime.now().strftime('%Y-%m-%d %H:%M')) r = Reservation.query.filter_by(id=rid).first() u = User.query.filter_by(id=r.user_id).first() bu = User.query.filter_by(id=r.bt_user_id).first() url = 'https://api.weixin.qq.com/cgi-bin/message/wxopen/template/send?access_token=%s' url = url % token res = requests.post(url, json={ "touser": u.openid, "template_id": "TkqGXhUoHMNbfIxjjTsDg3lSkoiGr4hQj_-eVyiAIeM", "form_id": r.formid, "data": { "keyword1": { "value": str(r.id) }, "keyword2": { "value": bu.name }, "keyword3": { "value": bu.phone }, "keyword4": { "value": 'QQ:' + bu.qq } } })
def create_users(): from wsgi import app with app.app_context(): admin = User(username='******', email='*****@*****.**', password=generate_password_hash('123'), is_staff=True) james = User(username='******', email='*****@*****.**', password=generate_password_hash('12345')) db.session.add(admin) db.session.add(james) db.session.commit() print('create users!')
def create_articles(): from wsgi import app with app.app_context(): article_1 = Article(title='some title #1', text='some text #1', author_id=1) article_2 = Article(title='some title #2', text='some text #2', author_id=2) db.session.add(article_1) db.session.add(article_2) db.session.commit() print('create articles!')
def send_email(rid): with app.app_context(): r = Reservation.query.filter_by(id=rid).first() if r.formid == 'send': return # print(r) u = User.query.filter_by(id=r.user_id).first() bu = User.query.filter_by(id=r.bt_user_id).first() # print(u) mail_host = app.config.get('MAIL_HOST') mail_user = app.config.get('MAIL_USER') mail_pass = app.config.get('MAIL_PASS') to_addr = u.qq + "@qq.com" from_addr = mail_user # from_addr = mail_user content = '''%s: 您好! 您的订单(订单号:%s, 维修状态: 维修%s)已经完成,请您对队员%s的服务做出评价。 奔腾服务,竭诚为您! 奔腾服务队 ''' % (u.name, r.id, '成功' if r.solved else '失败', bu.name) h_from = '奔腾服务队<*****@*****.**>' h_to = u.name + '<*****@*****.**>' % u.qq msg = MIMEText(content, 'plain', 'utf-8') msg['From'] = Header(h_from, 'utf-8') msg['To'] = Header(h_to, 'utf-8') subject = '华中师范大学奔腾服务队维修反馈' msg['Subject'] = Header(subject, 'utf-8') try: smtp = smtplib.SMTP_SSL(mail_host) smtp.login(mail_user, mail_pass) # print('login') smtp.sendmail(from_addr, to_addr, msg.as_string()) print('success to send email to ' + h_to) except: print('fail to send email to ' + h_to) r.formid = 'send' try: db.session.add(r) db.session.commit() except: db.session.rollback()
def scheduler_task(): with app.app_context(): print("scheduler_task: " + datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')) date = datetime.datetime.now() - datetime.timedelta(days=2) rs = Reservation.query.\ filter(and_(Reservation.formid == 'send', Reservation.finish_time <= date, Reservation.status >= 4, Reservation.status < 6)).all() for r in rs: r.status = 6 r.score = 5 r.evaluation = '系统自动好评' try: db.session.add(r) db.session.commit() print('自动好评 rid=' + str(r.id)) except: db.session.rollback() rs = Reservation.query.\ filter(and_(Reservation.formid != 'send', Reservation.status >= 4, Reservation.status < 6)).all() # print(rs) for r in rs: send_email(r.id) # 自动分配订单 date = datetime.datetime.now() - datetime.timedelta(hours=2) rs = Reservation.query.\ filter(and_(Reservation.status == 1, Reservation.create_time <= date)).all() bt = User.query.\ filter(User.role == 1).all() for r in rs: b = bt[random.randint(0, len(bt) - 1)] r.status = 2 r.bt_user_id = b.id db.session.add(r) db.session.commit() print("分配订单%d 给 %s" % (r.id, b.name))
def run_celery_beat(): """Start the celery beat""" celery_args = ['celery', 'beat', '--pidfile', '/tmp/beat.pid'] with app.app_context(): celery_main(celery_args)
def setup(): log.info("Initializing Application") with app.app_context(): log.info("Seeding In-Memory Test Database") app.seed()
def setUp(self): self.app = app.test_client() app.app_context().push() user = User(email="*****@*****.**") db.session.add(user) db.session.flush()
def persist_section_scores(): """ """ with app.app_context(): persist_section_scores_command()
def create_app(): from app.config import Config, ConfigDB app.config.from_object(Config) app.config.from_object(ConfigDB) CORS(app) db.init_app(app) ma.init_app(app) configure_uploads(app, files) patch_request_class(app) # set maximum file size, default is 16MB excel.init_excel(app) with app.app_context(): from app.models import IndustryArea, EmailStatus, UserRole, User, EmployeeCompany, Employee, \ Company, CompanyEmailStat, AlumnusEmailStat db.create_all() # create tables in database if not UserRole.UserRole.get_all(): # initialise default super admin role, dev advices to assign the role id to a user first before login into the system new = UserRole.UserRole( user_role_description="SuperAdmin", user_role_json=json.loads( '{"roles":"full","areas":"full","users":"full","companies":"full","employees":"full","reports":"full","conversations":"full"}' )) new.save() if not IndustryArea.IndustryArea.get_all(): # initialise default super admin role, dev advices to assign the role id to a user first before login into the system new = IndustryArea.IndustryArea( industry_name="All", industry_desc= "This default area is for user that can manage all company, which separated from admin role.", is_read_only=True) new.save() if not EmailStatus.EmailStatus.get_all(): # initialise default super admin role, dev advices to assign the role id to a user first before login into the system new = EmailStatus.EmailStatus('Lead-Opened', 'New lead') new.save() new = EmailStatus.EmailStatus('Lead-Processing', 'Discussion undergoing on') new.save() new = EmailStatus.EmailStatus('Lead-Closed', 'Closed case on the lead') new.save() new = EmailStatus.EmailStatus('Opportunity-Opened', 'New opportunity') new.save() new = EmailStatus.EmailStatus('Opportunity-Processing', 'Discussion undergoing on') new.save() new = EmailStatus.EmailStatus('Opportunity-Closed', 'Closed case on the opportunity') new.save() migrate = Migrate( app, db, compare_type=True ) # provide Flask Migrate command ability, set column type to detect in migrate files_path = Config.UPLOADS_DEFAULT_DEST + 'files/' template_path = files_path + "company_template.csv" if not os.path.exists(files_path): os.makedirs(files_path) if not os.path.exists(template_path): with open(Config.UPLOADS_DEFAULT_DEST + 'files/company_template.csv', mode='w') as csv_file: fieldnames = [ 'company_reg_num', 'company_name', 'company_size', 'company_industry_id', 'company_desc', 'company_address', 'company_postcode', 'company_city', 'company_state', 'company_country', 'company_office_contact_num' ] writer = csv.DictWriter(csv_file, fieldnames=fieldnames) writer.writeheader() from app.modules.LoginModule import routes as login_route app.register_blueprint(login_route.login_bp) from app.modules.UserModule import routes as user_route app.register_blueprint(user_route.user_bp) from app.modules.UserRoleModule import routes as role_route app.register_blueprint(role_route.user_role_bp) from app.modules.IndustryAreaModule import routes as area_route app.register_blueprint(area_route.industry_area_bp) from app.modules.CompanyModule import routes as comp_route app.register_blueprint(comp_route.company_bp) from app.modules.EmployeeModule import routes as emp_route app.register_blueprint(emp_route.employee_bp) from app.modules.EmailStatModule import routes as email_route app.register_blueprint(email_route.email_bp) from app.modules.DashboardModule import routes as home_route app.register_blueprint(home_route.home_bp) from app.services.AuthMiddleware import AuthMiddleware app.wsgi_app = AuthMiddleware(app.wsgi_app)
def init_db(): from wsgi import app with app.app_context(): db.create_all() print('init_db! done!')
def migrate_sections(): """ """ with app.app_context(): migrate_sections_to_many_to_many_command()
def run_celery_worker(): """Start the celery Worker""" celery_args = ['celery', 'worker'] with app.app_context(): celery_main(celery_args)
import sys from api.models import db, base_models if __name__ == '__main__': from wsgi import app with app.app_context(): interactive = sys.argv[-1] != '--auto' db.database.evolve(ignore_tables=base_models, interactive=interactive)
def migrate_question_attempt_was_correct(): """ """ with app.app_context(): migrate_question_attempt_was_correct_command()
from wsgi import app # push app context shell = app.app_context() shell.push()
def seed_demo(): with app.app_context(): # Password = password db.drop_all() db.create_all() a1 = Authentication( username="******", password= "******") a2 = Authentication( username="******", password= "******") u1 = User(first_name="Melissa", last_name="McDaniel", email="*****@*****.**", username="******", public=True) u2 = User(first_name="Richard", last_name="Greenway", email="*****@*****.**", username="******", public=True) db.session.add_all([a1, a2]) db.session.commit() db.session.add_all([u1, u2]) db.session.commit() p1 = Persona(title_en="Runner", description_public= "An athlete with strong cardio ability in running.") p2 = Persona( title_en="Painter", description_public= "An artist who creates physical art with paint and complementary medias." ) p3 = Persona( title_en="Software Engineer", description_public= "An engineer specialized in the design, development and maintenance of software." ) p4 = Persona( title_en="Olympian", description_public= "An athlete at the top of their physical and mental state representing their nation in global competition." ) p5 = Persona( title_en="Rock Star", description_public= "An musician with a notable following who writes and performs music identified as the rock genre." ) # User 1 & User 2 h1 = Habit( title_en="Stretch", description_public= "An activity to increase physical mobility and encourage recovery." ) # User 1 h2 = Habit(title_en="Run", description_public= "The activity of running / propelling yourself by foot.") # User 1 & User 2 h3 = Habit( title_en="Healthy Diet", description_public="Follow a diet which encourages physical health." ) # User 1 & User 2 h4 = Habit( title_en="Sketch", description_public= "Catalogue & experiment in artistic design through rough sketching." ) # User 1 & User 2 h5 = Habit(title_en="Paint", description_public="Create physical art utilizing.") # User 2 h6 = Habit( title_en="Code", description_public= "Write code to create projects and/or practice new concepts.") # User 2 h7 = Habit(title_en="Curl", description_public="Engage in the fine sport of curling.") # User 1 h8 = Habit( title_en="Sing", description_public= "Seranade audiences, loved ones, or your wall with your lovely voice." ) # User 1 g1 = Goal(title_en="Run 25kms in a single session", description_public="Half marathon preparation") # User 1 g2 = Goal(title_en="Run 50kms in a single session", description_public="Full marathon preparation.") # User 1 g3 = Goal(title_en="Sketch The Thinker from online images", description_public="Practice human biology in sketch.") # User 2 g4 = Goal( title_en="Paint an image of a Lily", description_public="Create first full color image of a flower.") # User 2 g5 = Goal(title_en="Finish Capstone 1 Project", description_public= "Complete first full-stack project for programming course.") # User 2 g6 = Goal( title_en="Hit the Button 10 times in a row", description_public= "Land stone in the center of the scoring area 10 times in a row in practice." ) # User 1 g7 = Goal( title_en="Complete lyrics for first song", description_public="Finish writing lyrics for first song release.") # User 1 g8 = Goal( title_en="Master the guitar lick for recording", description_public= "Practice the guitar line for first song in preparation for recording." ) db.session.add_all([ p1, p2, p3, p4, p5, h1, h2, h3, h4, h5, h6, h7, h8, g1, g2, g3, g4, g5, g6, g7, g8 ]) db.session.commit() score1 = Scoring_System(user_id=u1.id, title_en="US Grading System", description="US Grading System", public=False) score2 = Scoring_System( user_id=u1.id, title_en="All or Nothing Scoring System 30mins", description="Only credit if time spent is greater than 30mins", public=False) score3 = Scoring_System( user_id=u2.id, title_en="Back Loaded Scoring System", description="Progressively higher scores given for more time spent", public=False) score4 = Scoring_System( user_id=u2.id, title_en="Motivational Message Scoring System", description="Scores are accopanied by motivational messages.", public=False) sched1 = Reminder_Schedule(user_id=u1.id, title_en="User1 Schedule 1", description="User1 Schedule Description", public=True, global_time="1900-01-01 20:00:00-06", monday=True, tuesday=True, wednesday=True, thursday=True, friday=True, saturday=False, sunday=False) sched2 = Reminder_Schedule(user_id=u1.id, title_en="User2 Schedule 2", description="User2 Schedule Description", public=False, global_time="1900-01-01 20:00:00-06", monday=True, tuesday=True, wednesday=True, thursday=True, friday=True, saturday=False, sunday=False) db.session.add_all([score1, score2, score3, score4, sched1, sched2]) db.session.commit() score1_param_1 = Scoring_System_Params(scoring_system_id=score1.id, score_bp=0, score_input=0, score_output=0, name_en="F") score1_param_2 = Scoring_System_Params(scoring_system_id=score1.id, score_bp=1, score_input=59, score_output=0, name_en="F") score1_param_3 = Scoring_System_Params(scoring_system_id=score1.id, score_bp=2, score_input=69, score_output=1, name_en="D") score1_param_4 = Scoring_System_Params(scoring_system_id=score1.id, score_bp=3, score_input=79, score_output=2, name_en="C") score1_param_5 = Scoring_System_Params(scoring_system_id=score1.id, score_bp=4, score_input=89, score_output=3, name_en="B") score1_param_6 = Scoring_System_Params(scoring_system_id=score1.id, score_bp=5, score_input=100, score_output=4, name_en="A") score2_param_1 = Scoring_System_Params(scoring_system_id=score2.id, score_bp=0, score_input=0, score_output=0, name_en=None) score2_param_2 = Scoring_System_Params(scoring_system_id=score2.id, score_bp=1, score_input=29, score_output=0, name_en=None) score2_param_3 = Scoring_System_Params(scoring_system_id=score2.id, score_bp=2, score_input=30, score_output=5, name_en=None) score3_param_1 = Scoring_System_Params(scoring_system_id=score3.id, score_bp=0, score_input=0, score_output=0, name_en=None) score3_param_2 = Scoring_System_Params(scoring_system_id=score3.id, score_bp=1, score_input=10, score_output=1, name_en=None) score3_param_3 = Scoring_System_Params(scoring_system_id=score3.id, score_bp=2, score_input=30, score_output=5, name_en=None) score3_param_4 = Scoring_System_Params(scoring_system_id=score3.id, score_bp=3, score_input=45, score_output=10, name_en=None) score3_param_5 = Scoring_System_Params(scoring_system_id=score3.id, score_bp=4, score_input=55, score_output=15, name_en=None) score3_param_6 = Scoring_System_Params(scoring_system_id=score3.id, score_bp=5, score_input=60, score_output=20, name_en=None) score4_param_1 = Scoring_System_Params( scoring_system_id=score4.id, score_bp=0, score_input=0, score_output=0, name_en="You can do better then that!") score4_param_2 = Scoring_System_Params(scoring_system_id=score4.id, score_bp=1, score_input=30, score_output=50, name_en="Just a little more!") score4_param_3 = Scoring_System_Params(scoring_system_id=score4.id, score_bp=2, score_input=60, score_output=100, name_en="Target Achieved!") score4_param_4 = Scoring_System_Params(scoring_system_id=score4.id, score_bp=3, score_input=72, score_output=120, name_en="A true champion!") db.session.add_all([ score1_param_1, score1_param_2, score1_param_3, score1_param_4, score1_param_5, score1_param_6, score2_param_1, score2_param_2, score2_param_3, score3_param_1, score3_param_2, score3_param_3, score3_param_4, score3_param_5, score3_param_6, score4_param_1, score4_param_2, score4_param_3, score4_param_4 ]) db.session.commit() u1_p1 = User_Persona(active=True, user_id=u1.id, persona_id=p1.id, description_private=None) u1_p2 = User_Persona(active=True, user_id=u1.id, persona_id=p2.id, description_private=None) u1_p5 = User_Persona( active=True, user_id=u1.id, persona_id=p5.id, description_private= "I'll be the best rockstar in the world, like Queen meets Slipknot." ) u2_p2 = User_Persona( active=True, user_id=u2.id, persona_id=p2.id, description_private= "A new hobby to relax to, who doesn't like happy clouds?") u2_p3 = User_Persona(active=True, user_id=u2.id, persona_id=p3.id, description_private= "I've always wanted to create the next Facebook.") u2_p4 = User_Persona(active=True, user_id=u2.id, persona_id=p4.id, description_private=None) db.session.add_all([u1_p1, u1_p2, u1_p5, u2_p2, u2_p3, u2_p4]) db.session.commit() # User 1 Goals # Goal run 25kms u1_g1 = User_Goal(active=True, user_id=u1.id, user_persona_id=u1_p1.id, scoring_system_id=score1.id, schedule_id=sched1.id, goal_id=g1.id, description_private=None) # Goal run 50kms u1_g2 = User_Goal(active=True, user_id=u1.id, user_persona_id=u1_p1.id, scoring_system_id=score1.id, schedule_id=sched1.id, goal_id=g2.id, description_private=None) # Sketch the Thinker u1_g3 = User_Goal(active=True, user_id=u1.id, user_persona_id=u1_p2.id, scoring_system_id=score2.id, schedule_id=sched1.id, goal_id=g3.id, description_private=None) # Write song lyrics u1_g4 = User_Goal( active=True, user_id=u1.id, user_persona_id=u1_p5.id, scoring_system_id=score2.id, schedule_id=sched1.id, goal_id=g7.id, description_private="Gritty & politically charged or a party song?" ) # Master Guitar u1_g5 = User_Goal(active=True, user_id=u1.id, user_persona_id=u1_p5.id, scoring_system_id=score2.id, schedule_id=sched1.id, goal_id=g8.id, description_private= "I will seranade the gods with my guitar mastery") # User 2 Goals # Paint a Lily u2_g1 = User_Goal(active=True, user_id=u2.id, user_persona_id=u2_p2.id, scoring_system_id=score3.id, schedule_id=sched1.id, goal_id=g4.id, description_private=None) # Finish Capstone u2_g2 = User_Goal( active=True, user_id=u2.id, user_persona_id=u2_p3.id, scoring_system_id=score4.id, schedule_id=sched2.id, goal_id=g5.id, description_private= "This website will change the world! Well maybe not, but its a start." ) # Curling bullseye u2_g3 = User_Goal(active=True, user_id=u2.id, user_persona_id=u2_p4.id, scoring_system_id=score3.id, schedule_id=sched2.id, goal_id=g6.id, description_private=None) db.session.add_all( [u1_g1, u1_g2, u1_g3, u1_g4, u1_g5, u2_g1, u2_g2, u2_g3]) db.session.commit() # user 1 Habits # Stretch u1_h1 = User_Habit(active=True, user_id=u1.id, user_persona_id=u1_p1.id, scoring_system_id=score1.id, schedule_id=sched1.id, habit_id=h1.id, linked_goal_id=None, description_private= "I've had alot of shin splint problems in the past") # Run u1_h2 = User_Habit(active=True, user_id=u1.id, user_persona_id=u1_p1.id, scoring_system_id=score1.id, schedule_id=sched1.id, habit_id=h2.id, linked_goal_id=None, description_private=None) # Healthy Diet u1_h3 = User_Habit(active=True, user_id=u1.id, user_persona_id=u1_p1.id, scoring_system_id=score1.id, schedule_id=sched1.id, habit_id=h3.id, linked_goal_id=None, description_private="No more Twinkies!") # Sketch u1_h4 = User_Habit(active=True, user_id=u1.id, user_persona_id=u1_p2.id, scoring_system_id=score2.id, schedule_id=sched1.id, habit_id=h4.id, linked_goal_id=None, description_private=None) # Paint u1_h5 = User_Habit(active=True, user_id=u1.id, user_persona_id=u1_p2.id, scoring_system_id=score2.id, schedule_id=sched1.id, habit_id=h5.id, linked_goal_id=None, description_private=None) # Sing u1_h6 = User_Habit(active=True, user_id=u1.id, user_persona_id=u1_p5.id, scoring_system_id=score2.id, schedule_id=sched1.id, habit_id=h8.id, linked_goal_id=None, description_private="Screaming needs some work") # User 2 Habits # Stretch u2_h1 = User_Habit( active=True, user_id=u2.id, user_persona_id=u2_p4.id, scoring_system_id=score3.id, schedule_id=sched1.id, habit_id=h1.id, linked_goal_id=None, description_private= "Need to make sure my hips are loose for letting that stone go") # Healthy Diet u2_h2 = User_Habit(active=True, user_id=u2.id, user_persona_id=u2_p4.id, scoring_system_id=score3.id, schedule_id=sched1.id, habit_id=h3.id, linked_goal_id=None, description_private=None) # Sketch u2_h3 = User_Habit(active=True, user_id=u2.id, user_persona_id=u2_p2.id, scoring_system_id=score4.id, schedule_id=sched1.id, habit_id=h4.id, linked_goal_id=None, description_private=None) # Paint u2_h4 = User_Habit(active=True, user_id=u2.id, user_persona_id=u2_p2.id, scoring_system_id=score4.id, schedule_id=sched1.id, habit_id=h5.id, linked_goal_id=None, description_private=None) # Code u2_h5 = User_Habit(active=True, user_id=u2.id, user_persona_id=u2_p3.id, scoring_system_id=score3.id, schedule_id=sched1.id, habit_id=h6.id, linked_goal_id=None, description_private=None) # Code u2_h6 = User_Habit(active=True, user_id=u2.id, user_persona_id=u2_p4.id, scoring_system_id=score3.id, schedule_id=sched1.id, habit_id=h7.id, linked_goal_id=None, description_private=None) db.session.add_all([ u1_h1, u1_h2, u1_h3, u1_h4, u1_h5, u1_h6, u2_h1, u2_h2, u2_h3, u2_h4, u2_h5, u2_h6 ]) db.session.commit() generateUserGoalScores(30, u1_g1.id, 0, 100) generateUserGoalScores(20, u1_g2.id, 0, 100) generateUserGoalScores(30, u1_g3.id, 0, 100) generateUserGoalScores(25, u1_g4.id, 0, 100) generateUserGoalScores(15, u1_g5.id, 0, 100) generateUserGoalScores(25, u2_g1.id, 0, 100) generateUserGoalScores(15, u2_g2.id, 0, 100) generateUserGoalScores(30, u2_g3.id, 0, 100) generateUserHabitScores(30, u1_h1.id, 0, 100) generateUserHabitScores(30, u1_h2.id, 0, 100) generateUserHabitScores(20, u1_h3.id, 0, 100) generateUserHabitScores(30, u1_h4.id, 0, 100) generateUserHabitScores(25, u1_h5.id, 0, 100) generateUserHabitScores(30, u1_h6.id, 0, 100) generateUserHabitScores(30, u2_h1.id, 0, 100) generateUserHabitScores(30, u2_h2.id, 0, 100) generateUserHabitScores(15, u2_h3.id, 0, 100) generateUserHabitScores(10, u2_h4.id, 0, 100) generateUserHabitScores(20, u2_h5.id, 0, 100) generateUserHabitScores(30, u2_h6.id, 0, 100)
def __call__(self, *args, **kwargs): with app.app_context(): return self.run(*args, **kwargs)
def get_hash_for_pass(password): with app.app_context(): password = bcrypt.generate_password_hash(password).decode() print(password)