Beispiel #1
0
def properties(self):
    "Displays a generic edit form based on the object's schema"
    sLang = context.request.get_lang()

    user = context.user
    iUserRole = permsresolver.get_access(self, user)
    readonly = (iUserRole == permsresolver.READER)
    admin = (iUserRole == permsresolver.COORDINATOR)
    modified = date.Date(self.modified)

    params = {
        'URI': self.id,
        'ICON': self.__image__,
        'TITLE': xml.xml_encode(self.displayName.value),
        'MODIFIED': modified.format(DATES_FORMAT, sLang),
        'MODIFIED_BY': xml.xml_encode(self.modifiedBy),
        'CONTENTCLASS': self.contentclass,
        'PROPERTIES': [],
        'EXTRA_TABS': [],
        'ADMIN': admin,
        'ROLES_INHERITED': str(self.inheritRoles).lower(),
        'ACTION_DISABLED': str(readonly).lower(),
        'METHOD': 'update'
    }
    # inspect item properties
    for attr_name in self.__props__:
        attr = getattr(self, attr_name)
        if isinstance(attr, datatypes.DataType):
            control, tab = \
                _getControlFromAttribute(self, attr_name, attr, readonly)
            params['PROPERTIES'].append(control)
            params['EXTRA_TABS'].append(tab)

    return params
Beispiel #2
0
def getInfo(self):
    "Returns info about the container's contents"
    sLang = context.request.get_lang()
    lstChildren = []
    children = self.get_children()
    for child in children:
        obj = {
            'id': child.id,
            'cc': child.contentclass,
            'image': child.__image__,
            'displayName': child.displayName.value,
            'isCollection': child.isCollection,
            'modified': date.Date(child.modified)
        }
        if hasattr(child, 'size'):
            obj['size'] = child.size
        lstChildren.append(obj)

    containment = []
    for contained in self.containment:
        image = misc.get_rto_by_name(contained).__image__
        if not type(image) == str:
            image = ''
        localestring = resources.get_resource(contained, sLang)
        containment.append([localestring, contained, image])

    return {
        'displayName': self.displayName.value,
        'path': misc.get_full_path(self),
        'parentid': self.parentid,
        'iscollection': self.isCollection,
        'containment': containment,
        'user_role': permsresolver.get_access(self, context.user),
        'contents': lstChildren
    }
Beispiel #3
0
def properties(self):
    "Displays the deleted item's properties form"
    sLang = context.request.get_lang()
    modified = date.Date(self.modified)
    return {
        'ICON': self.__image__,
        'NAME': xml.xml_encode(self.originalName),
        'LOC': xml.xml_encode(self.originalLocation),
        'MODIFIED': modified.format(baseitem.DATES_FORMAT, sLang),
        'MODIFIED_BY': xml.xml_encode(self.modifiedBy),
        'CONTENTCLASS': self.get_deleted_item().contentclass}
Beispiel #4
0
def getInfo(self):
    "Returns info about its children"
    lstChildren = []
    children = self.get_children()
    for child in children:
        obj = {
            'id': child.id,
            'image': child.__image__,
            'displayName': child.originalName,
            'origloc': child.originalLocation,
            'modified': date.Date(child.modified)
        }
        if hasattr(child, 'size'):
            obj['size'] = child.size
        lstChildren.append(obj)
    return {'displayName': self.displayName.value, 'contents': lstChildren}
Beispiel #5
0
def properties(self):
    "Displays the group's properties form"
    sLang = context.request.get_lang()

    user = context.user
    iUserRole = permsresolver.get_access(self, user)
    readonly = (iUserRole == permsresolver.READER)
    admin = (iUserRole == permsresolver.COORDINATOR)

    params = {
        'ID': self.id,
        'ICON': self.__image__,
        'SELECT_FROM_POLICIES': 'policies',
        'POLICIES_REL_CC': '|'.join(self.policies.relCc),
        'NAME': xml.xml_encode(self.displayName.value),
        'DESCRIPTION': xml.xml_encode(self.description.value),
        'MODIFIED': date.Date(self.modified).format(baseitem.DATES_FORMAT,
                                                    sLang),
        'MODIFIED_BY': xml.xml_encode(self.modifiedBy),
        'CONTENTCLASS': self.contentclass,
        'SELECT_FROM': self.parentid,
        'REL_CC': '|'.join(self.members.relCc),
        'READONLY': str(readonly).lower(),
        'ADMIN': admin,
        'ROLES_INHERITED': str(self.inheritRoles).lower()
    }

    members_options = []
    members = self.members.get_items()
    for user in members:
        members_options += [
            xml.xml_encode(user.__image__), user.id,
            xml.xml_encode(user.displayName.value)
        ]
    params['MEMBERS'] = ';'.join(members_options)

    policies_options = []
    policies = self.policies.get_items()
    for policy in policies:
        policies_options += [
            xml.xml_encode(policy.__image__), policy.id,
            xml.xml_encode(policy.displayName.value)
        ]
    params['POLICIES'] = ';'.join(policies_options)

    return params
Beispiel #6
0
def getInfo(self):
    "Retutns info about the category's contents"
    # call super method for getting the container's info
    info = s_getInfo(self)

    lstObjects = []
    category_objects = self.category_objects.get_items()
    for item in category_objects:
        obj = {'id': item.id,
               'image': item.__image__,
               'displayName': item.displayName.value,
               'isCollection': item.isCollection,
               'modified': date.Date(item.modified)}
        if hasattr(item, 'size'):
            obj['size'] = item.size
        lstObjects.append(obj)
    info['contents'].extend(lstObjects)

    return info
Beispiel #7
0
def properties(self):
    "Displays the application's properties form"
    sLang = context.request.get_lang()
    user = context.user
    iUserRole = permsresolver.get_access(self, user)
    readonly = (iUserRole == permsresolver.READER)
    admin = (iUserRole == permsresolver.COORDINATOR)
    modified = date.Date(self.modified)
    return {
        'ID': self.id,
        'IMG': self.__image__,
        'NAME': xml.xml_encode(self.displayName.value),
        'DESCRIPTION': xml.xml_encode(self.description.value),
        'ICON': self.icon.value,
        'LAUNCH_URL': xml.xml_encode(self.launchUrl.value),
        'MODIFIED': modified.format(baseitem.DATES_FORMAT, sLang),
        'MODIFIED_BY': xml.xml_encode(self.modifiedBy),
        'CONTENTCLASS': self.contentclass,
        'ADMIN': admin,
        'ROLES_INHERITED': str(self.inheritRoles).lower(),
        'READONLY': str(readonly).lower()}
Beispiel #8
0
 def default(self, obj):
     if isinstance(obj, objectSet.ObjectSet):
         return list(obj)
     elif isinstance(obj,
                     (systemObjects.GenericItem, systemObjects.Composite)):
         rpc_object = {}
         for attr in list(obj.__props__.keys()) + self.default_props:
             try:
                 oAttr = getattr(obj, attr)
             except AttributeError:
                 continue
             if isinstance(oAttr, datatypes.ExternalAttribute):
                 rpc_object[attr] = '[EXTERNAL STREAM]'
             elif isinstance(oAttr, datatypes.ReferenceN):
                 rpc_object[attr] = [{
                     'id': x._id,
                     'displayName': x.displayName.value
                 } for x in oAttr.get_items()]
             elif isinstance(oAttr, datatypes.Reference1):
                 item_ref = oAttr.get_item()
                 rpc_object[attr] = {'id': oAttr.value}
                 if item_ref is not None:
                     rpc_object[attr]['displayName'] = \
                         item_ref.displayName.value
             elif isinstance(oAttr, datatypes.Date):
                 rpc_object[attr] = oAttr
             elif isinstance(oAttr, datatypes.DataType):
                 rpc_object[attr] = oAttr.value
             elif attr in ('created', 'modified'):
                 rpc_object[attr] = date.Date(oAttr)
             else:
                 rpc_object[attr] = oAttr
         return rpc_object
     elif isinstance(obj, date.Date):
         return obj.to_iso_8601()
     else:
         return obj