def login_success_redirect(sim_type): if sim_type: if cookie.get_value(_COOKIE_STATE) == _STATE_COMPLETE_REGISTRATION: return http_reply.gen_redirect_for_local_route( sim_type, 'completeRegistration', ) return http_reply.gen_redirect_for_root(sim_type)
def api_findByName(simulation_type, application_mode, simulation_name): req = http_request.parse_params(type=simulation_type) return http_reply.gen_redirect_for_local_route( req.type, 'findByName', PKDict( applicationMode=application_mode, simulationName=simulation_name, ), )
def api_importArchive(): """ Params: data: what to import """ import sirepo.importer data = sirepo.importer.do_form(flask.request.form) return http_reply.gen_redirect_for_local_route( data.simulationType, route=None, params={'simulationId': data.models.simulation.simulationId}, )
def api_importArchive(): """ Params: data: what to import """ import sirepo.importer # special http_request parsing here data = sirepo.importer.do_form(flask.request.form) m = simulation_db.get_schema(data.simulationType).appModes.default return http_reply.gen_redirect_for_local_route( data.simulationType, m.localRoute, PKDict(simulationId=data.models.simulation.simulationId), )
def login_fail_redirect(sim_type=None, module=None, reason=None): if sim_type: return http_reply.gen_redirect_for_local_route( sim_type, 'loginFail', { 'method': module.AUTH_METHOD, 'reason': reason, }, ) util.raise_unauthorized( 'login failed (no sym_type): reason={} method={}'.format( reason, module.AUTH_METHOD, ), )
def api_findByNameWithAuth(simulation_type, application_mode, simulation_name): req = http_request.parse_params(type=simulation_type) #TODO(pjm): need to unquote when redirecting from saved cookie redirect? if hasattr(urllib, 'unquote'): # python2 simulation_name = urllib.unquote(simulation_name) else: # python3 simulation_name = urllib.parse.unquote(simulation_name) # use the existing named simulation, or copy it from the examples rows = simulation_db.iterate_simulation_datafiles( req.type, simulation_db.process_simulation_list, { 'simulation.name': simulation_name, 'simulation.isExample': True, }, ) if len(rows) == 0: for s in simulation_db.examples(req.type): if s['models']['simulation']['name'] != simulation_name: continue simulation_db.save_new_example(s) rows = simulation_db.iterate_simulation_datafiles( req.type, simulation_db.process_simulation_list, { 'simulation.name': simulation_name, }, ) break else: sirepo.util.raise_not_found( 'simulation not found by name={} type={}', simulation_name, req.type, ) m = simulation_db.get_schema(req.type).appModes[application_mode] return http_reply.gen_redirect_for_local_route( req.type, m.localRoute, PKDict(simulationId=rows[0].simulationId), query=m.includeMode and PKDict(application_mode=application_mode), )