def post(self, person_id): # Query all records with this person id, reject if there is a record with no time out # [abort] this person has a time in recod with no out record existRec = db.session.query(Record)\ .filter(Record.deletedAt == 0)\ .filter(Record.person_id == person_id)\ .filter(Record.timeOut == 0)\ .first() if existRec: abort( 400, message="Person with id -- {} has already TIMED IN".format(id)) # abort if person does not exist person = RecordAPI.getActivePersonWithId(person_id) # create record rec = Record() rec.person_id = person.id rec.type = person.type rec.timeIn = time_provider.getTime() rec.timeInBy = api_user() # insert db.session.add(rec) db.session.commit() return rec, 201
def delete(self, id): record = RecordAPI.getActiveRecordWithId(id) record.deletedAt = time_provider.getTime() record.deletedBy = api_user() db.session.add(record) db.session.commit() return {}, 204
def delete(self, id): person = PersonAPI.getActivePersonWithId(id) person.deletedAt = time_provider.getTime() person.deletedBy = api_user() db.session.add(person) db.session.commit() return {}, 204
def delete(self, id): endpoint_admin() user = UserAPI.getActiveUserWithId(id) user.deletedAt = time_provider.getTime() user.deletedBy = api_user() db.session.add(user) db.session.commit() return {}, 204
def put(self, id): record = RecordAPI.getActiveRecordWithId(id) if record.timeOut != 0: abort(400, message="Record with id -- {} has already TIMED OUT".format( id)) record.timeOut = time_provider.getTime() record.timeOutBy = api_user() db.session.add(record) db.session.commit() return record, 200
def post(self): parsed_args = self.request_parser.parse_args() person = Person() person.type = parsed_args['type'] person.nameLast = parsed_args['nameLast'] person.nameFirst = parsed_args['nameFirst'] person.nameMiddle = parsed_args['nameMiddle'] person.nameExt = parsed_args['nameExt'] person.contactTel = parsed_args['contactTel'] person.contactMobile = parsed_args['contactMobile'] person.contactEmail = parsed_args['contactEmail'] person.updatedAt = time_provider.getTime() person.updatedBy = api_user() db.session.add(person) db.session.commit() return person, 201
def post(self): endpoint_admin() parsed_args = self.post_parser.parse_args() user = User() user.username = parsed_args['username'] user.password = UserAPI.hash_password(parsed_args['password']) user.nameLast = parsed_args['nameLast'] user.nameFirst = parsed_args['nameFirst'] user.nameMiddle = parsed_args['nameMiddle'] user.nameExt = parsed_args['nameExt'] user.access = parsed_args['access'] user.updatedAt = time_provider.getTime() user.updatedBy = api_user() db.session.add(user) db.session.commit() return user, 201
def put(self, id): endpoint_admin() user = UserAPI.getActiveUserWithId(id) parsed_args = self.post_parser.parse_args() user.username = parsed_args['username'] # update password if not empty (change password) password = parsed_args['password'] if password: user.password = UserAPI.hash_password(parsed_args['password']) # user.nameLast = parsed_args['nameLast'] user.nameFirst = parsed_args['nameFirst'] user.nameMiddle = parsed_args['nameMiddle'] user.nameExt = parsed_args['nameExt'] user.access = parsed_args['access'] user.updatedAt = time_provider.getTime() user.updatedBy = api_user() db.session.add(user) db.session.commit() return user, 200