示例#1
0
def get_form_expected_form_details_dto():

    brand1= GetFormBrandDtoWithItemId(
            brand_id=1,
            name="HoneyBee",
            min_quantity=2,
            max_quantity=10,
            price_per_item=100,
            item_id=1)
    brand2 = GetFormBrandDtoWithItemId(
            brand_id=2,
            name="KnockOut",
            min_quantity=2,
            max_quantity=11,
            price_per_item=200,
            item_id=1)
    brand3 = GetFormBrandDtoWithItemId(
            brand_id=3,
            name="KingFisher",
            min_quantity=2,
            max_quantity=11,
            price_per_item=200,
            item_id=2)
        
    order1 = GetFormItemOrderDto(order_id=1,
                                 brand_id=1,
                                 ordered_count=10,
                                 out_of_stock=0)
    order2 = GetFormItemOrderDto(order_id=2,
                                 brand_id=3,
                                 ordered_count=10,
                                 out_of_stock=0)
    
    item1 = GetFormItemDto(item_id=1,
                           name="choco",
                           description="choco",
                           brands=[brand1, brand2],
                           order=order1)
    item2 = GetFormItemDto(item_id=2,
                           name="lace",
                           description="lace",
                           brands=[brand3],
                           order=order2)

    section1 = GetFormSectionDto(section_id=1,
                                 name="SECTION1",
                                 description="DESCRIP SECTION1",
                                 items=[item1, item2])

    section2 = GetFormSectionDto(section_id=2,
                                 name="SECTION2",
                                 description="DESCRIP SECTION2",
                                 items=[])
    
    get_form_dto = GetFormDto(form_id=1,
                              name="FORM1",
                              close_date=datetime.datetime(2020, 10, 10, 0, 0),
                              sections=[section1, section2])

    return get_form_dto
示例#2
0
    def _get_item_details_dtos(self,
                               section_order_dtos,
                               section_items_dtos,
                               brand_dicts):

        item_dto_list = []

        for item in section_items_dtos:
            brand_dtos = self._get_item_brands_dto_list(
                item=item,
                brand_dicts=brand_dicts)

            (order_id,
             brand_id,
             ordered_count,
             out_of_stock) = self._get_order_related_data_for_item(
                 item=item,
                 orders=section_order_dtos,
                 brand_dicts=brand_dicts)

            item_order_dto = GetFormItemOrderDto(order_id=order_id,
                                                 brand_id=brand_id,
                                                 ordered_count=ordered_count,
                                                 out_of_stock=out_of_stock)
                    
            dto = GetFormItemDto(item_id=item.item_id,
                                 name=item.name,
                                 description=item.description,
                                 brands=brand_dtos,
                                 order=item_order_dto)
            item_dto_list.append(dto)

        return item_dto_list
    def _get_items_details_dtos(self, section_id, order_dtos, item_dtos,
                                brand_dicts):
        item_dtos_list = []

        section_items = self._get_section_items(section_id=section_id,
                                                item_dtos=item_dtos)

        for item in section_items:
            item_id = item.item_id
            item_brands = self._get_item_brands_dtos(item_id=item_id,
                                                     brand_dicts=brand_dicts)
            order_dto = self._get_item_order_dto(item_id=item_id,
                                                 order_dtos=order_dtos)

            dto = GetFormItemDto(item_id=item.item_id,
                                 name=item.name,
                                 description=item.description,
                                 brands=item_brands,
                                 order=order_dto)
            item_dtos_list.append(dto)

        return item_dtos_list