@action(route="/stations/edit/<id>", template="stations/edit.html", methods=['POST', 'GET'])
@only_orga_admin_user()
def stations_edit(request, id):

    object = None
    errors = []

    if id != '-':
        object = Station.query.filter_by(orga=int(request.args.get('ebuio_orgapk') or request.form.get('ebuio_orgapk')), id=int(id)).first()

    if request.method == 'POST':

        if not object:
            object = Station(int(request.form.get('ebuio_orgapk')))

        object.name = request.form.get('name')
        object.short_name = request.form.get('short_name')
        object.short_description = request.form.get('short_description')
        object.ip_allowed = request.form.get('ip_allowed')

        genres = []

        genre_href = request.form.getlist('genrehref[]')
        genre_name = request.form.getlist('genrename[]')

        for h in genre_href:
            genres.append({'href': h, 'name': genre_name.pop(0)})

        object.genres = json.dumps(genres)

        # Check errors
        if object.name == '':
            errors.append("Please set a name")

        # If no errors, save
        if not errors:

            if not object.id:
                object.gen_random_password()
                db.session.add(object)

            db.session.commit()

            return PlugItRedirect('stations/?saved=yes')

    if object:
        object = object.json

    return {'object': object, 'errors': errors}
Registers a namespace,, making it available for use when adding subsequent fields to the entry.
dataset/ETHPy150Open ebu/radiodns-plugit/RadioDns-PlugIt/stations/actions.py/stations_edit--crossover with--dataset/ETHPy150Open swordapp/python-client-sword2/sword2/atom_objects.py/Entry.register_namespace