def new(self):
    "Displays a generic form for creating a new object"
    context = HttpContext.current()
        
    sCC = context.request.queryString['cc'][0]
    oNewItem = misc.getCallableByName(sCC)()
    
    params = {
        'CC': sCC,
        'URI': context.request.getRootUrl() + '/' + self.id,
        'ICON': oNewItem.__image__,
        'PROPERTIES_TAB': '',
        'EXTRA_TABS': '',
        'SECURITY_TAB': baseitem._getSecurity(self, context.user, True)
    }
    
    # inspect item properties
    sProperties = ''
    for attr_name in oNewItem.__props__:
        attr = getattr(oNewItem, attr_name)
        if isinstance(attr, datatypes.DataType):
            control, tab = baseitem._getControlFromAttribute(oNewItem,
                                                             attr_name,
                                                             attr,
                                                             False,
                                                             True)
            sProperties += control
            params['EXTRA_TABS'] += tab
    
    params['PROPERTIES'] = sProperties
    
    return params
def new(self):
    "Displays a generic form for creating a new object"
    sCC = context.request.queryString['cc'][0]
    oNewItem = misc.get_rto_by_name(sCC)()
    role = permsresolver.get_access(self, context.user)

    params = {
        'CC': sCC,
        'URI': self.id,
        'TITLE': '@@CREATE@@ "@@%s@@"' % sCC,
        'ICON': oNewItem.__image__,
        'PROPERTIES': [],
        'EXTRA_TABS': [],
        'ADMIN': role == permsresolver.COORDINATOR,
        'ROLES_INHERITED': 'true',
        'ACTION_DISABLED': 'false',
        'METHOD': 'create'}

    # inspect item properties
    for attr_name in oNewItem.__props__:
        attr = getattr(oNewItem, attr_name)
        if isinstance(attr, datatypes.DataType):
            control, tab = baseitem._getControlFromAttribute(oNewItem,
                                                             attr_name,
                                                             attr,
                                                             False,
                                                             True)
            params['PROPERTIES'].append(control)
            params['EXTRA_TABS'].append(tab)

    return params
Exemple #3
0
def new(self):
    "Displays a generic form for creating a new object"
    sCC = context.request.queryString['cc'][0]
    oNewItem = misc.get_rto_by_name(sCC)()
    role = permsresolver.get_access(self, context.user)

    params = {
        'CC': sCC,
        'URI': self.id,
        'TITLE': '@@CREATE@@ "@@%s@@"' % sCC,
        'ICON': oNewItem.__image__,
        'PROPERTIES': [],
        'EXTRA_TABS': [],
        'ADMIN': role == permsresolver.COORDINATOR,
        'ROLES_INHERITED': 'true',
        'ACTION_DISABLED': 'false',
        'METHOD': 'create'
    }

    # inspect item properties
    for attr_name in oNewItem.__props__:
        attr = getattr(oNewItem, attr_name)
        if isinstance(attr, datatypes.DataType):
            control, tab = baseitem._getControlFromAttribute(
                oNewItem, attr_name, attr, False, True)
            params['PROPERTIES'].append(control)
            params['EXTRA_TABS'].append(tab)

    return params