def register(): """ Registration form """ from lib.forms.registration import RegistrationForm from lib.database import db_session form = RegistrationForm(request.form) if request.method == 'POST' and form.validate(): from models import Team team = Team(form.team_name.data, form.institution.data, form.team_members.data, md5(form.password.data).hexdigest()) db_session.add(team) # trying to add to db try: db_session.flush() except: form.team_name.errors.append(u'Команда с таким названием уже зарегистрирована.') else: # if success, generate TEAM_ID team.generate_team_id() db_session.commit() # store session session['team_id'] = team.team_id return render_template('registration_success.html', team_id = team.team_id, active_register = True) return render_template('registration.html', form = form, active_registration = True)
def insert(cls, log_id=None, issuer_name=None, email=None, phone=None, country=None, name=None, context=None, user_ontid=None, id_name=None, id_no=None): newRec = cls( log_id=log_id, issuer_name=issuer_name, email=email, phone=phone, country=country, name=name, context=context, user_ontid=user_ontid, id_name=id_name, id_no=id_no, ) db_session.add(newRec) try: db_session.commit() except: db_session.rollback() return True
def insert(cls, ont_kyc_data=None, ont_payload=None, ont_Claims_sub=None, ont_Claims_clm_IssuerName=None, ont_Claims_clm_Email=None, ont_Claims_clm_Country=None, ont_Claims_clm_PhoneNumber=None, ont_Claims_clm_DocumentType=None, ont_Claims_clm_Name=None, ont_Claims_context=None, ont_Claims_iat=None, ont_Claims_exp=None, ont_OntPassOntId=None, ont_UserOntId=None, ont_Signature=None, ont_Claims=None, ): newOKL = OntKycLog( ont_kyc_data=ont_kyc_data, ont_payload=ont_payload, ont_Claims_sub=ont_Claims_sub, ont_Claims_clm_IssuerName=ont_Claims_clm_IssuerName, ont_Claims_clm_Email=ont_Claims_clm_Email, ont_Claims_clm_Country=ont_Claims_clm_Country, ont_Claims_clm_PhoneNumber=ont_Claims_clm_PhoneNumber, ont_Claims_clm_DocumentType=ont_Claims_clm_DocumentType, ont_Claims_clm_Name=ont_Claims_clm_Name, ont_Claims_context=ont_Claims_context, ont_Claims_iat=ont_Claims_iat, ont_Claims_exp=ont_Claims_exp, ont_OntPassOntId=ont_OntPassOntId, ont_UserOntId=ont_UserOntId, ont_Signature=ont_Signature, ont_Claims=ont_Claims, ) db_session.add(newOKL) try: db_session.commit() except: db_session.rollback() if newOKL.id: return cls.find_one(newOKL.id) return None
def submit(): """ Action for solution submit """ if request.method == 'POST': from models import Solution from lib.database import db_session file = request.files['file'] if not file: return redirect(request.referrer) lang_id = get_lang_id(file.filename) if lang_id: # Create solution in database team_id = session['team_id'] problem_id = request.form['problem_id'] solution = Solution(problem_id, team_id, lang_id) db_session.add(solution) db_session.commit() # Store solution file path = solution.get_solution_path() solution_file = solution.get_solution_file() if not os.path.exists(path): os.makedirs(path) file.save(solution_file) tester_module = import_module('lib.testers.{tester_name}'.format(tester_name = solution.language.tester_name)) tester = tester_module.Tester(solution, tester_semaphore) tester.start() else: flash(u'Неверное расширение файла!', 'alert-error') return redirect(request.referrer) return redirect(url_for('status'))