Ejemplo n.º 1
0
    def add_lookup_field(self,
                         title,
                         lookup_list_id,
                         lookup_field_name,
                         allow_multiple_values=False):
        """
        Adds Lookup field

        :param bool allow_multiple_values:
        :param str lookup_field_name:
        :param str lookup_list_id:
        :param str title:
        """
        if allow_multiple_values:
            field_schema = '''
                        <Field Type="LookupMulti" Mult="TRUE" DisplayName="{title}" Required="FALSE" Hidden="TRUE" \
                        ShowField="{lookup_field_name}" List="{{{lookup_list_id}}}" StaticName="{title}" Name="{title}">
                        </Field>
                        '''.format(title=title,
                                   lookup_field_name=lookup_field_name,
                                   lookup_list_id=lookup_list_id)
            target_field = self.create_field_as_xml(field_schema)
        else:
            create_field_info = FieldCreationInformation(
                title=title,
                lookup_list_id=lookup_list_id,
                lookup_field_name=lookup_field_name,
                field_type_kind=FieldType.Lookup)
            target_field = self.add_field(create_field_info)
        return target_field
Ejemplo n.º 2
0
 def test_15_create_list_user_field(self):
     create_field_info = FieldCreationInformation(self.user_field_name,
                                                  FieldType.User)
     user_field = self.target_list.fields.add(
         create_field_info).execute_query()
     self.assertIsNotNone(user_field.resource_path)
     self.assertEqual(user_field.type_as_string, 'User')
Ejemplo n.º 3
0
 def test_13_create_list_geolocation_field(self):
     create_field_info = FieldCreationInformation(self.geo_field_name,
                                                  FieldType.Geolocation)
     geo_field = self.target_list.fields.add(
         create_field_info).execute_query()
     self.assertIsNotNone(geo_field.resource_path)
     self.assertEqual(geo_field.type_as_string, 'Geolocation')
 def test_4_create_site_field(self):
     field_name = "Title_" + uuid.uuid4().hex
     create_field_info = FieldCreationInformation(field_name,
                                                  FieldType.Text)
     created_field = self.client.site.rootWeb.fields.add(
         create_field_info).execute_query()
     self.assertEqual(created_field.properties["Title"], field_name)
     self.__class__.target_field = created_field
Ejemplo n.º 5
0
 def test_4_create_list_field(self):
     field_name = "TaskStatuses"
     create_field_info = FieldCreationInformation(field_name, FieldType.MultiChoice)
     [create_field_info.Choices.add(choice) for choice in ["Not Started", "In Progress", "Completed", "Deferred"]]
     created_field = self.__class__.target_list.fields.add(create_field_info)
     self.client.execute_query()
     self.assertIsInstance(created_field, FieldMultiChoice)
     self.__class__.target_field = created_field
    def setUpClass(cls):
        super(TestSPView, cls).setUpClass()
        cls.target_list = cls.ensure_list(
            cls.client.web,
            ListCreationInformation("Tasks", None, ListTemplateType.Tasks))

        field_info = FieldCreationInformation(
            "TaskComment_" + uuid.uuid4().hex, FieldType.Note)
        cls.target_field = cls.target_list.fields.add(
            field_info).execute_query()
Ejemplo n.º 7
0
    def add_choice_field(self, title, values, multiple_values=False):
        """
        Adds Choice field

        :param bool multiple_values:
        :param list[str] values:
        :param str title:
        """
        fld_type = FieldType.MultiChoice if multiple_values else FieldType.Choice
        create_field_info = FieldCreationInformation(title, fld_type)
        [create_field_info.Choices.add(choice) for choice in values]
        return self.add_field(create_field_info)
    def add_url_field(self, title, description=None):
        """
        Adds Url field

        :param str title:
        :param str or None description:
        :return:
        """
        create_field_info = FieldCreationInformation(title=title,
                                                     description=description,
                                                     field_type_kind=FieldType.URL)
        return self.add(create_field_info)
def create_tasks_list(client):
    """

    :type client: ClientContext
    """
    list_title = create_unique_name("Tasks N")
    list_create_info = ListCreationInformation(list_title,
                                               None,
                                               ListTemplateType.TasksWithTimelineAndHierarchy)

    target_list = client.web.lists.add(list_create_info).execute_query()
    field_info = FieldCreationInformation("Manager", FieldType.User)
    user_field = target_list.fields.add(field_info).execute_query()
    return target_list