def update_by_id(id, db_connection, data): result = None try: db.session.query(BusinessOwner). \ filter(CarWashBusinessOwner.id == BusinessOwner.id). \ filter(CarWashBusinessOwner.id == User.id). \ filter(CarWashBusinessOwner.id == id). \ update(data, synchronize_session='fetch') # AutoServiceBusinessOwner.query.filter_by(id=id).update(data) # AutoServiceBusinessOwner.query.filter_by(id=id).update(data) db_connection.session.commit() logger.info('update user. ID: %s' % id) params = {"user_id": id} success = SuccessUpdate(status=200, message=MessagesKeys.SUCCESS_UPDATE, params=params) # raise Exception() result = True, success except InvalidRequestError as error: result = db_error_message(logger) db_connection.session.rollback() except: result = db_error_message(logger) db_connection.session.rollback() return result
def _update_location(self): try: BusinessOwner.update_lng_lat(self.business_owner.id, self.business_owner.lng, self.business_owner.lat, db) success = SuccessUpdate(status=200, message=MessagesKeys.SUCCESS_UPDATE) result = True, success except InvalidRequestError as error: result = db_error_message(logger) db.session.rollback() except: result = db_error_message(logger) db.session.rollback() return result
def update_by_id(id, db_connection, data): result = None try: OrderItem.query.filter(OrderItem.id == id).update(data) db_connection.session.commit() logger.info('update question_sets. ID: %s' % id) params = {Keys.ID: id} success = SuccessUpdate(status=200, message=MessagesKeys.SUCCESS_UPDATE, params=params) result = True, success except InvalidRequestError as error: result = db_error_message(logger) db_connection.session.rollback() except: result = db_error_message(logger) db_connection.session.rollback() return result
def update(self, db_connection, data): result = None try: Administrator.query.filter_by(phone_number=self.phone_number).update(data) user = Administrator.query.filter_by(phone_number=self.phone_number).first() self.id = user.id db_connection.session.commit() logger.info('update admin. ID: %s' % self.id) params = {"user_id": self.id} success = SuccessUpdate(status=200, message=MessagesKeys.SUCCESS_UPDATE, params=params) result = True, success except InvalidRequestError as error: result = db_error_message(logger) db_connection.session.rollback() except: result = db_error_message(logger) db_connection.session.rollback() return result
def update(self, db_connection, data): result = None try: Calendar.query.filter_by(id=self.id).update(data) db_connection.session.commit() logger.info('update business_owner. ID: %s' % self.id) params = {Keys.ID: self.id} success = SuccessUpdate(status=200, message=MessagesKeys.SUCCESS_UPDATE, params=params) result = True, success except InvalidRequestError as error: result = db_error_message(logger, message='InvalidRequestError') db_connection.session.rollback() except: result = db_error_message(logger) db_connection.session.rollback() return result
def add_rate(id, db_connection, data): result = None try: res = Jobs.query.filter(Jobs.id == id).first() result0 = res.rate.append(data) resu1 = res.rate re = {Keys.ID: id, Keys.RATE: resu1} Jobs.query.filter(Jobs.id == id).update(re) db_connection.session.commit() logger.info('update question_sets. ID: %s' % id) params = {Keys.ID: id} success = SuccessUpdate(status=200, message=MessagesKeys.SUCCESS_UPDATE, params=params) result = True, success except InvalidRequestError as error: result = db_error_message(logger) db_connection.session.rollback()
def update(self, db_connection, data): result = None try: Car.query.filter_by(id=self.id).update(data) db_connection.session.commit() logger.info('update car. ID: %s' % self.id) params = {"id": self.id} success = SuccessUpdate(status=200, message=MessagesKeys.SUCCESS_UPDATE, params=params) result = True, success except InvalidRequestError as error: result = db_error_message(logger, message='InvalidRequestError') db_connection.session.rollback() except IntegrityError as error: result = db_error_message(logger, message= Result.language.DUPLICATED_CAR) db_connection.session.rollback() except: result = db_error_message(logger) db_connection.session.rollback() return result
def update_by_id(id, db_connection, data): result = None try: Product.query.filter_by(id=id).update(data) db_connection.session.commit() logger.info('update user. ID: %s' % id) params = {"user_id": id} success = SuccessUpdate(status=200, message=MessagesKeys.SUCCESS_UPDATE, params=params) # raise Exception() result = True, success except InvalidRequestError as error: result = db_error_message(logger) db_connection.session.rollback() except: result = db_error_message(logger) db_connection.session.rollback() return result