예제 #1
0
    def create_site_sync(self, url, owner, title=None):
        """Creates a site collection

         :param str title: Sets the new site’s title.
        :param str url: Sets the new site’s URL.
        :param str owner: Sets the login name of the owner of the new site.
        """
        return_type = Site(self.context)
        op = self.create_site(url, owner, title)

        def _verify_site_status(resp, items=None):
            """
            :type resp: requests.Response
            """
            if items is None:
                is_complete = op.is_complete
            else:
                is_complete = len([
                    item
                    for item in items if item.properties.get("SiteUrl") == url
                ]) > 0
            if not is_complete:
                time.sleep(op.polling_interval_secs)
                items = self.get_sites_by_state([0, 1, 2])
                self.context.after_execute(_verify_site_status, items=items)

            return_type.set_property("NewSiteUrl", url)

        self.context.after_execute(_verify_site_status)
        return return_type
예제 #2
0
 def personal_site(self):
     """
     The PersonalSite property specifies the user's personal site
     """
     return self.properties.get(
         "PersonalSite",
         Site(self.context, ResourcePath("PersonalSite",
                                         self.resource_path)))
예제 #3
0
    def test4_register_hub_site(self):
        client_admin = ClientContext(test_admin_site_url).with_credentials(
            test_user_credentials)
        tenant = Tenant(client_admin)
        props = tenant.register_hub_site(
            self.__class__.site_response.SiteUrl).execute_query()
        self.assertIsNotNone(props.site_id)

        target_site = Site.from_url(
            self.__class__.site_response.SiteUrl).with_credentials(
                test_user_credentials)
        target_site.get().execute_query()
        self.assertTrue(target_site.is_hub_site)
 def test_1_get_app_catalog(self):
     admin_client = ClientContext(test_admin_site_url).with_credentials(
         test_user_credentials)
     tenant_settings = TenantSettings.current(
         admin_client).get().execute_query()
     self.assertIsNotNone(tenant_settings.resource_path)
     site = Site.from_url(
         tenant_settings.corporate_catalog_url).with_credentials(
             test_user_credentials)
     catalog = site.root_web.site_collection_app_catalog.get(
     ).execute_query()
     self.assertIsNotNone(catalog.resource_path)
     self.__class__.catalog = catalog
예제 #5
0
    def get_personal_site(self):
        """Get personal site"""
        from office365.sharepoint.sites.site import Site
        site = Site(self.context)

        def _user_loaded():
            from office365.sharepoint.userprofiles.people_manager import PeopleManager
            people_manager = PeopleManager(self.context)
            person_props = people_manager.get_properties_for(self.login_name)

            def _person_props_loaded(resp):
                site.set_property("NewSiteUrl", person_props.personal_url)
            self.context.after_execute(_person_props_loaded)

        self.ensure_property("LoginName", _user_loaded)
        return site
예제 #6
0
 def site(self):
     """Get Site client object"""
     if not self._site:
         self._site = Site(self)
     return self._site
예제 #7
0
 def test3_get_site_by_id(self):
     site_id = self.__class__.target_site.properties['Id']
     result = Site.get_url_by_id(self.client, site_id)
     self.client.execute_query()
     self.assertIsNotNone(result.value)
예제 #8
0
 def test2_if_site_exists(self):
     site_url = self.__class__.target_site.properties['Url']
     result = Site.exists(self.client, site_url)
     self.client.execute_query()
     self.assertIsNotNone(result.value)
from random import randint

from office365.sharepoint.sites.site import Site
from tests import test_site_url, test_user_credentials


alias = str(randint(0, 10000))
title = "Team Site"
site = Site.create_team_site(test_site_url, alias, title).with_credentials(test_user_credentials).execute_query()
print(site.url)
from random import randint

from office365.sharepoint.sites.site import Site
from tests import test_site_url, test_user_credentials

alias = str(randint(0, 10000))
title = "Communication Site"
site = Site.create_communication_site(
    test_site_url, alias,
    title).with_credentials(test_user_credentials).execute_query()
print(site.url)
from office365.sharepoint.sites.site import Site
from office365.sharepoint.tenant.administration.secondary_administrators_info import SecondaryAdministratorsInfo
from office365.sharepoint.tenant.administration.tenant import Tenant
from tests import test_user_credentials, test_site_url, test_admin_site_url, test_user_principal_name_alt

tenant = Tenant.from_url(test_admin_site_url).with_credentials(
    test_user_credentials)

target_site = Site.from_url(test_site_url).with_credentials(
    test_user_credentials).get().execute_query()
admins = tenant.get_site_secondary_administrators(site_id=target_site.id)
tenant.execute_query()

existing_admin_names = [admin.loginName for admin in admins]

target_user = target_site.root_web.ensure_user(
    test_user_principal_name_alt).execute_query()
names = existing_admin_names + [target_user.login_name]
tenant.set_site_secondary_administrators(site_id=target_site.id,
                                         names=names).execute_query()

for admin in admins:  # type: SecondaryAdministratorsInfo
    print(admin.loginName)