• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python web.slugify函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中monstor.utils.web.slugify函数的典型用法代码示例。如果您正苦于以下问题:Python slugify函数的具体用法?Python slugify怎么用?Python slugify使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了slugify函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_0020_tasklists_post1

 def test_0020_tasklists_post1(self):
     """
     Test post with logged in and invalid organisation slug
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team = Team(
         name="Developers", organisation=organisation,
         members=[self.user]
     )
     team.save()
     acl = AccessControlList(team=team, role="admin")
     project = Project(
         name="titan", organisation=organisation, acl=[acl],
         slug=slugify('titan project')
     )
     project.save()
     response = self.fetch(
         '/an-invalid-organisation/%s/tasklists' % project.slug,
         method="POST",
         follow_redirects=False,
         body=urlencode({'name': "Version 0.1"}),
         headers={'Cookie': self.get_login_cookie()}
     )
     self.assertEqual(response.code, 404)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:27,代码来源:test_tasklist.py


示例2: test_0060_slugverification_2

 def test_0060_slugverification_2(self):
     """
     Verify project slug which already exists under current organisations
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team = Team(
         name="Developers", organisation=organisation,
         members=[self.user]
     )
     team.save()
     acl = AccessControlList(team=team, role="admin")
     project = Project(
         name="titan", organisation=organisation, acl=[acl],
         slug=slugify('titan project')
     )
     project.save()
     response = self.fetch(
         '/%s/+slug-check' % organisation.slug,
         method="POST",
         follow_redirects=False,
         body=urlencode({
             'project_slug':slugify('titan project')
         }),
         headers= {'Cookie' : self.get_login_cookie()}
     )
     response = json.loads(response.body)
     self.assertEqual(response, False)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:30,代码来源:test_projects.py


示例3: test_0040_projects_post_2

 def test_0040_projects_post_2(self):
     """
     post with logged in and Project slug already exist
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team = Team(
         name="Developers", organisation=organisation,
         members=[self.user]
     )
     team.save()
     acl = AccessControlList(team=team, role="admin")
     project = Project(
         name="titan", organisation=organisation, acl=[acl],
         slug=slugify('titan project')
     )
     project.save()
     response = self.fetch(
         '/%s/projects/' % organisation.slug,
         method="POST",
         follow_redirects=False,
         body=urlencode({'name':'Titan', 'slug':slugify('titan project')}),
         headers= {'Cookie' : self.get_login_cookie()}
     )
     self.assertEqual(response.code, 200)
     self.assertEqual(
         response.body.count(
             u'A project with the same short code already exists'
         ), 1
     )
开发者ID:Anoopsmohan,项目名称:titan,代码行数:32,代码来源:test_projects.py


示例4: test_0090_task_handler_get_1

    def test_0090_task_handler_get_1(self):
        """
        Try to render a particular task without being logged in
        """
        organisation = Organisation(
            name="open labs", slug=slugify("open labs")
        )
        organisation.save()
        team = Team(
            name="Developers", organisation=organisation,
            members=[self.user]
        )
        team.save()
        acl = AccessControlList(team=team, role="admin")
        project = Project(
            name="titan", organisation=organisation, acl=[acl],
            slug=slugify('titan project')
        )
        project.save()
        tasklist = TaskList(name="version 01", project=project)
        tasklist.save()

        response = self.fetch(
            '/%s/%s/%s/tasks/new' % (
                organisation.slug, project.slug, tasklist.sequence
            ),
            method="GET",
            follow_redirects=False,
        )
        self.assertEqual(response.code, 302)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:30,代码来源:test_tasklist.py


示例5: test_0160_task_handler_post_5

    def test_0160_task_handler_post_5(self):
        """
        Test TaskHandler 'post' method invalid form fields
        """
	organisation = Organisation(
            name="open labs", slug=slugify("open labs")
        )
	organisation.save()
        team = Team(
            name="Developers", organisation=organisation,
            members=[self.user]
        )
        team.save()
        acl = AccessControlList(team=team, role="admin")
        project = Project(
            name="titan", organisation=organisation, acl=[acl],
            slug=slugify('titan project')
        )
        project.save()
        tasklist = TaskList(name="version 01", project=project)
        tasklist.save()

        response = self.fetch(
            '/%s/%s/%s/tasks/new' % (
                organisation.slug, project.slug, tasklist.sequence
            ),
            method="POST",
            follow_redirects=False,
            body=urlencode({
                    "status": "new",
                    "assigned_to": str(self.user.id),
            }),
            headers={'Cookie': self.get_login_cookie()},
        )
        self.assertEqual(response.code, 200)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:35,代码来源:test_tasklist.py


示例6: test_0100_task_handler_get_2

    def test_0100_task_handler_get_2(self):
        """
        Try to render a particular task without providing Task Id
        If 'task id' is not provided, then it will return create task form.
        """
        organisation = Organisation(
            name="open labs", slug=slugify("open labs")
        )
        organisation.save()
        team = Team(
            name="Developers", organisation=organisation,
            members=[self.user]
        )
        team.save()
        acl = AccessControlList(team=team, role="admin")
        project = Project(
            name="titan", organisation=organisation, acl=[acl],
            slug=slugify('titan project')
        )
        project.save()
        tasklist = TaskList(name="version 01", project=project)
        tasklist.save()

        response = self.fetch(
            '/%s/%s/%s/tasks/new' % (
                organisation.slug, project.slug, tasklist.sequence
            ),
            method="GET",
            follow_redirects=False,
            headers={'Cookie': self.get_login_cookie()}
        )
        self.assertEqual(response.code, 200)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:32,代码来源:test_tasklist.py


示例7: test_0150_user_organisation

    def test_0150_user_organisation(self):
        """
        Test the organisation property of user
        """
        user_2 = User(
            name="test-user",
            email="[email protected]",
        )
        user_2.set_password("openlabs")
        user_2.save()

        # Create organisations
        organisation_1 = Organisation(
            name="open labs", slug=slugify("open labs")
        )
        organisation_1.save()
        organisation_2 = Organisation(
            name="new organisation", slug=slugify("new organisation")
        )
        organisation_2.save()

        # Create teams
        team_developers = Team(
            name="Developers", organisation=organisation_1,
            members=[self.user, user_2]
        )
        team_developers.save()
        team_participants = Team(
            name="Paricipants", organisation=organisation_2,
            members=[self.user]
        )
        team_participants.save()
        self.assertEqual(len(self.user.organisations), 2)
        self.assertEqual(len(user_2.organisations), 1)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:34,代码来源:test_model.py


示例8: test_0080_tasklist_get_1

 def test_0080_tasklist_get_1(self):
     """
     Test Task List with wrong organisation slug
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team = Team(
         name="Developers", organisation=organisation,
         members=[self.user]
     )
     team.save()
     acl = AccessControlList(team=team, role="admin")
     project = Project(
         name="titan", organisation=organisation, acl=[acl],
         slug=slugify('titan project')
     )
     project.save()
     tasklist = TaskList(name="version 01", project=project)
     tasklist.save()
     response = self.fetch(
         '/wrong-organisation/%s/%s' % (project.slug, tasklist.sequence),
         method="GET",
         follow_redirects=False,
         headers={'Cookie': self.get_login_cookie()}
     )
     self.assertEqual(response.code, 404)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:28,代码来源:test_tasklist.py


示例9: test_0070_projecthandler_1

 def test_0070_projecthandler_1(self):
     """
     Test project page which already exist
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team = Team(
         name="Developers", organisation=organisation,
         members=[self.user]
     )
     team.save()
     acl = AccessControlList(team=team, role="admin")
     project = Project(
         name="titan", organisation=organisation, acl=[acl],
         slug=slugify('titan project')
     )
     project.save()
     response = self.fetch(
         '/%s/%s' % (organisation.slug, project.slug),
         method="GET",
         follow_redirects=False,
         headers= {'Cookie' : self.get_login_cookie()}
     )
     self.assertEqual(response.code, 200)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:26,代码来源:test_projects.py


示例10: test_0020_unique_slug

 def test_0020_unique_slug(self):
     """
     'slug' must be a unique value in Organisation.
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     organisation = Organisation(name="open lab", slug=slugify("open labs"))
     self.assertRaises(OperationError, organisation.save)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:10,代码来源:test_model.py


示例11: create_project

def create_project(user, name, slug, organisation):
    """
    Create a new project and return the object.

    :param user: User collection object
    :param name: The name of the project
    :param slug: The slug used for the project.
    :param organisation: The organisation the project belongs to.
    :return: Created project as Document
    """
    acl_admin = AccessControlList(
        team=Team(
            name="Admin", organisation=organisation, members=[user]
        ).save(), role="admin"
    )
    acl_participant = AccessControlList(
        team=Team(
            name="Participant", organisation=organisation, members=[user]
        ).save(), role="participant"
    )
    project = Project(
        name=name, organisation=organisation, acl=[acl_admin, acl_participant],
        slug=slugify(slug)
    )
    return project
开发者ID:Anoopsmohan,项目名称:titan,代码行数:25,代码来源:test_model.py


示例12: test_0010_tasklistshandler_get

    def test_0010_tasklistshandler_get(self):
        """
        Test tasklists handler get method
        """
        organisation = Organisation(
            name="open labs", slug=slugify("open labs")
        )
        organisation.save()
        team = Team(
            name="Developers", organisation=organisation,
            members=[self.user]
        )
        team.save()
        acl = AccessControlList(team=team, role="admin")
        project = Project(
            name="titan", organisation=organisation, acl=[acl],
            slug=slugify('titan project')
        )
        project.save()

        # User not logged in
        response = self.fetch(
            '/%s/%s/tasklists' % (organisation.slug, project.slug),
            method="GET",
            follow_redirects=False
        )
        self.assertEqual(response.code, 302)

        # User logged in and an existing organisation
        cookies = self.get_login_cookie()
        response = self.fetch(
            '/%s/%s/tasklists' % (organisation.slug, project.slug),
            method="GET",
            follow_redirects=False,
            headers={'Cookie': cookies}
        )
        self.assertEqual(response.code, 200)

        # User logged in and Organisation not existing
        cookies = self.get_login_cookie()
        response = self.fetch(
            '/an-invalid-organisation/%s/tasklists' % project.slug,
            method="GET",
            follow_redirects=False,
            headers={'Cookie': cookies}
        )
        self.assertEqual(response.code, 404)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:47,代码来源:test_tasklist.py


示例13: test_0100_project_fields

    def test_0100_project_fields(self):
        """
        Test the fields required for the Project collection.
        """
        organisation = Organisation(
            name="open labs", slug=slugify("open labs")
        )
        organisation.save()
        # Create AccessControlList instances
        acl_developers = AccessControlList(
            team=Team(
                name="Admins", organisation=organisation, members=[self.user]
            ).save(), role="admin"
        )
        acl_participants = AccessControlList(
            team=Team(
                name="Viewers", organisation=organisation, members=[self.user]
            ).save(), role="participant"
        )

        # 'organisation' is a required field
        project = Project(
            name="titan", slug=slugify("titan project"), acl=[acl_developers,
            acl_participants]
        )
        self.assertRaises(ValidationError, project.save)

        # 'acl' is a a required field
        project = Project(name="New Titan", slug=slugify( "titan projects"),
            organisation=organisation
        )
        self.assertRaises(ValidationError, project.save)

        # 'name' is a required field
        project = Project(slug=slugify("titan project"),
            organisation=organisation, acl=[acl_developers, acl_participants]
        )
        self.assertRaises(ValidationError, project.save)

        # 'slug' is a required field
        project = Project(
            name="titan", organisation=organisation,
            acl=[acl_developers, acl_participants]
        )
        self.assertRaises(ValidationError, project.save)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:45,代码来源:test_model.py


示例14: test_0090_same_slug

 def test_0090_same_slug(self):
     """
     We can use same project "slug" under different organisations
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     project = create_project(
         self.user, "New Titan", "titan projects", organisation
     )
     project.save()
     new_organisation = Organisation(name="Infy", slug=slugify("infy labs"))
     new_organisation.save()
     project = create_project(
         self.user, "New Titan", "titan projects", new_organisation
     )
     project.save()
开发者ID:Anoopsmohan,项目名称:titan,代码行数:18,代码来源:test_model.py


示例15: test_0010_create_organisation

 def test_0010_create_organisation(self):
     """
     Create an Organisation
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     self.assertEqual(Organisation.objects().count(), 1)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:9,代码来源:test_model.py


示例16: test_0080_create_organisation_2

 def test_0080_create_organisation_2(self):
     """
     Test for creating an organisation which already existing
     """
     organisation = Organisation(
         name="openlabs", slug=slugify("new organisation")
     )
     organisation.save()
     cookies = self.get_login_cookie()
     slug = slugify('new organisation')
     response = self.fetch(
         '/my-organisations/', method="POST", follow_redirects=False,
         headers={
             'Cookie': cookies
         },
         body=urlencode({
             'name': 'organisation', 'slug': slug
         })
     )
     self.assertEqual(response.code, 200)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:20,代码来源:test_organisations.py


示例17: test_0030_org_required_fields

    def test_0030_org_required_fields(self):
        """
        Test the required fields of Organisation collection.
        """
        # 'slug' is a required field
        organisation = Organisation(name="openlabs")
        self.assertRaises(ValidationError, organisation.save)

        # 'name' is a required field
        organisation = Organisation(slug=slugify("open labs"))
        self.assertRaises(ValidationError, organisation.save)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:11,代码来源:test_model.py


示例18: test_0060_slug_verification_2

 def test_0060_slug_verification_2(self):
     """
     verify slug which already exists
     """
     organisation = Organisation(
         name="openlabs", slug=slugify("new organisation")
     )
     organisation.save()
     slug = slugify("new organisation")
     response = self.fetch(
         '/+slug-check', method="POST",
         follow_redirects=False,
         headers={
             'Cookie': self.get_login_cookie()
         },
         body=urlencode({
             "slug": slug
         })
     )
     response = json.loads(response.body)
     self.assertEqual(response, False)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:21,代码来源:test_organisations.py


示例19: test_0040_create_team

 def test_0040_create_team(self):
     """
     Create a Team
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     team = Team(
         name="Developers", organisation=organisation, members=[self.user]
     )
     team.save()
     self.assertEqual(Team.objects().count(), 1)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:13,代码来源:test_model.py


示例20: test_0070_create_project

 def test_0070_create_project(self):
     """
     Create project under organisation
     """
     organisation = Organisation(
         name="open labs", slug=slugify("open labs")
     )
     organisation.save()
     project = create_project(
         self.user, "Titan", "titan project", organisation
     )
     project.save()
     self.assertEqual(Project.objects().count(), 1)
开发者ID:Anoopsmohan,项目名称:titan,代码行数:13,代码来源:test_model.py



注:本文中的monstor.utils.web.slugify函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python base.typecheck函数代码示例发布时间:2022-05-27
下一篇:
Python monster.Monster类代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap