Example #1
0
def rolesList(context,
              main=None,
              add=None,
              filterinfo=None,
              session=None,
              params=None,
              curvalue=None,
              startswith=None,
              firstrecord=None,
              recordcount=None):
    u'''Функция list для селектора выбора ролей. '''

    roles = RolesCursor(context)
    roles.setFilter(
        'id', """!'editor'&!'reader'&@%s'%s'%%""" %
        ("%" * (not startswith), curvalue.replace("'", "''")))
    roles.orderBy('id')
    roles.limit(firstrecord, recordcount)

    recordList = ArrayList()
    if roles.tryFindSet():
        while True:
            rec = DataRecord()
            rec.setId(unicode(roles.id))
            rec.setName(roles.id)
            recordList.add(rec)
            if not roles.nextInSet():
                break

    return ResultSelectorData(recordList, 0)
Example #2
0
def rolesList(context,
              main=None,
              add=None,
              filterinfo=None,
              session=None,
              params=None,
              curvalue="",
              startswith=False,
              firstrecord=0,
              recordcount=None):
    u'''Функция list селектора типа элемента. '''
    # raise Exception(curvalue)
    recordList = ArrayList()
    roles = RolesCursor(context)
    roles.setFilter(
        'description',
        "@%s'%s'%%" % ("%" * (not startswith), curvalue.replace("'", "''")))
    roles.orderBy('id')
    roles.limit(firstrecord, recordcount)
    if roles.tryFindSet():
        while True:
            rec = DataRecord()
            rec.setId(roles.id)
            rec.setName(
                '%s - %s' %
                (roles.id, roles.description if roles.description else ''))
            recordList.add(rec)
            if not roles.nextInSet():
                break
    return ResultSelectorData(recordList, 0)
Example #3
0
def gridMeta(context, main=None, add=None, filterinfo=None, session=None, elementId=None):
    u'''Функция получения настроек грида. '''

    # Курсор таблицы directories
    roles = RolesCursor(context)
    # Вычисляем количества записей в таблице
    specialRoles = ["!'editor'", "!'reader'"]
    roles.setFilter("id", '&'.join(specialRoles))
    totalcount = roles.count()
    # Заголовок таблицы
    header = "Роли"
    _header = {"id": [u"Роль"],
               "description": [u"Описание"],
               }

    # Определяем список полей таблицы для отображения
    settings = {}
    settings["gridsettings"] = {"columns": {"col": []},
                                "properties": {"@pagesize":"50",
                                               "@gridWidth": "100%",
                                               "@gridHeight": getGridHeight(session, numberOfGrids=1.6, delta=35),
                                               "@totalCount": totalcount,
                                               "@profile": "default.properties"},
                                "labels": {"header": header}
                                }
    # Добавляем поля для отображения в gridsettings
    settings["gridsettings"]["columns"]["col"].append({"@id": _header["id"][0],
                                                       "@width": "80px"})
    settings["gridsettings"]["columns"]["col"].append({"@id": _header["description"][0],
                                                       "@width": "400px"})

    res = XMLJSONConverter.jsonToXml(json.dumps(settings))
    return JythonDTO(None, res)
Example #4
0
def gridData(context, main=None, add=None, filterinfo=None,
             session=None, elementId=None, sortColumnList=None, firstrecord=None, pagesize=None):
    u'''Функция получения данных для грида. '''

    # Создание экземпляра курсора разрешения
    roles = RolesCursor(context)
    # Определяем переменную для JSON данных
    data = {"records":{"rec":[]}}
    # Проходим по таблице и заполняем data
    specialRoles = ["!'editor'", "!'reader'"]

    roles.setFilter("id", '&'.join(specialRoles))
    if sortColumnList:
        sortName = toHexForXml(sortColumnList[0].id)
        sortType = unicode(sortColumnList[0].sorting).lower()
    else:
        sortName = None

    _header = {"roleId": ["~~id"],
               "id": [u"Роль"],
               "description": [u"Описание"],

               "properties": [u"properties"]
               }
    for column in _header:
        _header[column].append(toHexForXml(_header[column][0]))
        if sortName == _header[column][1]:
            roles.orderBy("%s %s" % (column, sortType))

    roles.limit(firstrecord - 1, pagesize)
    if roles.tryFindSet():
        while True:
            rolesDict = {}
            rolesDict[_header["roleId"][1]] = roles.id
            for column in [x for x in _header.keys() if x not in ("roleId", "properties")]:
                rolesDict[_header[column][1]] = getattr(roles, column) or ''

            rolesDict['properties'] = {"event": {"@name":"row_single_click",
                                                 "action": {"#sorted": [{"main_context": 'current'},
                                                                        {"datapanel":{'@type':"current",
                                                                                      '@tab':"current",
                                                                                      "element":{"@id":"id_perm_roles_grid"}
                                                                                      }
                                                                         }]
                                                            }
                                                 }
                                       }
            data["records"]["rec"].append(rolesDict)
            if not roles.nextInSet():
                break

    res = XMLJSONConverter.jsonToXml(json.dumps(data))
    return JythonDTO(res, None)
Example #5
0
def rolesCount(context,
               main=None,
               add=None,
               filterinfo=None,
               session=None,
               params=None,
               curvalue="",
               startswith=False):
    roles = RolesCursor(context)
    roles.setFilter(
        'description',
        "@%s'%s'%%" % ("%" * (not startswith), curvalue.replace("'", "''")))
    count = roles.count()
    # raise Exception(count)
    return ResultSelectorData(None, count)
Example #6
0
def rolesCount(context,
               main=None,
               add=None,
               filterinfo=None,
               session=None,
               params=None,
               curvalue=None,
               startswith=None):
    u'''Функция count для селектора выбора ролей. '''

    #specialRoles = ["!'editor'", "!'reader'"]
    roles = RolesCursor(context)
    roles.setFilter(
        'id', """!'editor'&!'reader'&@%s'%s'%%""" %
        ("%" * (not startswith), curvalue.replace("'", "''")))

    count = roles.count()

    return ResultSelectorData(None, count)