def View_country_detail(postal_code: str, current_user=Security(deps.get_current_active_user, scopes=["read_country"]), db: Session = Depends(deps.get_db)): if crud_country.get_country(db=db, country_id=postal_code) is None: raise UnicornException(messages="COUNTRY ID NOT FOUND", name=postal_code) return crud_country.get_country(db=db, country_id=postal_code)
def get_shop(db: Session, shop_id: str): s = db.query(shop.Shop).filter(shop.Shop.id == shop_id).first() s.channel_name = crud_channel.get_channel(db=db, channel_id=s.channel_id).name s.country_name = crud_country.get_country(db=db, country_id=s.postal_code).name return s
def get_all_shops(db: Session, skip: int = 0, limit: int = 100): shops = db.query(shop.Shop).offset(skip).limit(limit).all() for s in shops: s.channel_name = crud_channel.get_channel(db=db, channel_id=s.channel_id).name s.country_name = crud_country.get_country( db=db, country_id=s.postal_code).name return shops
def get_all_shop_channel(db: Session, channel_id: str): shops = db.query( shop.Shop).filter(shop.Shop.channel_id == channel_id).all() for s in shops: s.channel_name = crud_channel.get_channel(db=db, channel_id=s.channel_id).name s.country_name = crud_country.get_country( db=db, country_id=s.postal_code).name return shops
def get_all_shop_of_executor(db: Session, executor_id: str): all_shop_id = [] for id in crud_shop_executor.get_shop_id_of_executor( db=db, executor_id=executor_id): all_shop_id.append(id[0]) shops = db.query(shop.Shop).filter(shop.Shop.id.in_(all_shop_id)).all() for s in shops: s.channel_name = crud_channel.get_channel(db=db, channel_id=s.channel_id).name s.country_name = crud_country.get_country( db=db, country_id=s.postal_code).name return shops
def View_All_Shop_Of_Country(postal_code: str, current_user=Security( deps.get_current_active_user, scopes=["READ_COUNTRY"]), db: Session = Depends(deps.get_db)): ''' View ALL Shop Of Country ''' if crud_country.get_country(db=db, country_id=postal_code) is None: raise UnicornException(messages="COUNTRY ID NOT FOUND", name=postal_code) return crud_shop.get_all_shop_country(db=db, postal_code=postal_code)
def View_country_detail(postal_code: str, current_user=Security(deps.get_current_active_user, scopes=["read_country"]), db: Session = Depends(deps.get_db)): return crud_country.get_country(db=db, country_id=postal_code)
def View_country_detail(postal_code: str, db: Session = Depends(deps.get_db)): return crud_country.get_country(db=db, country_id=postal_code)