コード例 #1
0
ファイル: test_root_compare.py プロジェクト: So1itarius/Polus
    def test_compare_customers(self):
        customers = [
            dict(regnum=str(1),
                 guid="",
                 name="test1",
                 maxPrice=50325235.53,
                 guaranteeApp=95830945.54),
            dict(regnum=str(2),
                 guid="",
                 name="test2",
                 maxPrice=20325235.53,
                 guaranteeApp=35830945.54)
        ]

        result1 = Root() \
            .set_publication_date(1) \
            .add_customers(
                customers,
                lambda obj, c: c
                .set_properties(
                    max_price=obj['maxPrice'],
                    guarantee_app=obj['guaranteeApp'],
                    customer_name=obj['name'],
                    customer_guid=obj['guid']
                )
                .add_field(Field(
                    value="1",
                    name="test1",
                    displayName="fdn",
                    type=FieldType.String
                ))
        )

        result2 = Root() \
            .set_publication_date(2) \
            .add_customers(
                customers,
                lambda obj, c: c
                .set_properties(
                    max_price=obj['maxPrice'] + 50,
                    guarantee_app=obj['guaranteeApp'] + 50,
                    customer_name=obj['name'],
                    customer_guid=obj['guid']
                )
                .add_field(Field(
                    value="2",
                    name="test1",
                    displayName="fdn",
                    type=FieldType.String
                ))
        )

        result = result2.compare_many([result1])

        expected = "{\"customers\":[{\"0\":{\"fn\":\"maxPrice\",\"ft\":\"Price\",\"fv\":50325285.53,\"fdn\":\"Цена контракта\",\"ch\":{\"1\":50325235.53,\"2\":50325285.53}},\"1\":{\"fn\":\"guaranteeApp\",\"ft\":\"Price\",\"fv\":95830995.54,\"fdn\":\"Обеспечение заявки\",\"ch\":{\"1\":95830945.54,\"2\":95830995.54}},\"2\":{\"fn\":\"customer\",\"ft\":\"Object\",\"fv\":{\"guid\":\"\",\"name\":\"test1\"},\"fdn\":\"Заказчик\"},\"3\":{\"fn\":\"test1\",\"ft\":\"String\",\"fv\":\"2\",\"fdn\":\"fdn\",\"ch\":{\"1\":\"1\",\"2\":\"2\"}}},{\"0\":{\"fn\":\"maxPrice\",\"ft\":\"Price\",\"fv\":20325285.53,\"fdn\":\"Цена контракта\",\"ch\":{\"1\":20325235.53,\"2\":20325285.53}},\"1\":{\"fn\":\"guaranteeApp\",\"ft\":\"Price\",\"fv\":35830995.54,\"fdn\":\"Обеспечение заявки\",\"ch\":{\"1\":35830945.54,\"2\":35830995.54}},\"2\":{\"fn\":\"customer\",\"ft\":\"Object\",\"fv\":{\"guid\":\"\",\"name\":\"test2\"},\"fdn\":\"Заказчик\"},\"3\":{\"fn\":\"test1\",\"ft\":\"String\",\"fv\":\"2\",\"fdn\":\"fdn\",\"ch\":{\"1\":\"1\",\"2\":\"2\"}}}],\"general\":{}}"
        self.assertEqual(result.to_json(), expected)
コード例 #2
0
 def get_json(cls, tender):
     return Root() \
         .add_general(
         Field(
             name='MaxPrice',
             type=FieldType.Price,
             value=None,
             displayName='Цена контракта'
         )) \
         .add_customer(
         Customer().set_properties(
             max_price=None,
             guarantee_app=None,
             guarantee_contract=None,
             customer_guid=tender['customer']['guid'],
             customer_name=tender['customer']['name']
         )) \
         .add_category(
             lambda c: c.set_properties(
                 name='ProcedureInfo',
                 displayName='Порядок размещения заказа',
             ).add_field(Field(
                 name='SubmissionCloseDateTime',
                 displayName='Дата окончания приема заявок',
                 value=tender['submissonCloseDateTime'],
                 type=FieldType.DateTime
             )))\
         .to_json()
コード例 #3
0
 def test_add_general_object(self):
     field = Field(name="General1",
                   type=FieldType.DateTime,
                   value=5039466,
                   displayName="Основное поле 1")
     obj = Root().add_general(field)
     self.assertEqual(obj.general[0], field)
コード例 #4
0
 def test_add_category_lambda(self):
     obj = Root().add_category(lambda c: c.set_properties(
         name="Category1",
         displayName="Категория 1",
         modifications=[Modification.Calendar, Modification.Help]))
     self.assertIsNotNone(obj.containers[0])
     self.assertIsInstance(obj.containers[0], Category)
コード例 #5
0
 def test_add_category_object(self):
     category = Category(
         name="Category1",
         displayName="Категория 1",
         modifications=[Modification.Calendar, Modification.Help])
     obj = Root().add_category(category)
     self.assertEqual(obj.containers[0], category)
コード例 #6
0
    def test_validate_with_customers(self):
        customers = [
            dict(regnum=1,
                 guid="",
                 name="test1",
                 maxPrice=50325235.53,
                 guaranteeApp=95830945.54),
            dict(regnum=2,
                 guid="",
                 name="test2",
                 maxPrice=20325235.53,
                 guaranteeApp=35830945.54)
        ]

        errors = Root() \
            .add_customers(
                customers,
                lambda obj, c: c
                .set_properties(
                    max_price=obj['maxPrice'],
                    guarantee_app=obj['guaranteeApp'],
                    customer_name=obj['name'],
                    customer_guid=obj['guid']
                )
                .add_field(Field(
                    value="1",
                    name="test1",
                    displayName="fdn",
                    type=FieldType.String
                ))
        ) \
            .validate()

        self.assertEqual(errors, [])
コード例 #7
0
 def test_add_general_lambda(self):
     obj = Root().add_general(
         lambda f: f.set_properties(name="General1",
                                    type=FieldType.DateTime,
                                    value=5039466,
                                    displayName="Основное поле 1"))
     self.assertIsNotNone(obj.general[0])
     self.assertIsInstance(obj.general[0], Field)
コード例 #8
0
    def test_from_json_with_array(self):
        json1 = Root() \
            .add_category(
                lambda c: c
                .set_properties(
                    name="Category1",
                    displayName="Категория 1",
                    modifications=[Modification.Calendar, Modification.Help]
                )
                .add_field(Field(
                    type=FieldType.Price,
                    name="Field1",
                    displayName="Поле категории 1",
                    value=124124.54,
                    modifications=[Modification.CurEUR],
                    changes=dict([[1, "Старое поле категории 1"],
                                  [2, "Поле категории 1"]])
                ))
        ) \
            .add_category(
                lambda c: c
                .set_properties(
                    displayName="Category2",
                    name="Category2"
                )
                .add_array(
                    lambda ca: ca
                    .set_properties(
                        name="Array1",
                        displayName="Array 1"
                    )
                    .add_field(Field(
                        name="Field1",
                        displayName="Поле 1",
                        value="Значение 1",
                        type=FieldType.String
                    ))
                )
        ) \
            .to_json()

        json2 = Root().from_json(json1).to_json()
        self.assertEqual(json1, json2)
コード例 #9
0
    def test_from_json_with_customers(self):
        customers = [
            dict(regnum=str(1),
                 guid="",
                 name="test1",
                 maxPrice=50325235.53,
                 guaranteeApp=95830945.54),
            dict(regnum=str(2),
                 guid="",
                 name="test2",
                 maxPrice=20325235.53,
                 guaranteeApp=35830945.54)
        ]

        json1 = Root() \
            .add_customers(
                customers,
                lambda obj, c: c
                .set_properties(
                    max_price=obj['maxPrice'],
                    guarantee_app=obj['guaranteeApp'],
                    customer_name=obj['name'],
                    customer_guid=obj['guid']
                )
                .add_field(Field(
                    value="1",
                    name="test1",
                    displayName="fdn",
                    type=FieldType.String
                ))
        ) \
            .to_json()

        json2 = Root().from_json(json1).to_json()

        self.assertEqual(json1, json2)
コード例 #10
0
ファイル: test_root_to_json.py プロジェクト: So1itarius/Polus
    def test_to_json_with_array(self):
        result = Root() \
            .add_category(
                lambda c: c
                .set_properties(
                    name="Category1",
                    displayName="Категория 1",
                    modifications=[Modification.Calendar, Modification.Help]
                )
                .add_field(Field(
                    type=FieldType.Price,
                    name="Field1",
                    displayName="Поле категории 1",
                    value=124124.54,
                    modifications=[Modification.CurEUR],
                    changes=dict([[1, "Старое поле категории 1"],
                                  [2, "Поле категории 1"]])
                ))
        ) \
            .add_category(
                lambda c: c
                .set_properties(
                    displayName="Category2",
                    name="Category2"
                )
                .add_array(
                    lambda ca: ca
                    .set_properties(
                        name="Array1",
                        displayName="Array 1"
                    )
                    .add_field(Field(
                        name="Field1",
                        displayName="Поле 1",
                        value="Значение 1",
                        type=FieldType.String
                    ))
                )
        ) \
            .to_json()

        expected = "{\"0\":{\"fn\":\"Category1\",\"ft\":\"Category\",\"fv\":{\"0\":{\"fn\":\"Field1\",\"ft\":\"Price\",\"fv\":124124.54,\"fdn\":\"Поле категории 1\",\"md\":[\"CurEUR\"],\"ch\":{\"1\":\"Старое поле категории 1\",\"2\":\"Поле категории 1\"}}},\"fdn\":\"Категория 1\",\"md\":[\"Calendar\",\"Help\"]},\"1\":{\"fn\":\"Category2\",\"ft\":\"Category\",\"fv\":{\"0\":{\"fn\":\"Array1\",\"ft\":\"Array\",\"fv\":{\"0\":{\"fn\":\"Field1\",\"ft\":\"String\",\"fv\":\"Значение 1\",\"fdn\":\"Поле 1\"}},\"fdn\":\"Array 1\"}},\"fdn\":\"Category2\"},\"general\":{\"customers\":[]}}"
        self.assertEqual(result, expected)
コード例 #11
0
ファイル: test_root_compare.py プロジェクト: So1itarius/Polus
    def test_compare_categories_with_general(self):
        some_list = [
            dict(SomeShit="SomeShit1", Nullable="Nullable1", OtherShit=1),
            dict(SomeShit="SomeShit2", Nullable="Nullable2", OtherShit=2),
            dict(SomeShit="SomeShit2", Nullable="Nullable2", OtherShit=2)
        ]

        obj1 = Root() \
            .set_publication_date(1) \
            .add_general(Field(
                name="General1",
                type=FieldType.DateTime,
                value=5039466,
                displayName="Основное поле 1"
            )
        ) \
            .add_category(
                lambda c: c
                .set_properties(
                    name="Category1",
                    displayName="Категория 1",
                    modifications=[
                        Modification.Calendar, Modification.Help]
                )
                .add_table(
                    lambda t: t
                    .set_properties(
                        name="Table1",
                        displayName="Таблица 1"
                    )
                    .set_header(
                        lambda th: th
                        .add_cells([
                            Head(name="Head1", displayName="Header 1"),
                            Head(name="Head2", displayName="Header 2"),
                            Head(name="Head3", displayName="Header 3")
                        ]))
                    .add_rows(
                        some_list,
                        lambda list_element, row: row.add_cells([
                            Cell(
                                name="Head1",
                                type=FieldType.Integer,
                                value=list_element['SomeShit']
                            ),
                            Cell(
                                name="Head2",
                                type=FieldType.String,
                                value=list_element['Nullable']
                            ),
                            Cell(
                                name="Head3",
                                type=FieldType.String,
                                value=list_element['OtherShit']
                            )
                        ])
                    )
                )
                .add_field(Field(
                    type=FieldType.String,
                    name="Field1",
                    displayName="Поле категории 1",
                    value="просто строка",
                    modifications=[Modification.CurEUR]
                ))
        ) \
            .add_category(
                lambda c: c
                .set_properties(
                    name="Category2",
                    displayName="Категория 2",
                    modifications=[
                        Modification.Calendar, Modification.Help]
                )
                .add_field(Field(
                    type=FieldType.Price,
                    name="Field2",
                    displayName="Поле категории 2",
                    value=124124.54,
                    modifications=[Modification.CurEUR]
                ))
        )

        obj2 = deepcopy(obj1)

        obj2.set_publication_date(2)
        obj2.general[0].value += 50
        obj2.containers[0].entities[1].value = 'другая строка'
        obj2.containers[1].entities[0].value -= 50

        result = obj2.compare_many([obj1])

        expected = "{\"0\":{\"fn\":\"Category1\",\"ft\":\"Category\",\"fv\":{\"0\":{\"fn\":\"Table1\",\"ft\":\"Table\",\"fv\":{\"th\":{\"0\":{\"fn\":\"Head1\",\"fv\":\"Header 1\"},\"1\":{\"fn\":\"Head2\",\"fv\":\"Header 2\"},\"2\":{\"fn\":\"Head3\",\"fv\":\"Header 3\"}},\"tb\":{\"0\":{\"0\":{\"fn\":\"Head1\",\"ft\":\"Integer\",\"fv\":\"SomeShit1\"},\"1\":{\"fn\":\"Head2\",\"ft\":\"String\",\"fv\":\"Nullable1\"},\"2\":{\"fn\":\"Head3\",\"ft\":\"String\",\"fv\":1}},\"1\":{\"0\":{\"fn\":\"Head1\",\"ft\":\"Integer\",\"fv\":\"SomeShit2\"},\"1\":{\"fn\":\"Head2\",\"ft\":\"String\",\"fv\":\"Nullable2\"},\"2\":{\"fn\":\"Head3\",\"ft\":\"String\",\"fv\":2}},\"2\":{\"0\":{\"fn\":\"Head1\",\"ft\":\"Integer\",\"fv\":\"SomeShit2\"},\"1\":{\"fn\":\"Head2\",\"ft\":\"String\",\"fv\":\"Nullable2\"},\"2\":{\"fn\":\"Head3\",\"ft\":\"String\",\"fv\":2}}}},\"fdn\":\"Таблица 1\"},\"1\":{\"fn\":\"Field1\",\"ft\":\"String\",\"fv\":\"другая строка\",\"fdn\":\"Поле категории 1\",\"md\":[\"CurEUR\"],\"ch\":{\"1\":\"просто строка\",\"2\":\"другая строка\"}}},\"fdn\":\"Категория 1\",\"md\":[\"Calendar\",\"Help\"]},\"1\":{\"fn\":\"Category2\",\"ft\":\"Category\",\"fv\":{\"0\":{\"fn\":\"Field2\",\"ft\":\"Price\",\"fv\":124074.54,\"fdn\":\"Поле категории 2\",\"md\":[\"CurEUR\"],\"ch\":{\"1\":124124.54,\"2\":124074.54}}},\"fdn\":\"Категория 2\",\"md\":[\"Calendar\",\"Help\"]},\"general\":{\"0\":{\"fn\":\"General1\",\"ft\":\"DateTime\",\"fv\":5039516,\"fdn\":\"Основное поле 1\",\"ch\":{\"1\":5039466,\"2\":5039516}},\"customers\":[]}}"
        self.assertEqual(result.to_json(), expected)
コード例 #12
0
    def test_from_json_with_table(self):
        some_list = [
            dict(SomeShit="SomeShit1", Nullable="Nullable1", OtherShit=1),
            dict(SomeShit="SomeShit2", Nullable="Nullable2", OtherShit=2),
            dict(SomeShit="SomeShit2", Nullable="Nullable2", OtherShit=2)
        ]

        json1 = Root() \
            .add_general(Field(
                name="General1",
                type=FieldType.DateTime,
                value=5039466,
                displayName="Основное поле 1"
            )
        ) \
            .add_category(
                lambda c: c
                .set_properties(
                    name="Category1",
                    displayName="Категория 1",
                    modifications=[
                        Modification.Calendar, Modification.Help]
                )
                .add_table(
                    lambda t: t
                    .set_properties(
                        name="Table1",
                        displayName="Таблица 1"
                    )
                    .set_header(
                        lambda th: th
                        .add_cells([
                            Head(name="Head1", displayName="Header 1"),
                            Head(name="Head2", displayName="Header 2"),
                            Head(name="Head3", displayName="Header 3")
                        ]))
                    .add_rows(
                        some_list,
                        lambda list_element, row: row.add_cells([
                            Cell(
                                name="Head1",
                                type=FieldType.Integer,
                                value=list_element['SomeShit']
                            ),
                            Cell(
                                name="Head2",
                                type=FieldType.String,
                                value=list_element['Nullable']
                            ),
                            Cell(
                                name="Head3",
                                type=FieldType.String,
                                value=list_element['OtherShit']
                            )
                        ])
                    )
                )
                .add_field(Field(
                    type=FieldType.String,
                    name="Field1",
                    displayName="Поле категории 1",
                    value="просто строка",
                    modifications=[Modification.CurEUR]
                ))
        ) \
            .add_category(
                lambda c: c
                .set_properties(
                    name="Category2",
                    displayName="Категория 2",
                    modifications=[
                        Modification.Calendar, Modification.Help]
                )
                .add_field(Field(
                    type=FieldType.Price,
                    name="Field2",
                    displayName="Поле категории 2",
                    value=124124.54,
                    modifications=[Modification.CurEUR],
                    changes=dict([[1, "Старое поле категории 2"],
                                  [2, "Поле категории 2"]])
                ))
        ).to_json()

        json2 = Root().from_json(json1).to_json()
        self.assertEqual(json1, json2)
コード例 #13
0
 def test_from_json_tender_json_model(self):
     with open('./tests/files/tender_json_model.json',
               mode='r',
               encoding='utf-8') as f:
         root_json = f.read()
         root = Root().from_json(root_json)
コード例 #14
0
ファイル: test_root_to_json.py プロジェクト: So1itarius/Polus
    def test_to_json_with_table(self):
        some_list = [
            dict(SomeShit="SomeShit1", Nullable="Nullable1", OtherShit=1),
            dict(SomeShit="SomeShit2", Nullable="Nullable2", OtherShit=2),
            dict(SomeShit="SomeShit2", Nullable="Nullable2", OtherShit=2)
        ]

        result = Root() \
            .add_general(Field(
                name="General1",
                type=FieldType.DateTime,
                value=5039466,
                displayName="Основное поле 1"
            )
        ) \
            .add_category(
                lambda c: c
                .set_properties(
                    name="Category1",
                    displayName="Категория 1",
                    modifications=[
                        Modification.Calendar, Modification.Help]
                )
                .add_table(
                    lambda t: t
                    .set_properties(
                        name="Table1",
                        displayName="Таблица 1"
                    )
                    .set_header(
                        lambda th: th
                        .add_cells([
                            Head(name="Head1", displayName="Header 1"),
                            Head(name="Head2", displayName="Header 2"),
                            Head(name="Head3", displayName="Header 3")
                        ]))
                    .add_rows(
                        some_list,
                        lambda list_element, row: row.add_cells([
                            Cell(
                                name="Head1",
                                type=FieldType.Integer,
                                value=list_element['SomeShit']
                            ),
                            Cell(
                                name="Head2",
                                type=FieldType.String,
                                value=list_element['Nullable']
                            ),
                            Cell(
                                name="Head3",
                                type=FieldType.String,
                                value=list_element['OtherShit']
                            )
                        ])
                    )
                )
                .add_field(Field(
                    type=FieldType.String,
                    name="Field1",
                    displayName="Поле категории 1",
                    value="просто строка",
                    modifications=[Modification.CurEUR]
                ))
        ) \
            .add_category(
                lambda c: c
                .set_properties(
                    name="Category2",
                    displayName="Категория 2",
                    modifications=[
                        Modification.Calendar, Modification.Help]
                )
                .add_field(Field(
                    type=FieldType.Price,
                    name="Field2",
                    displayName="Поле категории 2",
                    value=124124.54,
                    modifications=[Modification.CurEUR],
                    changes=dict([[1, "Старое поле категории 2"],
                                  [2, "Поле категории 2"]])
                ))
        ) \
            .to_json()

        self.assertEqual(
            result,
            "{\"0\":{\"fn\":\"Category1\",\"ft\":\"Category\",\"fv\":{\"0\":{\"fn\":\"Table1\",\"ft\":\"Table\",\"fv\":{\"th\":{\"0\":{\"fn\":\"Head1\",\"fv\":\"Header 1\"},\"1\":{\"fn\":\"Head2\",\"fv\":\"Header 2\"},\"2\":{\"fn\":\"Head3\",\"fv\":\"Header 3\"}},\"tb\":{\"0\":{\"0\":{\"fn\":\"Head1\",\"ft\":\"Integer\",\"fv\":\"SomeShit1\"},\"1\":{\"fn\":\"Head2\",\"ft\":\"String\",\"fv\":\"Nullable1\"},\"2\":{\"fn\":\"Head3\",\"ft\":\"String\",\"fv\":1}},\"1\":{\"0\":{\"fn\":\"Head1\",\"ft\":\"Integer\",\"fv\":\"SomeShit2\"},\"1\":{\"fn\":\"Head2\",\"ft\":\"String\",\"fv\":\"Nullable2\"},\"2\":{\"fn\":\"Head3\",\"ft\":\"String\",\"fv\":2}},\"2\":{\"0\":{\"fn\":\"Head1\",\"ft\":\"Integer\",\"fv\":\"SomeShit2\"},\"1\":{\"fn\":\"Head2\",\"ft\":\"String\",\"fv\":\"Nullable2\"},\"2\":{\"fn\":\"Head3\",\"ft\":\"String\",\"fv\":2}}}},\"fdn\":\"Таблица 1\"},\"1\":{\"fn\":\"Field1\",\"ft\":\"String\",\"fv\":\"просто строка\",\"fdn\":\"Поле категории 1\",\"md\":[\"CurEUR\"]}},\"fdn\":\"Категория 1\",\"md\":[\"Calendar\",\"Help\"]},\"1\":{\"fn\":\"Category2\",\"ft\":\"Category\",\"fv\":{\"0\":{\"fn\":\"Field2\",\"ft\":\"Price\",\"fv\":124124.54,\"fdn\":\"Поле категории 2\",\"md\":[\"CurEUR\"],\"ch\":{\"1\":\"Старое поле категории 2\",\"2\":\"Поле категории 2\"}}},\"fdn\":\"Категория 2\",\"md\":[\"Calendar\",\"Help\"]},\"general\":{\"0\":{\"fn\":\"General1\",\"ft\":\"DateTime\",\"fv\":5039466,\"fdn\":\"Основное поле 1\"},\"customers\":[]}}"
        )
コード例 #15
0
    def get_json(self, model, lot, org):
        """
        Получение модели для рендера
        Использует sharedmodel модуль

        В данной модели обязательно присутствие:
        * general - основная информация
        * customer - заказчик

        В данной модели должно быть как можно больше информации о тендере
        (сроки поставки, вскрытия конвертов итп)

        """
        return Root()\
            .add_customer(
                Customer().set_properties(
                    max_price=model['maxPrice'],
                    guarantee_app=model['guaranteeApp'],
                    guarantee_contract=None,
                    customer_guid=model['customers'][0]['guid'],
                    customer_name=model['customers'][0]['name']
                )
            ).add_category(
                lambda c: c.set_properties(
                    name='ObjectInfo',
                    displayName='Информация об объекте закупки',
                ).add_table(
                    lambda t: t.set_properties(
                        name='Objects',
                        displayName='Объекты закупки'
                    ).set_header(
                        lambda th: th.add_cells([
                            Head(name='Name', displayName='Наименования товара, работы, услуги'),
                            Head(name='Count', displayName='Количество')
                        ])
                    ).add_rows(
                        [element for element in enumerate(lot['positions'], start=1)],
                        lambda el, row: row.add_cells([
                            Cell(
                                name='Name',
                                type=FieldType.String,
                                value=el[1].get('name').strip('"'),
                                modifications=[]
                            ),
                            Cell(
                                name='Count',
                                type=FieldType.String,
                                value=el[1].get('quantity'),
                                modifications=[]
                            )
                        ])
                    )
                )
            ).add_category(
                lambda c: c.set_properties(
                    name='procedureInfo',
                    displayName='Порядок размещения заказа',
                    modifications=[]
                ).add_field(
                    Field(
                        name='PublicationtDateTime',
                        displayName='Дата публикации',
                        value=model['publicationDateTime'],
                        type=FieldType.DateTime,
                        modifications=[Modification.Calendar]
                    )
                ).add_field(
                    Field(
                        name='AcceptOrderEndDateTime',
                        displayName='Дата и время окончания срока приема заявок',
                        value=model['submissionCloseDateTime'],
                        type=FieldType.DateTime,
                        modifications=[Modification.Calendar]
                    )
                ).add_field(
                    Field(
                        name='ScoringStartDateTime',
                        displayName='Дата и время вскрытия заявок',
                        value=self.tools.get_utc_epoch(
                            lot['order_view_date'][0], lot['order_view_date'][1]) if lot['order_view_date'] else None,
                        type=FieldType.DateTime,
                        modifications=[]
                    )
                ).add_field(        #
                    Field(
                        name='ScoringEndDateTime',
                        displayName='Дата подведения итогов',
                        value=self.tools.get_utc_epoch(
                            lot['scoring_date'][0], lot['scoring_date'][1]) if lot['scoring_date'] else None,
                        type=FieldType.DateTime,
                        modifications=[]
                    )
                ).add_field(
                    Field(
                        name='TradeDateTime',
                        displayName='Дата проведения торгов',
                        value=self.tools.get_utc_epoch(
                            lot['trade_date'][0], lot['trade_date'][1]) if lot['trade_date'] else None,
                        type=FieldType.Date,
                        modifications=[]
                    )
                )
            ).add_category(
                lambda c: c.set_properties(
                    name='Contacts',
                    displayName='Контактная информация',
                    modifications=[]
                ).add_field(Field(
                    name='Organization',
                    displayName='Организация',
                    value=org['name'],
                    type=FieldType.String,
                    modifications=[]
                    )
                ).add_field(Field(
                    name='ActualAddress',
                    displayName='Фактический адрес',
                    value=org['actual_address'],
                    type=FieldType.String,
                    modifications=[]
                    )
                ).add_field(Field(
                    name='PostAddress',
                    displayName='Почтовый адрес',
                    value=org['post_address'],
                    type=FieldType.String,
                    modifications=[]
                    )
                ).add_array(
                    lambda ar: ar.set_properties(
                        name='Contacts',
                        displayName='Контакты',
                        modifications=[Modification.HiddenLabel]
                    ).add_field(Field(
                        name='FIO',
                        displayName='ФИО',
                        value=org['fio'],
                        type=FieldType.String,
                        modifications=[Modification.HiddenLabel]
                        )
                    ).add_field(Field(
                        name='Phone',
                        displayName='Телефон',
                        value=org['phone'],
                        type=FieldType.String,
                        modifications=[]
                        )
                    ).add_field(Field(
                        name='Email',
                        displayName='Электронная почта',
                        value=org['email'],
                        type=FieldType.String,
                        modifications=[Modification.Email]
                        )
                    )
                )
            ).add_general(
                lambda f: f.set_properties(
                    name='Quantity',
                    displayName='Количество поставляемого товара/объем выполняемых работ/оказываемых услуг',
                    value=lot['quantity'],
                    type=FieldType.String,
                    modifications=[]
                )
            ).add_general(
                lambda f: f.set_properties(
                    name='deliveryPlace',
                    displayName='Место поставки товаров оказания услуг',
                    value=lot['delivery_place'] if lot['delivery_place'] else '',
                    type=FieldType.String,
                    modifications=[]
                )
            ).add_general(
                lambda f: f.set_properties(
                    name='PaymentTerms',
                    displayName='Условия оплаты и поставки товаров/выполнения работ/оказания услуг',
                    value=lot['payment_terms'] if lot['payment_terms'] else '',
                    type=FieldType.String,
                    modifications=[]
                )
            ).to_json()
コード例 #16
0
ファイル: mapper.py プロジェクト: So1itarius/Polus
 def get_json(self, model, contacts, organization):
     return Root() \
         .add_general(
         Field(
             name="MaxPrice",
             type=FieldType.Price,
             value=model['maxPrice'],
             displayName="Цена контракта"
           )
          ) \
         .add_customer(
         Customer().set_properties(
             max_price=None,
             guarantee_app=None,
             guarantee_contract=None,
             customer_guid=model['customers'][0]['guid'],
             customer_name=model['customers'][0]['name']
         )
         ) \
         .add_category(
          lambda c: c.set_properties(
             name='ProcedureInfo',
             displayName='Порядок размещения заказа'
         ).add_field(Field(
             name='AcceptOrderEndDateTime',
             displayName='Дата окончания приема заявок',
             value=model['submissionCloseDateTime'],
             type=FieldType.DateTime,
             modifications=[Modification.Calendar]
           ))
         ) \
         .add_category(
         lambda c: c.set_properties(
             name='Contacts',
             displayName='Контактная информация'
         ).add_field(Field(
             name='Organization',
             displayName='Организация',
             value=organization,
             type=FieldType.String
         )).add_array(
             lambda ar: ar.set_properties(
                 name='Contacts',
                 displayName='Контакты',
                 modifications=[Modification.HiddenLabel]
             ).add_field(Field(
                 name='FIO',
                 displayName='ФИО',
                 value=contacts[0]['name'],
                 type=FieldType.String,
                 modifications=[Modification.HiddenLabel]
             )).add_field(Field(
                 name='Phone',
                 displayName='Телефон',
                 value=contacts[0]['phone'],
                 type=FieldType.String,
                 modifications=[]
             )).add_field(Field(
                 name='Email',
                 displayName='Электронная почта',
                 value=contacts[0]['email'],
                 type=FieldType.String,
                 modifications=[]
             ))
         )
        ) \
         .to_json()