def packages(): require_user() if request.method == 'GET': return get_packages() else: pkg_name = request.form.get('package', None) if pkg_name == None: abort(500) else: pkg = require_package(pkg_name) if request.method == 'PUT': return put_package(pkg) elif request.method == 'DELETE': return delete_package(pkg)
def user_info_put(): user = require_user() name = request.form.get('name', None) if name != None: user.change_shown_name(name) return 'ok' else: abort(400)
def mirrors_get(): user = require_user() # Get mirrors information return_mirrors = [] for mirror in user.get_owned_mirrors(): return_mirror = { 'id': mirror.get_id(), 'name': mirror.get_name() } return_mirrors.append(return_mirror) return_mirrors.sort(key=lambda m: m['name']) return json.dumps(return_mirrors)
def synceds_put(): user = require_user() # Create a new mirror name = request.form.get('name', None) if name != None: synced = create_work_folder(name, user.get_username()) return str(synced.get_id()) else: abort(400)
def synceds_get(): user = require_user() # Get mirrors information return_synceds = [] for synced in user.get_owned_work_folders(): return_synced = { 'id': synced.get_id(), 'name': synced.get_name() } return_synceds.append(return_synced) return_synceds.sort(key=lambda m: m['name']) return json.dumps(return_synceds)
def mirrors_put(): user = require_user() # Create a new mirror name = request.form.get('name', None) if name != None: mirror = create_mirror(name, user.get_username()) return str(mirror.get_id()) else: abort(400)
def synced_generate_invite(sid): user = require_user() s = WorkFolder(sid) #app.logger.error('User: %s, existance: %s, owner: %s', user.get_username(), str(s.exists()), s.get_owner().get_username()) if s.exists() and s.get_owner().get_username() == user.get_username(): random_id = random.randint(100, 2000000) current_upload_keys.append({ 'id': random_id, 'time': datetime.datetime.now(), 'synced_id': sid, 'user': user }) return str(random_id) else: abort(403)
def mirrors_delete(): user = require_user() # Delete a mirror mid = int(request.form.get('id')) m = Mirror(mid) if m.exists() and m.get_owner().get_username() == user.get_username(): m.delete(False) abort(200) else: abort(403)
def synced_name(): user = require_user() name = request.form.get('name', None) sid = int(request.form.get('id')) s = WorkFolder(sid) if name != None and s.exists() and s.get_owner().get_username() == user.get_username(): # Change name s.change_name(name) abort(200) else: abort(403)
def mirror_name(): user = require_user() name = request.form.get('name', None) mid = int(request.form.get('id')) m = Mirror(mid) if name != None and m.exists() and m.get_owner().get_username() == user.get_username(): # Change name m.change_name(name) abort(200) else: abort(403)
def user_info_get(): user = require_user() return json.dumps({ 'username': user.get_username(), 'uid': user.get_id(), 'name': user.get_shown_name() })
def user_name(): user = require_user() return user.get_shown_name()
def change_password(): user = require_user() oldPass = request.form.get('old', None) newPass = request.form.get('new', None) user.change_password(oldPass, newPass) return 'ok'
def package_status(pkg_name): require_user() pkg = require_package(pkg_name) return json.dumps({ 'status': get_package_status(pkg) })
def package_info(pkg_name): require_user() pkg = require_package(pkg_name) pkg['status'] = get_package_status(pkg) return json.dumps(pkg)