def remove_user(self, email): user_to_be_removed = db_session.query(UserDB).filter( UserDB.email == email).one() db_session.delete(user_to_be_removed) db_session.commit() db_session.flush()
def attend_next_customer(): next_customer = db_session.query(AppointmentsDB).filter( AppointmentsDB.request_addressed is False).one() next_customer.request_addressed = True db_session.update(next_customer) db_session.commit() db_session.flush()
def remove_insurance_plan(self, plan_id): update_plan = db_session.query(InsurancePlanDB).filter( InsurancePlanDB.plan_id == plan_id).one() update_plan.plan_active = False db_session.update(update_plan) db_session.commit() db_session.flush()
def add_payment_info_in_topic(self, topic_id): id = input('Введите id платежной информации (1 или 2): ') q_message = db_session.query(PaymentInfo).filter_by(id=id).first() message = '{}\n\nРЕКВИЗИТЫ\nПолучатель: {}\n№ карты: {}\n{}\n\n{}'.format(q_message.first_msg, q_message.recipient, q_message.card_number, q_message.card_type, q_message.end_msg) self.__vk_api.board.createComment(v='5.0', group_id=47985581, topic_id=topic_id, message=message, from_group=1)
def plan_details(self, email, password): if self._customer.email == email and self._customer.password == password: user_details = db_session.query(UserDB).filter( UserDB.email == email).one() plan_details = eval( user_details.additional_metadata.replace('null', 'None')).get( 'plan_details', {}) return plan_details else: return "Unauthorized Access"
def buy_plan(self, plan_details): curr_customer = db_session.query(UserDB).filter( UserDB.email == self.email).one() curr_customer.additional_metadata = eval( curr_customer.additional_metadata.replace('null', 'None')) curr_customer.additional_metadata['plan_details'] = plan_details db_session.add(curr_customer) db_session.commit() db_session.flush()
def get_user(email): curr_user = db_session.query(UserDB).filter(UserDB.email == email).one() username = curr_user.name email = curr_user.email password = curr_user.password mod_additional_metadata = eval( curr_user.additional_metadata.replace('null', 'None')) phone_no = mod_additional_metadata.get('phone_no', 'UNK') postal_address = mod_additional_metadata.get('postal_address', 'UNK') curr_user_obj = Customer(username=username, email=email, password=password, phone_no=phone_no, postal_address=postal_address) curr_user_obj.additional_metadata = mod_additional_metadata return curr_user_obj
def create_first_topic_msg(self): pattern = r'_[0-9]+$' # 'https://vk.com/album-47985581_237024723' albums = {} album_link = input('Введите ссылку на альбом: ') while album_link: album_id = re.search(pattern, album_link).group()[1:] album_info = self.__vk_api.photos.getAlbums(v='5.0', owner_id=-47985581, album_ids=album_id) stop_album = StopAlbum(album_info['items'][0]['title'], album_link, 1) stop_album.save_in_db() albums[stop_album.link] = stop_album.name album_link = input('Введите ссылку на альбом: ') q_first_text = db_session.query(TopicMessage).filter_by(id=1).first() first_text = q_first_text.text for k, v in albums.items(): first_text += '\n{}: {}'.format(v, k) return first_text