def register_save(): data = request_content(request) try: logic.user.register(data) return redirect(url_for('home')) except Invalid, inv: page = register() return htmlfill.render(page, defaults=data, errors=inv.unpack_errors())
def login_save(): data = request_content(request) try: logic.user.login(data) flash('Welcome back.', 'success') return redirect(url_for('home')) except Invalid, inv: page = login() return htmlfill.render(page, defaults=data, errors=inv.unpack_errors())
def profile_save(): data = request_content(request) try: logic.user.update(current_user, data) flash('Your profile has been updated.', 'success') return profile() except Invalid, inv: page = profile() return htmlfill.render(page, defaults=data, errors=inv.unpack_errors())
def dataset_create(): """ Create a new dataset for the given user. """ require.logged_in() owner = current_user.name data = request_content(request) try: dataset = logic.dataset.create(owner, data) if 'resource' in data: # if we were simultaneously attaching a # resource, return there instead. flash('Created %s / %s' % (dataset.owner.name, dataset.name), 'success') return redirect( url_for('node', owner=data['resource']['owner'], node=data['resource']['name'])) return redirect(url_for('node', owner=owner, node=dataset.name)) except Invalid, inv: page = dataset_create_form() return htmlfill.render(page, defaults=data, errors=inv.unpack_errors())
def dataset_create(): """ Create a new dataset for the given user. """ require.logged_in() owner = current_user.name data = request_content(request) try: dataset = logic.dataset.create(owner, data) if 'resource' in data: # if we were simultaneously attaching a # resource, return there instead. flash('Created %s / %s' % (dataset.owner.name, dataset.name), 'success') return redirect(url_for('node', owner=data['resource']['owner'], node=data['resource']['name'])) return redirect(url_for('node', owner=owner, node=dataset.name)) except Invalid, inv: page = dataset_create_form() return htmlfill.render(page, defaults=data, errors=inv.unpack_errors())
def update(owner, resource): """ Update the data of the resource. """ data = request_content(request) resource = logic.resource.update(owner, resource, data) return jsonify(resource)
def create(owner): """ Create a new resource for the given user. """ data = request_content(request) resource = logic.resource.create(owner, data) return redirect(url_for(".get", owner=owner, resource=resource.name))
def update(owner, dataset): """ Update the data of the dataset. """ data = request_content(request) dataset = logic.dataset.update(owner, dataset, data) return jsonify(dataset)
def resources_add(owner, dataset): """ Add a resource to this dataset. """ data = request_content(request) logic.dataset.add_resource(owner, dataset, data) return redirect(url_for('.resources_get', owner=owner, dataset=dataset))
def create(owner): """ Create a new dataset for the given user. """ data = request_content(request) dataset = logic.dataset.create(owner, data) return redirect(url_for('.get', owner=owner, dataset=dataset.name))
def create(owner): """ Create a new resource for the given user. """ data = request_content(request) resource = logic.resource.create(owner, data) return redirect(url_for('.get', owner=owner, resource=resource.name))
def update(account): """ Update the data of the account profile. """ data = request_content(request) account = logic.account.update(account, data) return jsonify(account)