-
-
Notifications
You must be signed in to change notification settings - Fork 317
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
type hints enhancements for lists, webs namespaces, #749: a few fixes
- Loading branch information
Showing
22 changed files
with
66 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
""" | ||
Demonstrates how to crete a site field of type DateTime | ||
""" | ||
|
||
from office365.sharepoint.client_context import ClientContext | ||
from tests import create_unique_name, test_client_credentials, test_team_site_url | ||
|
||
client = ClientContext(test_team_site_url).with_credentials(test_client_credentials) | ||
field_name = create_unique_name("DateColumn") | ||
field = client.web.fields.add_datetime(field_name).execute_query() | ||
print("Field {0} has been created".format(field.internal_name)) | ||
field.delete_object().execute_query() # clean up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
""" | ||
Retrieves sites in tenant | ||
""" | ||
|
||
from office365.sharepoint.client_context import ClientContext | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
from office365.sharepoint.client_context import ClientContext | ||
from office365.sharepoint.sites.home_sites_details import HomeSitesDetails | ||
from tests import test_admin_credentials, test_admin_site_url | ||
|
||
admin_client = ClientContext(test_admin_site_url).with_credentials( | ||
test_admin_credentials | ||
) | ||
result = admin_client.tenant.get_home_sites().execute_query() | ||
for details in result.value: # type: HomeSitesDetails | ||
for details in result.value: | ||
print(" {0}".format(details.Url)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import json | ||
""" | ||
Retrieves site users | ||
""" | ||
|
||
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) | ||
users = ctx.web.site_users.select(["LoginName"]).get().execute_query() | ||
print(json.dumps(users.to_json(), indent=4)) | ||
users = ctx.web.site_users.select(["LoginName"]).get().top(100).execute_query() | ||
for user in users: | ||
print(user.login_name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,19 @@ | ||
from office365.sharepoint.client_context import ClientContext | ||
from office365.sharepoint.lists.list import List | ||
from tests import test_client_credentials, test_site_url, test_team_site_url | ||
from tests import test_client_credentials, test_site_url | ||
|
||
|
||
def print_progress(num_deleted): | ||
print("{0} deleted.".format(num_deleted)) | ||
|
||
|
||
def delete_custom_lists(web): | ||
""" | ||
:type web: office365.sharepoint.webs.web.Web | ||
""" | ||
result = ( | ||
web.lists.get() | ||
.select(["IsSystemList", "Title", "Id"]) | ||
.filter("IsSystemList eq false") | ||
.execute_query() | ||
) | ||
print("{0} lists found".format(len(result))) | ||
for lst in result: # type: List | ||
lst.delete_object() | ||
web.context.execute_batch(success_callback=print_progress) | ||
|
||
|
||
ctx = ClientContext(test_site_url).with_credentials(test_client_credentials) | ||
delete_custom_lists(ctx.web) | ||
result = ( | ||
ctx.web.lists.get() | ||
.select(["IsSystemList", "Title", "Id"]) | ||
.filter("IsSystemList eq false") | ||
.execute_query() | ||
) | ||
print("{0} lists found".format(len(result))) | ||
for lst in result: | ||
lst.delete_object() | ||
ctx.web.context.execute_batch(success_callback=print_progress) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
""" | ||
Gets web activities | ||
""" | ||
from office365.sharepoint.activities.entity import SPActivityEntity | ||
from office365.sharepoint.client_context import ClientContext | ||
from tests import test_client_credentials, test_site_url | ||
|
||
client = ClientContext(test_site_url).with_credentials(test_client_credentials) | ||
activities = client.web.activities.get().execute_query() | ||
for activity in activities: # type: SPActivityEntity | ||
for activity in activities: | ||
print(activity.action.facet_type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
from office365.sharepoint.client_context import ClientContext | ||
from office365.sharepoint.webs.web import Web | ||
from tests import test_client_credentials, test_site_url | ||
|
||
client = ClientContext(test_site_url).with_credentials(test_client_credentials) | ||
|
||
webs = client.web.get_all_webs().execute_query() | ||
for web in webs: # type: Web | ||
for web in webs: | ||
print(web.url) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
from office365.sharepoint.client_context import ClientContext | ||
from office365.sharepoint.lists.list import List | ||
from tests import test_client_credentials, test_site_url | ||
|
||
client = ClientContext(test_site_url).with_credentials(test_client_credentials) | ||
lists = client.web.get_lists().execute_query() | ||
for lst in lists: # type: List | ||
for lst in lists: | ||
print(lst.title) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.