def _des_from_db_info_child(child_parents_dict) -> Children:
     return Children(id=child_parents_dict['id'],
                     name=child_parents_dict['children_name'],
                     surname=child_parents_dict['children_surname'],
                     date_born=child_parents_dict['children_date_born'],
                     parents=ParentsDeserializer.deserialize(
                         child_parents_dict, DES_FROM_DB_INFO_PARENTS))
 def _des_from_db_info_child_with_parents(row_dict) -> Children:
     return Children(id=row_dict['children_id'],
                     name=row_dict['children_name'],
                     surname=row_dict['children_surname'],
                     date_born=row_dict['children_date_born'],
                     parents=Parents(
                         id=row_dict['children_parents_id'],
                         account_main=AccountMain(
                             id=row_dict['parents_account_main_id'])))
 def _des_from_db_all_children(list_children) -> List[Children]:
     return [
         Children(id=list_children[i]['children_id'],
                  name=list_children[i]['children_name'],
                  surname=list_children[i]['children_surname'],
                  date_born=list_children[i]['children_date_born'],
                  parents=Parents(id=list_children[i]['parents_id']))
         for i in range(len(list_children))
     ]
 def _des_from_db_get_list_requests(data) -> List[RequestToOrganisation]:
     return [
         RequestToOrganisation(
             id=data[i]['request_id'],
             parents=ParentsDeserializer.deserialize(data[i], DES_FROM_DB_INFO_PARENTS),
             events=EventDeserializer.deserialize(data[i], DES_FROM_DB_INFO_EVENTS),
             children=Children(id=data[i]['request_children_id']),
             status=data[i]['request_status']
         )
         for i in range(len(data))
     ]
    def wrapper(*args, auth_account_main_id: int, parent_id: int, **kwargs):
        children = Children(parents=Parents(
            id=parent_id, account_main=AccountMain(id=auth_account_main_id)))

        list_children, err = ChildrenService.get_children_by_parents_id(
            children)
        if err:
            return json.dumps(err)
        response = func(*args,
                        list_children=list_children,
                        parent_id=list_children[0].parents.id,
                        **kwargs)
        return response
def request_add_child(parent_id: int, auth_account_main_id: int,
                      children_id: int, events_id: int):
    if request.method == 'POST':
        if not events_id:
            return json.dumps('Выберите событие')
        request_to_organisation = RequestToOrganisation(
            children=Children(id=children_id),
            parents=Parents(id=parent_id,
                            account_main=AccountMain(id=auth_account_main_id)),
            events=Events(id=events_id))

        request_to_organisation, err = RequestToOrganisationService.make_request(
            request_to_organisation)
        if err:
            return json.dumps(err)
        return json.dumps(get_response_make_request(request_to_organisation))
def detail_child(result_sort_statistic: datetime.date,
                 result_sort_focus: datetime.date, parent_id: int,
                 auth_account_main_id: int, children_id: int):
    if request.method == 'GET':
        events_child = EventsChild(children_organisation=ChildrenOrganisation(
            children=Children(id=children_id)))
        activity_child, err = EventsChildService.get_by_children_id(
            events_child)
        if err:
            return json.dumps(err)

        statistic_dict, err = StatisticService.get_result_statistic(
            result_sort_statistic, children_id)
        if err:
            return None, err

        focus_dict, err = StatisticService.get_result_focus(
            result_sort_focus, children_id)
        if err:
            return None, err

        return json.dumps(
            get_response_detail_activity_children(activity_child))
def index(parent_id: int, auth_account_main_id: int):
    if request.method == 'POST':
        errors = AddChildSchema().validate(
            dict(name=request.form['name'],
                 surname=request.form['surname'],
                 date_born=request.form['date_born']))
        if errors:
            return json.dumps(errors)
        children = ChildrenDeserialize.deserialize(request.form,
                                                   DES_FOR_ADD_CHILD)
        children.parents = Parents(
            id=parent_id, account_main=AccountMain(id=auth_account_main_id))
        children, err = ChildrenService.add_child(children)
        if err:
            return json.dumps(err)
        return json.dumps(get_response_add_children(children))
    elif request.method == 'GET':
        children = Children(parents=Parents(
            id=parent_id, account_main=AccountMain(id=auth_account_main_id)))
        list_children, err = ChildrenService.get_children_by_parents_id(
            children)
        if err:
            return json.dumps(err)
        return json.dumps(get_response_get_list_child(list_children))
 def _des_from_db_info_detail_child(row_dict) -> Children:
     return Children(id=row_dict['children_id'],
                     name=row_dict['children_name'],
                     surname=row_dict['children_surname'],
                     date_born=row_dict['children_date_born'],
                     parents=Parents(id=row_dict['children_parents_id']))
 def _des_from_db_info_children(child_dict) -> Children:
     return Children(id=child_dict['children_id'],
                     name=child_dict['children_name'],
                     surname=child_dict['children_surname'],
                     date_born=child_dict.get('children_date_born'))
 def _des_for_add_child(child_dict) -> Children:
     return Children(name=child_dict.get('name'),
                     surname=child_dict.get('surname'),
                     date_born=child_dict.get('date_born'))