Ejemplo n.º 1
0
    def conv_str_json_test(cls, arg_lst):

        res = Res_proc(res=False)

        obj_appl = jsonTest
        obj_modl = None
        for item in arg_lst[1].split('#'):
            _error = None
            if obj_modl:
                if hasattr(arg_obj_appl, item):
                    obj_modl = getattr(obj_modl, item)
                else:
                    _error = True
            else:
                if hasattr(obj_appl, item):
                    obj_modl = getattr(obj_appl, item)
                else:
                    _error = True

            if _error:
                res.error = 'Атрибут %s не найден' % item
                return res

        res.res = True
        res.res_obj = obj_modl

        return res
Ejemplo n.º 2
0
    def get_profil_user(cls, user):
        """ Создание dict профиля """

        from app import Ext_dict
        from .serv_sprstatus import Com_proc_sprstatus

        structDef = Struct_default_AdvUser

        res_proc = Res_proc()

        s_err = 'get_profil_user'

        try:
            user = getUser(user)
            if user is None:
                raise ErrorRun_impl(
                    '{0} нет данных для аргумента user'.format(s_err))

            res_proc.any_str = user.username
            type_status = type_status_user(user)
            res_proc.res_obj = type_status
            """
            imgphoto    = self.imgphoto,
                full_name   = self.full_name,
                status      = self.status,
                idcomp      = self.idcomp
            """
            if user.is_superuser:
                param = dict(
                    imgphoto=cls.get_path_photo(user),
                    full_name='Супер-пользоатель',
                    status=Com_proc_sprstatus.get_status_suadm().strIdent,
                    idcomp=structDef.idcomp)

                _dict = dict(btn_upd=False, param=param, prof=[])
                res_proc.res_dict = _dict
                res_proc.res = True

                return res_proc

            # возврат нулевого статуса
            if not type_status:
                param = dict(
                    imgphoto=cls.get_path_photo('suadm'),
                    full_name='Пользователь не определен',
                    status=Com_proc_sprstatus.get_status_notstatus().strIdent,
                    idcomp=structDef.idcomp)

                _dict = dict(btn_upd=False, param=param, prof=[])

                res_proc.res_obj.levelperm = 20  # чтобы отображение стало как у клиента
                res_proc.res_dict = _dict
                res_proc.res = True

                return res_proc

            # ------------- обработка данных профиля -----------------
            status_strIdent = type_status.strIdent  # structDef.conv_status_into_str(type_status.statusID)
            dict_head = cls.get_dataHeader()
            dict_cons = cls.get_dataCons(user)
            dict_user = cls.get_advData(user)
            dict_user['sendMes'] = structDef.conv_send_mes(
                dict_user.get('sendMes'))

            if dict_cons is None:
                dict_cont = dict_head

            Ext_dict.CL_modify_empty(dict_head)
            Ext_dict.CL_modify_empty(dict_cons)
            Ext_dict.CL_modify_empty(dict_user)

            param = dict(imgphoto=cls.get_path_photo(user),
                         full_name=dict_user.get('full_name'),
                         status=status_strIdent,
                         idcomp=dict_user.get('idcomp') or structDef.idcomp)

            arrayProf = [dict(val=user.username, str='Логин:')]
            if type_status.levelperm < 30:
                arrayProf += [dict(val=dict_user.get('pswcl'), str='Пароль:')]

            # Обработка гостВхода
            if type_status.levelperm < 20:  # гостевой вход или клиент сайта

                arrayProf += [
                    dict(val=dict_cons.get('full_name') or structDef.full_name,
                         str='Личн. консультант:',
                         idrow='parentData'),
                    dict(val=dict_cons.get('phone') or structDef.phone,
                         str='Тел. личн. консультанта:')
                ]

                arrayProf += [
                    dict(val=dict_head.get('full_name') or structDef.full_name,
                         str='Админ. проекта:',
                         idrow='parentData'),
                    dict(val=dict_head.get('phone') or structDef.phone,
                         str='Телефон адмПроекта:')
                ]

            else:  # структура профиля для менеджеров и рукГрупп

                arrayProf += [
                    dict(val=dict_user.get('phone') or structDef.phone,
                         str='Телефон:'),
                    dict(val=dict_user.get('email') or structDef.email,
                         str='email:'),
                    dict(val=dict_user.get('sendMes'), str='Получать сообщ.:'),
                    dict(val=dict_user.get('ageGroup') or structDef.ageGroup,
                         str='ВозрГруппа:'),
                    dict(val=structDef.conv_pol(dict_user.get('pol')),
                         str='Пол:'),
                ]

                if type_status.levelperm > 20:
                    arrayProf += [
                        dict(val=dict_user.get('pswcl') or structDef.pswcl,
                             str='Пароль клиента:',
                             idrow='parentData'),
                        dict(val=dict_user.get('logincl') or structDef.logincl,
                             str='Логин клиента:')
                    ]

                if type_status.levelperm < 100:
                    arrayProf += [
                        dict(val=dict_cons.get('full_name')
                             or structDef.full_name,
                             str='Консультант:',
                             idrow='parentData'),
                        dict(val=dict_cons.get('phone') or structDef.phone,
                             str='Тел. консультанта:'),
                        dict(val=dict_cons.get('email') or structDef.email,
                             str='email консультанта:')
                    ]

                if type_status.levelperm in (40, 70):
                    if type_status.levelperm == 40:
                        arrayProf += [
                            dict(val=dict_user.get('limitcon')
                                 or structDef.limitcon,
                                 str='Лимит подкл.:')
                        ]
                    else:
                        arrayProf += [
                            dict(val=dict_user.get('limitcon')
                                 or structDef.limitcon,
                                 str='Лимит подкл.:'),
                            dict(val=dict_user.get('limitcon40')
                                 or structDef.limitcon,
                                 str='Подкл. рукГр:'),
                            dict(val=dict_user.get('limitcon70')
                                 or structDef.limitcon,
                                 str='Подкл. максУровень:')
                        ]

            res_proc.res_dict = dict(btn_upd=True, param=param, prof=arrayProf)

            res_proc.res = True
            return res_proc

        except Exception as ex:
            res_proc.error = ex

        return res_proc