def __unload(entry): entity = Role() entity.dn = ldaphelper.get_dn(entry) entity.internal_id = ldaphelper.get_attr_val( entry[ATTRIBUTES][global_ids.INTERNAL_ID]) entity.name = ldaphelper.get_attr_val(entry[ATTRIBUTES][ROLE_NAME]) entity.description = ldaphelper.get_one_attr_val( entry[ATTRIBUTES][global_ids.DESC]) # Get the multi-occurring attrs: entity.props = ldaphelper.get_list(entry[ATTRIBUTES][global_ids.PROPS]) # unload raw constraint: entity.constraint = Constraint( ldaphelper.get_attr_val(entry[ATTRIBUTES][global_ids.CONSTRAINT])) return entity
gbr=Image() x=gbr.query.filter_by(path='beranda.jpeg').first() if x is None: gbr.path='beranda.jpeg' db.session.add(gbr) db.session.commit() role = Role() x=role.query.filter_by(name='admin').first() # db.session.delete(x) # db.session.commit() if x is None : role.name='admin' role.description='admin' db.session.add(role) db.session.commit() user = User() y=user.query.filter_by(email='*****@*****.**').first() if y is None: user.email='*****@*****.**' user.password='******' user.active=True user.roles.append(role) # bagian ini yg beda db.session.add(user) db.session.commit()