Skip to content

Commit

Permalink
#730: fix for SitePage.checkout_page method, workbooks namespace new …
Browse files Browse the repository at this point in the history
…types
  • Loading branch information
vgrem committed Sep 18, 2023
1 parent febede1 commit 3cc489b
Show file tree
Hide file tree
Showing 34 changed files with 298 additions and 63 deletions.
5 changes: 4 additions & 1 deletion examples/sharepoint/listitems/attachments/upload.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
"""
Creates a list item and uploads an attachment
"""

import os
from office365.sharepoint.attachments.creation_information import AttachmentCreationInformation
from office365.sharepoint.client_context import ClientContext
from tests import test_client_credentials, test_team_site_url

ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials)

list_title = "Company Tasks"
tasks_list = ctx.web.lists.get_by_title(list_title)

Expand Down
10 changes: 10 additions & 0 deletions examples/sharepoint/views/read_custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.listitems.listitem import ListItem
from tests import test_client_credentials, test_team_site_url


ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials)
view = ctx.web.default_document_library().views.get_by_title("All Documents")
items = view.get_items().expand(["Author"]).execute_query()
for item in items: # type: ListItem
print(item.properties)
13 changes: 13 additions & 0 deletions examples/sharepoint/views/read_default.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""
Read list items from a default view
"""
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.listitems.listitem import ListItem
from tests import test_client_credentials, test_team_site_url


ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials)
lib = ctx.web.default_document_library()
items = lib.default_view.get_items().execute_query()
for item in items: # type: ListItem
print(item.properties)
28 changes: 0 additions & 28 deletions examples/sharepoint/views/read_items.py

This file was deleted.

2 changes: 1 addition & 1 deletion generator/metadata/SharePoint.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22329,7 +22329,7 @@
<Annotations Target="SP.Publishing.SitePage/CanvasJson1">
<ValueAnnotation Term="Com.Microsoft.VisualStudio.CodeGen.IsBeta" Bool="true"/>
</Annotations>
<Annotations Target="SP.Publishing.SitePage/CheckIn">
<Annotations Target="SP.Publishing.SitePage/"CheckIn"">
<ValueAnnotation Term="Com.Microsoft.VisualStudio.CodeGen.IsBeta" Bool="true"/>
</Annotations>
<Annotations Target="SP.Publishing.SitePage/CoAuthState">
Expand Down
5 changes: 5 additions & 0 deletions office365/onedrive/workbooks/filter_criteria.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from office365.runtime.client_value import ClientValue


class WorkbookFilterCriteria(ClientValue):
"""Represents the filtering criteria applied to a column."""
1 change: 0 additions & 1 deletion office365/onedrive/workbooks/functions/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ class WorkbookFunctions(Entity):
def abs(self, number):
"""
Returns the absolute value of a number. The absolute value of a number is the number without its sign
:param float number: The real number of which you want the absolute value.
"""
return_type = WorkbookFunctionResult(self.context)
Expand Down
10 changes: 10 additions & 0 deletions office365/onedrive/workbooks/operations/error.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,13 @@

class WorkbookOperationError(ClientValue):
"""Represents an error from a failed workbook operation."""

def __init__(self, code=None, innerError=None, message=None):
"""
:param str code:
:param str innerError:
:param str message:
"""
self.code = code
self.innerError = innerError
self.message = message
5 changes: 5 additions & 0 deletions office365/onedrive/workbooks/ranges/border.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from office365.entity import Entity


class WorkbookRangeBorder(Entity):
"""Represents the border of an object."""
5 changes: 5 additions & 0 deletions office365/onedrive/workbooks/ranges/fill.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from office365.entity import Entity


class WorkbookRangeFill(Entity):
"""Represents the background of a range object."""
8 changes: 8 additions & 0 deletions office365/onedrive/workbooks/ranges/format.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
from office365.entity import Entity
from office365.onedrive.workbooks.ranges.fill import WorkbookRangeFill
from office365.onedrive.workbooks.ranges.format_protection import WorkbookFormatProtection
from office365.runtime.paths.resource_path import ResourcePath


class WorkbookRangeFormat(Entity):
"""A format object encapsulating the range's font, fill, borders, alignment, and other properties."""

@property
def fill(self):
"""Returns the fill object defined on the overall range"""
return self.properties.get('fill',
WorkbookRangeFill(self.context,
ResourcePath("fill", self.resource_path)))

@property
def protection(self):
"""Returns the format protection object for a range """
Expand Down
39 changes: 38 additions & 1 deletion office365/onedrive/workbooks/ranges/range.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from office365.entity import Entity
from office365.onedrive.workbooks.ranges.format import WorkbookRangeFormat
from office365.onedrive.workbooks.ranges.sort import WorkbookRangeSort
from office365.onedrive.workbooks.ranges.view import WorkbookRangeView
from office365.runtime.paths.resource_path import ResourcePath
from office365.runtime.queries.function import FunctionQuery
Expand All @@ -19,11 +21,46 @@ def address(self):
"""
Represents the range reference in A1-style. Address value will contain the Sheet reference
(e.g. Sheet1!A1:B4)
:rtype: str or None
"""
return self.properties.get("address", None)

@property
def address_local(self):
"""
Represents range reference for the specified range in the language of the user. Read-only.
:rtype: str or None
"""
return self.properties.get("addressLocal", None)

@property
def cell_count(self):
"""
Number of cells in the range. Read-only.
:rtype: int or None
"""
return self.properties.get("cellCount", None)

@property
def column_count(self):
"""
Represents the total number of columns in the range. Read-only.
:rtype: int or None
"""
return self.properties.get("columnCount", None)

@property
def format(self):
"""Returns a format object, encapsulating the range's font, fill, borders, alignment, and other properties"""
return self.properties.get('format',
WorkbookRangeFormat(self.context, ResourcePath("format", self.resource_path)))

@property
def sort(self):
"""The worksheet containing the current range. """
return self.properties.get('sort',
WorkbookRangeSort(self.context, ResourcePath("sort", self.resource_path)))

@property
def worksheet(self):
"""The worksheet containing the current range """
Expand Down
5 changes: 5 additions & 0 deletions office365/onedrive/workbooks/ranges/sort.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
from office365.entity import Entity


class WorkbookRangeSort(Entity):
"""Manages sorting operations on Range objects."""
1 change: 0 additions & 1 deletion office365/onedrive/workbooks/tables/pivot_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ def refresh_all(self):
@property
def name(self):
"""Name of the PivotTable.
:rtype: str or None
"""
return self.properties.get("Name", None)
Expand Down
4 changes: 2 additions & 2 deletions office365/outlook/calendar/email_address.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ class EmailAddress(ClientValue):

def __init__(self, address=None, name=None):
"""
:param str address:
:param str name:
:param str address: The email address of the person or entity.
:param str name: The display name of the person or entity.
"""
super(EmailAddress, self).__init__()
self.address = address
Expand Down
52 changes: 52 additions & 0 deletions office365/outlook/calendar/events/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,58 @@ def dismiss_reminder(self):
self.context.add_query(qry)
return self

@property
def allow_new_time_proposals(self):
"""
true if the meeting organizer allows invitees to propose a new time when responding; otherwise, false.
Optional. Default is true.
:rtype: bool or None
"""
return self.properties.get("allowNewTimeProposals", None)

@property
def has_attachments(self):
"""
Set to true if the event has attachments.
:rtype: bool or None
"""
return self.properties.get("hasAttachments", None)

@property
def hide_attendees(self):
"""
When set to true, each attendee only sees themselves in the meeting request and meeting Tracking list.
Default is false.
:rtype: bool or None
"""
return self.properties.get("hideAttendees", None)

@property
def ical_uid(self):
"""
A unique identifier for an event across calendars. This ID is different for each occurrence in a recurring
series. Read-only.
:rtype: str or None
"""
return self.properties.get("iCalUId", None)

@property
def importance(self):
"""
The importance of the event. The possible values are: low, normal, high.
:rtype: str
"""
return self.properties.get("importance", None)

@property
def is_all_day(self):
"""
Set to true if the event lasts all day. If true, regardless of whether it's a single-day or multi-day event,
start and end time must be set to midnight and be in the same time zone.
:rtype: bool or None
"""
return self.properties.get("isAllDay", None)

@property
def start(self):
"""
Expand Down
Empty file.
7 changes: 7 additions & 0 deletions office365/outlook/calendar/timezones/custom.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
from office365.outlook.calendar.timezones.base import TimeZoneBase


class CustomTimeZone(TimeZoneBase):
"""
Represents a time zone where the transition from standard to daylight saving time, or vice versa is not standard.
"""
2 changes: 1 addition & 1 deletion office365/outlook/calendar/working_hours.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from office365.outlook.calendar.time_zone_base import TimeZoneBase
from office365.outlook.calendar.timezones.base import TimeZoneBase
from office365.runtime.client_value import ClientValue
from office365.runtime.types.collections import StringCollection

Expand Down
13 changes: 12 additions & 1 deletion office365/outlook/mail/messages/rules/predicates.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,30 @@
from office365.outlook.mail.recipient import Recipient
from office365.runtime.client_value import ClientValue
from office365.runtime.client_value_collection import ClientValueCollection
from office365.runtime.types.collections import StringCollection


class MessageRulePredicates(ClientValue):
"""Represents the set of conditions and exceptions that are available for a rule."""

def __init__(self, body_contains=None, body_or_subject_contains=None, categories=None):
def __init__(self, body_contains=None, body_or_subject_contains=None, categories=None,
from_addresses=None, has_attachments=None, header_contains=None):
"""
:param list[str] body_contains: Represents the strings that should appear in the body of an incoming message
in order for the condition or exception to apply.
:param list[str] body_or_subject_contains: Represents the strings that should appear in the body or subject
of an incoming message in order for the condition or exception to apply.
:param list[str] categories: Represents the categories that an incoming message should be labeled with in
order for the condition or exception to apply.
:param list[Recipient] from_addresses: Represents the specific sender email addresses of an incoming message
in order for the condition or exception to apply.
:param bool has_attachments: Indicates whether an incoming message must have attachments in order for the
condition or exception to apply.
:param list[str] header_contains:
"""
self.bodyContains = StringCollection(body_contains)
self.bodyOrSubjectContains = StringCollection(body_or_subject_contains)
self.categories = StringCollection(categories)
self.fromAddresses = ClientValueCollection(Recipient, from_addresses)
self.hasAttachments = has_attachments
self.headerContains = StringCollection(header_contains)
4 changes: 2 additions & 2 deletions office365/sharepoint/attachments/creation_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ def __init__(self, filename=None, content=None):
"""
Represents properties that can be set when creating a file by using the AttachmentFiles.Add method.
:type filename: str
:type content: str or bytes
:param str filename: Specifies the file name of the list item attachment.
:param str or bytes content: The contents of the file as a stream.
"""
super(AttachmentCreationInformation, self).__init__()
self._filename = filename
Expand Down
1 change: 1 addition & 0 deletions office365/sharepoint/listitems/caml/query.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def parse(query_expr, scope=ViewScope.DefaultValue):

@staticmethod
def create_all_items_query():
"""Constructs a query"""
return CamlQuery.parse("", ViewScope.RecursiveAll)

@staticmethod
Expand Down
15 changes: 15 additions & 0 deletions office365/sharepoint/lists/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
from office365.sharepoint.pages.wiki_page_creation_information import WikiPageCreationInformation
from office365.sharepoint.permissions.securable_object import SecurableObject
from office365.sharepoint.principal.users.user import User
from office365.sharepoint.sharing.object_sharing_settings import ObjectSharingSettings
from office365.sharepoint.sitescripts.utility import SiteScriptUtility
from office365.sharepoint.translation.user_resource import UserResource
from office365.sharepoint.usercustomactions.collection import UserCustomActionCollection
Expand Down Expand Up @@ -115,6 +116,20 @@ def _loaded():
self.root_folder.ensure_property("ServerRelativeUrl", _loaded)
return return_type

def get_sharing_settings(self):
"""
Retrieves a sharing settings for a List
"""
return_type = ObjectSharingSettings(self.context)

def _list_loaded():
from office365.sharepoint.webs.web import Web
list_abs_path = SPResPath.create_absolute(self.context.base_url, self.root_folder.serverRelativeUrl)
Web.get_object_sharing_settings(self.context, str(list_abs_path), return_type=return_type)

self.ensure_property("RootFolder", _list_loaded)
return return_type

def get_site_script(self, options=None):
"""Creates site script syntax
Expand Down
Loading

0 comments on commit 3cc489b

Please sign in to comment.