def create(uid, new_user_notif, near_user_notif): s = session() s.add(UserPreferences(uid=uid, new_user_notif=new_user_notif, near_user_notif=near_user_notif)) s.commit() s.close()
def delete(**kwargs): s = session() q = s.query(PasswordReset) q = PasswordResetCRUD.__apply_filters(q, **kwargs) q.delete() s.commit() s.close()
def delete(**kwargs): s = session() q = s.query(UserPreferences) q = UserPreferencesCRUD.__apply_filters(q, **kwargs) q.delete() s.commit() s.close()
def delete(**kwargs): s = session() q = s.query(UserLocation) q = UserLocationCRUD.__apply_filters(q, **kwargs) q.delete() s.commit() s.close()
def delete(**kwargs): s = session() q = s.query(Location) q = LocationCRUD.__apply_filters(q, **kwargs) q.delete() s.commit() s.close()
def create(uid, new_user_notif, near_user_notif): s = session() s.add( UserPreferences(uid=uid, new_user_notif=new_user_notif, near_user_notif=near_user_notif)) s.commit() s.close()
def search(firstname_filter, lastname_filter, promo_filter): s = session() res = s.query(User).filter( User.firstname.ilike(firstname), User.lastname.ilike(lastname_filter), User.promo.ilike(promo_filter)).all() s.close() return res
def create(osm_id, city, country, lat, lon): s = session() s.add( Location(osm_id=osm_id, city=city, country=country, lat=lat, lon=lon)) s.commit() s.close()
def update(uid, **kwargs): state = False s = session() pwrst = s.query(PasswordReset).filter(PasswordReset.uid == uid).one_or_none() if pwrst is not None: for key, val in kwargs.items(): if val is not None and key in PasswordResetCRUD.ATTRIBUTES: if key == 'uid': modlgr.warning('update() cannot update uid.') continue setattr(pwrst, key, val) s.add(pwrst) s.commit() state = True s.close() return state
def update(uid, **kwargs): state = False s = session() pref = s.query(UserPreferences).filter(UserPreferences.uid == uid).one_or_none() if pref is not None: for key, val in kwargs.items(): if val is not None and key in UserPreferencesCRUD.ATTRIBUTES: if key == 'uid': modlgr.warning('update() cannot update uid.') continue setattr(pref, key, val) s.add(pref) s.commit() state = True s.close() return state
def update(lid, **kwargs): state = False s = session() loc = s.query(Location).filter(Location.id == lid).one_or_none() if loc is not None: for key, val in kwargs.items(): if val is not None and key in LocationCRUD.ATTRIBUTES: if key == 'id': modlgr.warning('update() cannot update id.') continue setattr(loc, key, val) s.add(loc) s.commit() state = True s.close() return state
def update(uid, **kwargs): state = False s = session() pref = s.query(UserPreferences).filter( UserPreferences.uid == uid).one_or_none() if pref is not None: for key, val in kwargs.items(): if val is not None and key in UserPreferencesCRUD.ATTRIBUTES: if key == 'uid': modlgr.warning('update() cannot update uid.') continue setattr(pref, key, val) s.add(pref) s.commit() state = True s.close() return state
def update(uid, **kwargs): state = False s = session() usr = s.query(User).filter(User.id == uid).one_or_none() if usr is not None: for key, val in kwargs.items(): if val is not None and key in UserCRUD.ATTRIBUTES: if key == 'id': modlgr.warning('update() cannot update id.') continue if key == 'pwd': val = bcrypt.hashpw(val.encode(), bcrypt.gensalt()).decode() setattr(usr, key, val) s.add(usr) s.commit() state = True s.close() return state
def update(uid, ulid, **kwargs): state = False s = session() # SEC-NOTE: test ulid and uid, even if uid is a foreign key, to prevent a # user updating a record of another user. uloc = s.query(UserLocation).filter( UserLocation.id == ulid, UserLocation.uid == uid).one_or_none() if uloc is not None: for key, val in kwargs.items(): if val is not None and key in UserLocationCRUD.ATTRIBUTES: if key == 'id': modlgr.warning('update() cannot update id.') continue setattr(uloc, key, val) s.add(uloc) s.commit() state = True s.close() return state
def create(osm_id, city, country, lat, lon): s = session() s.add(Location(osm_id=osm_id, city=city, country=country, lat=lat, lon=lon)) s.commit() s.close()
def retrieve(**kwargs): s = session() q = s.query(Location) q = LocationCRUD.__apply_filters(q, **kwargs) return (s, q)
def retrieve(**kwargs): s = session() q = s.query(PasswordReset) q = PasswordResetCRUD.__apply_filters(q, **kwargs) return (s, q)
def retrieve(**kwargs): s = session() q = s.query(UserLocation) q = UserLocationCRUD.__apply_filters(q, **kwargs) return (s, q)
def create(firstname, lastname, email, pwd, promo): s = session() s.add(User(firstname=firstname, lastname=lastname, email=email, pwd=pwd, promo=promo)) s.commit() s.close()
def create(uid, lid, timestamp, meta): s = session() s.add(UserLocation(uid=uid, lid=lid, timestamp=timestamp, meta=meta)) s.commit() s.close()
def retrieve(**kwargs): s = session() q = s.query(UserPreferences) q = UserPreferencesCRUD.__apply_filters(q, **kwargs) return (s, q)
def create(uid, token, timestamp, used): s = session() s.add(PasswordReset(uid=uid, token=token, timestamp=timestamp, used=used)) s.commit() s.close()