Esempio n. 1
0
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())
Esempio n. 2
0
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())
Esempio n. 3
0
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())
Esempio n. 4
0
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())
Esempio n. 5
0
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())
Esempio n. 6
0
def update(owner, resource):
    """ Update the data of the resource. """
    data = request_content(request)
    resource = logic.resource.update(owner, resource, data)
    return jsonify(resource)
Esempio n. 7
0
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))
Esempio n. 8
0
def update(owner, dataset):
    """ Update the data of the dataset. """
    data = request_content(request)
    dataset = logic.dataset.update(owner, dataset, data)
    return jsonify(dataset)
Esempio n. 9
0
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))
Esempio n. 10
0
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))
Esempio n. 11
0
def update(owner, resource):
    """ Update the data of the resource. """
    data = request_content(request)
    resource = logic.resource.update(owner, resource, data)
    return jsonify(resource)
Esempio n. 12
0
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))
Esempio n. 13
0
def update(owner, dataset):
    """ Update the data of the dataset. """
    data = request_content(request)
    dataset = logic.dataset.update(owner, dataset, data)
    return jsonify(dataset)
Esempio n. 14
0
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))
Esempio n. 15
0
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))
Esempio n. 16
0
def update(account):
    """ Update the data of the account profile. """
    data = request_content(request)
    account = logic.account.update(account, data)
    return jsonify(account)