def post(self): """Create new checkin""" auth = request.authorization user_uid = api.payload['user_uid'] checkin = Checkin(user_uid=user_uid, initiator=auth.username) db_session.add(checkin) db_session.commit() return db_session.query(Checkin).order_by( Checkin.checkin_uid.desc()).first(), 201
def get(self): """List all users""" return db_session.query(User).all(), 200
def verify_password(username, password_candidate): """Verify basic auth credentials.""" admin = db_session.query(Admin).filter_by(username=username).first() if not admin: return False return sha256_crypt.verify(password_candidate, admin.password_hash)
def get(self, username): """Fetch admin by username""" return db_session.query(Admin).filter_by(username=username).one(), 200
def get(self): """List all admins""" return db_session.query(Admin).all(), 200
def get(self, card_uid): """Fetch card by card_uid""" return db_session.query(Card).filter_by(card_uid=card_uid).one(), 200
def get(self): """List all cards""" return db_session.query(Card).all(), 200
def delete(self, checkin_uid): """Delete checkin""" db_session.query(Checkin).filter( Checkin.checkin_uid == checkin_uid).delete() db_session.flush() return '', 204
def get(self, checkin_uid): """Fetch checkin by id""" return db_session.query(Checkin).filter_by( checkin_uid=checkin_uid).one(), 200
def get(self): """List all checkins""" return db_session.query(Checkin).all(), 200
def put(self, id): """Update a user""" db_session.query(User).filter_by(id=id).update(api.payload) db_session.commit() user = db_session.query(User).filter_by(id=id).one() return user, 200
def get(self, id): """List user by id""" return db_session.query(User).filter_by(id=id).one(), 200