Beispiel #1
0
 def content_type(self):
     """Gets a value that specifies the content type of the list item."""
     from office365.sharepoint.contenttypes.content_type import ContentType
     return self.properties.get(
         "ContentType",
         ContentType(self.context,
                     ResourcePath("ContentType", self.resource_path)))
Beispiel #2
0
    def get_by_id(self, contentTypeId):
        """
        Returns the content type with the given identifier from the collection.
        If a content type with the given identifier is not found in the collection, the server MUST return null.

        :param str contentTypeId: A hexadecimal value representing the identifier of a content type.
        """
        return ContentType(self.context, ResourcePathServiceOperation("GetById", [contentTypeId], self.resource_path))
Beispiel #3
0
    def add_available_content_type(self, contentTypeId):
        """Adds the specified content type to the content type collection.

        :param str contentTypeId: Specifies the identifier of the content type to be added to the content type
            collection. It MUST exist in the web's available content types.

        """
        ct = ContentType(self.context)
        self.add_child(ct)
        qry = ServiceOperationQuery(self, "AddAvailableContentType", [contentTypeId], None, None, ct)
        self.context.add_query(qry)
        return ct
    def get_by_name(self, name):
        """
        Returns the content type with the given name from the collection.

        :param str name: Content type name
        """
        return_type = ContentType(self.context)
        self.add_child(return_type)

        def _after_get_by_name(col):
            if len(col) != 1:
                message = "Content type not found or ambiguous match found for name: {0}".format(
                    name)
                raise ValueError(message)
            return_type.set_property("StringId",
                                     col[0].get_property("StringId"))

        self.filter("Name eq '{0}'".format(name))
        self.context.load(self, after_loaded=_after_get_by_name)
        return return_type
    def add(self, content_type_info):
        """Adds a new content type to the collection and returns a reference to the added SP.ContentType.

        :param ContentTypeCreationInformation content_type_info: Specifies properties that is to be used to
            construct the new content type.
        """
        ct = ContentType(self.context)
        self.add_child(ct)
        ct_json = content_type_info.to_json()
        for k, v in ct_json.items():
            if k == "Id":
                ct.set_property(k, {"StringValue": v}, True)
            else:
                ct.set_property(k, v, True)
        qry = CreateEntityQuery(self, ct, ct)
        self.context.add_query(qry)
        return ct