

@expose('/lab/availability/public', methods=['POST'])
def change_public_availability(self):
    lab_id = int(request.form['lab_id'])
    activate = (request.form['activate'] == 'true')
    lab = self.session.query(Laboratory).filter_by(id=lab_id).first()
    if (lab is not None):
        if activate:
            lab.publicly_available = (not activate)
            lab.public_identifier = ''
        else:
            public_id = request.form['public_identifier']
            public_id = public_id.lstrip(' ')
            public_id = public_id.strip(' ')
            if ((not activate) and (len(public_id) == 0)):
                flash(gettext('Invalid public identifier (empty)'))
                return redirect(url_for('.index_view'))
            existing_labs = self.session.query(Laboratory).filter_by(public_identifier=public_id).all()
            if ((len(existing_labs) > 0) and (lab not in existing_labs)):
                flash(gettext("Public identifier '%(publicidentifier)s' already exists", publicidentifier=public_id))
                return redirect(url_for('.index_view'))
            lab.publicly_available = (not activate)
            lab.public_identifier = public_id
        public_id.session.add(lab)
        self.session.commit()
    return redirect(url_for('.index_view'))

dataset/ETHPy150Open gateway4labs/labmanager/labmanager/views/admin.py LaboratoryPanel.change_public_availability/VarMisuse@249/370 `self`->`public_id`