def _update_current_user_by_form() -> None: # Flags for update to_be_updated_user = current_user.first_name != request.form.get( 'first_name') or current_user.last_name != request.form.get( 'last_name') to_be_updated_tenant = current_user.tenant.name != request.form.get( 'tenant_name') if to_be_updated_user or to_be_updated_tenant: # Update UM current_user.first_name = request.form.get('first_name') current_user.last_name = request.form.get('last_name') current_user.tenant.name = request.form.get('tenant_name') current_user.save() # Update Camunda session = requests.session() login(session) if to_be_updated_user: UserApi.update(session, current_user) if to_be_updated_tenant: tenant_name = TenantApi.get_one( session, current_user.tenant).json().get('name') if tenant_name is None: TenantApi.create(session, current_user.tenant) session.close()
def api_station(): name = request.args.get('name') if name is None: ret_object = [] query = "CALL spatial.closest('spati', {latitude: {lat}, longitude: {lon}}, {dist}) YIELD node AS result SET " \ "result.nearby=result.nearby+1 RETURN result.name AS name, result.latitude AS latitude, " \ "result.longitude AS longitude, result.short AS shortn " try: latitude = float(request.args.get('lat')) longitude = float(request.args.get('lon')) distance = request.args.get('dist') if distance is None: distance = 0.005 else: distance = float(distance) stations = neo_db.cypher_query(query=query, params={'lat': latitude, 'lon': longitude, 'dist': distance}) stations = stations[0] for station in stations: nearby_stations = { 'name': station[0], 'latitude': station[1], 'longitude': station[2], 'shortn': station[3] } ret_object.append(nearby_stations) return jsonify(ret_object) except Exception as e: print(type(e)) return jsonify({'message': str(e)}), 500 else: current_user.stats.searched += 1 current_user.save() try: stations = Station.nodes.filter(name__istartswith=name) ret_object = [] for station in stations: found = { 'shortn': station.short, 'name': station.name, 'latitude': station.latitude, 'longitude': station.longitude } ret_object.append(found) return jsonify(ret_object) except Exception as e: print(type(e)) return jsonify({'message': str(e)}), 500
def api_station_directions(): from_name = request.args.get('from') to_name = request.args.get('to') from_station = Station.nodes.filter(short__iexact=from_name)[0] to_station = Station.nodes.filter(short__iexact=to_name)[0] current_user.stats.directed += 1 current_user.save() result = utils.get_directions(from_station, to_station) return jsonify(result)
def main(): import random import string if current_user.secret_key is None: N = 24 symbols = string.ascii_lowercase + string.ascii_uppercase + string.digits current_user.secret_key = "".join( random.SystemRandom().choice(symbols) for _ in range(N) ) current_user.save() return template("integrations/main.html.j2")
def set_article_summary(user_id): if not is_same_user(user_id): abort(403) summary_type = request.args.get("summary_type", "") summary_on_req = request.args.get("summary_on") if summary_on_req not in ["True", "true", "False", "false"]: flash("Summary On must be True or False", ALERT.ERROR) return redirect(url_for("users.user_settings")) if summary_on_req.lower() == "true": summary_on = True else: summary_on = False if summary_type == "Web": current_user.article_summary = summary_on elif summary_type == "Email": current_user.email_summary = summary_on elif summary_type == "RSS": current_user.rss_summary = summary_on update_user_feed(current_user) else: flash("Summary Type was not valid", ALERT.ERROR) return redirect(url_for("users.user_settings")) current_user.save() if summary_on: flash( f"You will now receive summaries for {summary_type} articles.", ALERT.SUCCESS, ) else: flash( f"You will now see the full received content for {summary_type} articles", ALERT.WARNING, ) return redirect(url_for("users.user_settings"))
def post(self): '''Upload a new avatar''' parse_uploaded_image(current_user.avatar) current_user.save() return {'image': current_user.avatar}
def delete(self): '''Clear/destroy an apikey''' current_user.apikey = None current_user.save() return '', 204
def post(self): '''(Re)Generate my API Key''' current_user.generate_api_key() current_user.save() return current_user, 201
def eve_main_character_change(character_id): if EveManager.check_if_character_owned_by_user(character_id, current_user.get_id()): current_user.main_character_id = character_id current_user.save() return redirect(url_for('user.eve_characters'))
def post(self): '''Upload a new avatar''' parse_uploaded_image(current_user.avatar) current_user.save() return {'image': current_user.avatar}
def delete(self): '''Clear/destroy an apikey''' current_user.apikey = None current_user.save() return '', 204
def post(self): '''(Re)Generate my API Key''' current_user.generate_api_key() current_user.save() return current_user, 201