def seed_awards(): new_user_award = Award(title="New User Award", badge_url="http://www.fillmurray.com/200/300", description="Thanks for being a new user!", point_value=15) db.session.add(new_user_award) db.session.commit()
def create_award(award_id): award = Award(award_id=award_id, pi_name='test', contact='test', pi_email='test', organization='test', program='test', title='test', abstract='test') db.session.add(award) db.session.commit() return award
def add_award(): if current_user.username != Config.ADMIN_USER: return redirect(url_for('main.awards')) form=AddAwardForm() if form.validate_on_submit(): award = Award(url=form.url.data, name=form.name.data, agency=form.agency.data, expiration_date=form.expiration_date.data, license_number=form.license_number.data, start_date=form.start_date.data, end_date=form.end_date.data) db.session.add(award) db.session.commit() flash(_('Congratulations, award added!')) return redirect(url_for('main.awards')) return render_template('add_award.html', form=form)
def add_random_user(id): user = User(id=id, nickname=generate(), description="Team Devian", steam=generate(), discord=generate(), twitch=generate()) s1 = Skill(title="Координатор", count=3, user=user) s2 = Skill(title="Лидер", count=2, user=user) g1 = Game(game_id=randint(0, 9), user=user) a1 = Award(title="Ez Game", imgSrc="https://www.ezride.be/wp-content/uploads/2017/11/cropped-Logo_EZRide_yellow_circle.png", user=user) db.session.add(user) db.session.add(s1) db.session.add(s2) db.session.add(g1) db.session.add(a1) db.session.commit() return user
def add_winner(sub_name, project_name): winning_sub = Award(username=sub_name, award_name=project_name) db.session.add(winning_sub) db.session.commit() return sub_name
Session = sessionmaker(bind=engine) session = Session() Base.metadata.create_all(bind=engine) try: with open(FILENAME, 'r', encoding='UTF-8') as csvfile: reader = csv.DictReader(csvfile, FIELDNAMES) for i, row in enumerate(reader): record = Award( **{ 'pi_name': row['pi_name'], 'contact': row['contact'], 'pi_email': row['pi_email'], 'organization': row['organization'], 'program': row['program'], 'title': row['title'], 'abstract': row['abstract'], 'award_id': row['award_number'] }) session.add(record) if i % 1000 == 0: session.flush() print('*flush*') session.commit() print('we did it') except Exception as e: session.rollback() print(e) finally: