Skip to content

Commit

Permalink
#722 fix for addressing resource, new types in publishing namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
vgrem committed Sep 3, 2023
1 parent 89d4e89 commit 0dd6039
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 7 deletions.
8 changes: 4 additions & 4 deletions examples/sharepoint/pages/get_page_content.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from office365.sharepoint.client_context import ClientContext
from tests import test_client_credentials, test_site_url
ctx = ClientContext(test_site_url).with_credentials(test_client_credentials)
from tests import test_client_credentials, test_team_site_url

file = ctx.web.get_file_by_server_relative_path("/SitePages/Home.aspx")
ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials)

file = ctx.web.get_file_by_server_relative_path("SitePages/Home.aspx")
file_item = file.listItemAllFields.select(["CanvasContent1", "LayoutWebpartsContent"]).get().execute_query()
print(file_item.properties.get("CanvasContent1"))

8 changes: 8 additions & 0 deletions office365/sharepoint/publishing/base_custom_property.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from office365.sharepoint.base_entity import BaseEntity


class BaseCustomProperty(BaseEntity):

@property
def entity_type_name(self):
return "Microsoft.SharePoint.Publishing.RestOnly.BaseCustomProperty"
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from office365.sharepoint.base_entity import BaseEntity


class StructuralNavigationCacheWrapper(BaseEntity):

@property
def entity_type_name(self):
return "SP.Publishing.Navigation.StructuralNavigationCacheWrapper"
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from office365.sharepoint.base_entity import BaseEntity


class PageCopyResponse(BaseEntity):

@property
def entity_type_name(self):
return "Microsoft.SharePoint.Publishing.PageCopyWithAssets.PageCopyResponse"
5 changes: 4 additions & 1 deletion office365/sharepoint/publishing/pages/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@
class SharePagePreviewByEmailFieldsData(ClientValue):

def __init__(self, message=None, recipient_emails=None):
"""
:param str message:
:param list[str] recipient_emails:
"""
self.message = message
self.recipientEmails = StringCollection(recipient_emails)

Expand Down Expand Up @@ -150,7 +154,6 @@ def publish(self):
def schedule_publish(self, publish_start_date):
"""
Schedules the page publication for a certain date
:param datetime.datetime publish_start_date: The pending publication scheduled date
"""
payload = SitePageFieldsData(publish_start_date=publish_start_date)
Expand Down
8 changes: 8 additions & 0 deletions office365/sharepoint/publishing/pages/reposts/metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from office365.sharepoint.publishing.pages.metadata import SitePageMetadata


class RepostPageMetadata(SitePageMetadata):

@property
def entity_type_name(self):
return "SP.Publishing.RepostPageMetadata"
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@


class PersonMagazine(BaseEntity):
pass

@property
def entity_type_name(self):
return "SP.Publishing.PersonMagazine"
4 changes: 3 additions & 1 deletion office365/sharepoint/types/resource_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ def __init__(self, decoded_url=None):
@staticmethod
def create_absolute(site_url, path):
"""
Creates absolute path
:param str site_url: Site url
:param str path: Resource path
"""
Expand All @@ -29,11 +30,12 @@ def create_absolute(site_url, path):
@staticmethod
def create_relative(site_url, path):
"""
Creates server relative path
:param str site_url: Site url
:param str path: Resource path
"""
site_path = urlparse(site_url).path
if not path.startswith(site_path):
if not path.lower().startswith(site_path.lower()):
return ResourcePath("/".join([site_path, path]))
else:
return ResourcePath(path)
Expand Down

0 comments on commit 0dd6039

Please sign in to comment.