Skip to content

Commit

Permalink
SharePoint API: setting datesInUTC as optional param in validate_upda…
Browse files Browse the repository at this point in the history
…te_list_item method #509
  • Loading branch information
vgrem committed May 29, 2022
1 parent b9a8880 commit 59cd2e9
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 8 deletions.
2 changes: 1 addition & 1 deletion examples/sharepoint/listitems/system_update_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"Title": "Task (updated)",
"Author": FieldUserValue.from_user(author),
"Modified": modified_date
}).execute_query()
}, dates_in_utc=True).execute_query()

has_any_error = any([item.HasException for item in result.value])
if has_any_error:
Expand Down
4 changes: 2 additions & 2 deletions examples/sharepoint/lists/create_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.lists.list_creation_information import ListCreationInformation
from office365.sharepoint.lists.list_template_type import ListTemplateType
from tests import test_client_credentials, test_site_url
from tests import test_client_credentials, test_team_site_url

ctx = ClientContext(test_site_url).with_credentials(test_client_credentials)
ctx = ClientContext(test_team_site_url).with_credentials(test_client_credentials)

list_name = "Tasks" + str(randint(0, 10000))
create_info = ListCreationInformation(list_name, None, ListTemplateType.Tasks)
Expand Down
8 changes: 8 additions & 0 deletions office365/sharepoint/alerts/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@


class Alert(BaseEntity):
"""
Represents an alert, which generates periodic e-mail notifications sent to a user about the list, list item,
document, or document library to which the alert applies. SP.Alert provides information about the alert,
such as which alert template is used, the alert frequency, and the UserID of the user who created the alert.
The AlertTime, ItemID, ListID and ListUrl properties are not included in the default scalar property
set for this type.
"""

@property
def user(self):
Expand Down
6 changes: 4 additions & 2 deletions office365/sharepoint/listitems/listitem.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,20 +168,22 @@ def _item_resolved():
self.ensure_properties(["Id", "ParentList"], _item_resolved)
return return_type

def validate_update_list_item(self, form_values, new_document_update=False, checkin_comment=None):
def validate_update_list_item(self, form_values, new_document_update=False, checkin_comment=None,
dates_in_utc=None):
"""Validates and sets the values of the specified collection of fields for the list item.
:param dict form_values: Specifies a collection of field internal names and values for the given field
:param dict new_document_update: Specifies whether the list item is a document being updated after upload.
:param str checkin_comment: Check-in comment, if any. This parameter is only applicable when the list item
is checked out.
:param bool or None dates_in_utc:
"""
normalized_form_values = [ListItemFormUpdateValue(k, v) for k, v in form_values.items()]
payload = {
"formValues": normalized_form_values,
"bNewDocumentUpdate": new_document_update,
"checkInComment": checkin_comment,
"datesInUTC": True
"datesInUTC": dates_in_utc
}
result = ClientResult(self.context, ClientValueCollection(ListItemFormUpdateValue))
qry = ServiceOperationQuery(self, "ValidateUpdateListItem", None, payload, None, result)
Expand Down
2 changes: 2 additions & 0 deletions office365/sharepoint/lists/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,13 +470,15 @@ def event_receivers(self):
@property
def item_count(self):
"""Gets a value that specifies the number of list items in the list.
:rtype: int or None
"""
return self.properties.get('ItemCount', None)

@property
def title(self):
"""Gets the displayed title for the list.
:rtype: str or None
"""
return self.properties.get('Title', None)
Expand Down
40 changes: 39 additions & 1 deletion office365/sharepoint/userprofiles/person_properties.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from office365.runtime.types.string_collection import StringCollection
from office365.sharepoint.base_entity import BaseEntity


Expand All @@ -6,4 +7,41 @@ class PersonProperties(BaseEntity):
The PersonProperties class contains the data about people and is returned by PeopleManager methods
(see section 3.1.5.58).
"""
pass

@property
def extended_managers(self):
"""
The ExtendedManagers property specifies an array of strings that specify the account names of
a person's managers.
:rtype: StringCollection
"""
return self.properties.get('ExtendedManagers', StringCollection())

@property
def extended_reports(self):
"""
The ExtendedReports properties specifies an array of strings that specify the account names of
person's extended reports.
:rtype: StringCollection
"""
return self.properties.get('ExtendedReports', StringCollection())

@property
def user_url(self):
"""
The UserUrl property specifies the URL for the person's profile.
:rtype: str or None
"""
return self.properties.get('UserUrl', None)

def get_property(self, name, default_value=None):
if default_value is None:
property_mapping = {
"ExtendedManagers": self.extended_managers,
"ExtendedReports": self.extended_reports
}
default_value = property_mapping.get(name, None)
return super(PersonProperties, self).get_property(name, default_value)
4 changes: 2 additions & 2 deletions tests/sharepoint/test_user_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def test4_get_user_props(self):
def test5_get_properties_for(self):
me = self.my_client.web.current_user.get().execute_query()
people_manager = PeopleManager(self.my_client)
result = people_manager.get_properties_for(me.login_name).execute_query()
self.assertIsNotNone(result)
properties = people_manager.get_properties_for(me.login_name).execute_query()
self.assertIsNotNone(properties)

def test6_get_default_document_library(self):
me = self.my_client.web.current_user.get().execute_query()
Expand Down

0 comments on commit 59cd2e9

Please sign in to comment.