def post(self): form = QuickRegisterForm(request.form) if form.validate(): accounts = [] # Create account 1 pass1 = make_password() account1 = auth2.create_account(email=form.email1.data, password=pass1, first_name=form.first_name1.data, last_name=form.last_name1.data, fsuid=form.fsuid1.data, course_list=form.courses1.data) quick_register_email(account1.email, pass1) accounts.append(account1) # Account 2 if form.account2: pass2 = make_password() account2 = auth2.create_account( email=form.email2.data, password=pass2, first_name=form.first_name2.data, last_name=form.last_name2.data, fsuid=form.fsuid2.data, course_list=form.courses2.data) quick_register_email(account2.email, pass2) accounts.append(account2) # Account 3 if form.account3: pass3 = make_password() account3 = auth2.create_account( email=form.email3.data, password=pass3, first_name=form.first_name3.data, last_name=form.last_name3.data, fsuid=form.fsuid3.data, course_list=form.courses3.data) quick_register_email(account3.email, pass3) accounts.append(account3) # Create team first, team = True, None while len(accounts) > 0: account = accounts.pop(0) if first: team = create_team(account, form.team_name.data) set_division(team, form.division.data) first = False else: join_team(account, team=team) flash('Team created! Please check your emails for your passwords.', 'success') return redirect(url_for('login')) return self.render_template(form=form)
def leave_team(account, team): account.team = None account.save() team.members.remove(account) # Clear name if last member, change teampass if len(team.members) is 0: team.members = [] team.team_name = None team.division = None team.teamPass = make_password() team.save() success = "You have left the team." return success
def __str__(self): if self.team_name: return self.team_name else: return "" # Pre-generate teams if Team.objects.count() < app.config['TEAM_COUNT']: from app.util.password import make_password # Don't overwrite teams start = 1 + Team.objects.count() target = 1 + app.config['TEAM_COUNT'] """ Domjudge doesn't support acm-0 (0 is not a valid ID), so whenever we start generating acm-x we use +1. Hence, to reach 300 teams we must generate acm-1 through acm-301. This still does not solve the issue if a team is removed in the middle. This should be rewritten to start at the largest existing team ID. """ for i in range(start, target): teamID = "acm-%i" % i teamPass = make_password() domPass = make_password() Team(teamID=teamID, teamPass=teamPass, domPass=domPass).save()