def tower(tower_id, decorator=None): try: towers.garbage_collection(tower_id) tower = towers[tower_id] except KeyError: log('Bad tower_id') abort(404) # Make sure the Bearer token for the current user is not expired and pass it to the client html # This is how the client will be automatically logged in w/o cross-domain cookies user_token = '' if current_user.is_anonymous\ else current_user.get_token() # Pass in both the tower and the user_name return render_template('ringing_room.html', tower = tower, user_id = 0 if current_user.is_anonymous else current_user.id, user_name = '' if current_user.is_anonymous else current_user.username, user_email = '' if current_user.is_anonymous else current_user.email, user_badge = '' if current_user.is_anonymous else current_user.badge, user_settings = Config.DEFAULT_SETTINGS if current_user.is_anonymous else current_user.get_settings_with_defaults(), server_ip=get_server_ip(tower_id), user_token = user_token, host_permissions = current_user.check_permissions(tower_id,'host')\ if current_user.is_authenticated else False, listen_link = False)
def get_tower(tower_id): tower = TowerDB.query.get_or_404(tower_id) data = { 'tower_id': tower_id, 'tower_name': tower.tower_name, 'server_address': get_server_ip(tower_id), } return jsonify(data)
def get_tower(tower_id): tower = TowerDB.query.get_or_404(tower_id) data = { 'tower_id': tower_id, 'tower_name': tower.tower_name, 'server_address': get_server_ip(tower_id), 'additional_sizes_enabled': tower.additional_sizes_enabled, 'host_mode_permitted': tower.host_mode_enabled, 'half_muffled': tower.half_muffled } return jsonify(data)
def observer(tower_id, decorator=None): try: towers.garbage_collection(tower_id) tower = towers[tower_id] except KeyError: log('Bad tower_id') abort(404) return render_template('ringing_room.html', tower=tower, listen_link=True, server_ip=get_server_ip(tower_id))
def create_tower(): data = request.get_json() or {} try: tower = Tower(name = data['tower_name']) except KeyError: return bad_request('You must supply a tower name.') tower_db = tower.to_TowerDB() tower_db.created_by(current_user) db.session.add(tower_db) db.session.commit() data = { 'tower_id': tower_db.tower_id, 'tower_name': tower_db.tower_name, 'server_address': get_server_ip(tower_db.tower_id), } return jsonify(data)