Example #1
0
def data():
    m = type("Models", (object, ), {})

    m.registered_user = f.UserFactory.create()
    m.project_member_with_perms = f.UserFactory.create()
    m.project_member_without_perms = f.UserFactory.create()
    m.project_owner = f.UserFactory.create()
    m.other_user = f.UserFactory.create()

    m.public_points = f.PointsFactory()
    m.public_project = f.ProjectFactory(
        is_private=False,
        anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)),
        public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)) +
        ["comment_us"],
        owner=m.project_owner,
        userstories_csv_uuid=uuid.uuid4().hex,
        default_points=m.public_points)
    m.public_project = attach_project_extra_info(
        Project.objects.all()).get(id=m.public_project.id)

    m.private_points1 = f.PointsFactory()
    m.private_project1 = f.ProjectFactory(
        is_private=True,
        anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)),
        public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)),
        owner=m.project_owner,
        userstories_csv_uuid=uuid.uuid4().hex,
        default_points=m.private_points1)
    m.private_project1 = attach_project_extra_info(
        Project.objects.all()).get(id=m.private_project1.id)

    m.private_sprint1 = f.MilestoneFactory.create(project=m.private_project1,
                                                  owner=m.project_owner)

    m.private_points2 = f.PointsFactory()
    m.private_project2 = f.ProjectFactory(
        is_private=True,
        anon_permissions=[],
        public_permissions=[],
        owner=m.project_owner,
        userstories_csv_uuid=uuid.uuid4().hex,
        default_points=m.private_points2)
    m.private_project2 = attach_project_extra_info(
        Project.objects.all()).get(id=m.private_project2.id)

    m.blocked_points = f.PointsFactory()
    m.blocked_project = f.ProjectFactory(
        is_private=True,
        anon_permissions=[],
        public_permissions=[],
        owner=m.project_owner,
        userstories_csv_uuid=uuid.uuid4().hex,
        blocked_code=project_choices.BLOCKED_BY_STAFF,
        default_points=m.blocked_points)
    m.blocked_project = attach_project_extra_info(
        Project.objects.all()).get(id=m.blocked_project.id)

    m.public_membership = f.MembershipFactory(project=m.public_project,
                                              user=m.project_member_with_perms,
                                              role__project=m.public_project,
                                              role__permissions=list(
                                                  map(lambda x: x[0],
                                                      MEMBERS_PERMISSIONS)))
    m.private_membership1 = f.MembershipFactory(
        project=m.private_project1,
        user=m.project_member_with_perms,
        role__project=m.private_project1,
        role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS)))
    f.MembershipFactory(project=m.private_project1,
                        user=m.project_member_without_perms,
                        role__project=m.private_project1,
                        role__permissions=[])
    m.private_membership2 = f.MembershipFactory(
        project=m.private_project2,
        user=m.project_member_with_perms,
        role__project=m.private_project2,
        role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS)))
    f.MembershipFactory(project=m.private_project2,
                        user=m.project_member_without_perms,
                        role__project=m.private_project2,
                        role__permissions=[])
    m.blocked_membership = f.MembershipFactory(
        project=m.blocked_project,
        user=m.project_member_with_perms,
        role__project=m.blocked_project,
        role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS)))
    f.MembershipFactory(project=m.blocked_project,
                        user=m.project_member_without_perms,
                        role__project=m.blocked_project,
                        role__permissions=[])

    f.MembershipFactory(project=m.public_project,
                        user=m.project_owner,
                        is_admin=True)

    f.MembershipFactory(project=m.private_project1,
                        user=m.project_owner,
                        is_admin=True)

    f.MembershipFactory(project=m.private_project2,
                        user=m.project_owner,
                        is_admin=True)

    f.MembershipFactory(project=m.blocked_project,
                        user=m.project_owner,
                        is_admin=True)

    m.public_user_story = f.UserStoryFactory(
        project=m.public_project,
        milestone__project=m.public_project,
        status__project=m.public_project)
    m.public_user_story = attach_userstory_extra_info(
        UserStory.objects.all()).get(id=m.public_user_story.id)

    m.private_user_story1 = f.UserStoryFactory(
        project=m.private_project1,
        milestone__project=m.private_project1,
        status__project=m.private_project1)
    m.private_user_story1 = attach_userstory_extra_info(
        UserStory.objects.all()).get(id=m.private_user_story1.id)

    m.private_user_story2 = f.UserStoryFactory(
        project=m.private_project2,
        milestone__project=m.private_project2,
        status__project=m.private_project2)
    m.private_user_story2 = attach_userstory_extra_info(
        UserStory.objects.all()).get(id=m.private_user_story2.id)

    m.blocked_user_story = f.UserStoryFactory(
        project=m.blocked_project,
        milestone__project=m.blocked_project,
        status__project=m.blocked_project)
    m.blocked_user_story = attach_userstory_extra_info(
        UserStory.objects.all()).get(id=m.blocked_user_story.id)

    return m
def data():
    m = type("Models", (object, ), {})

    m.registered_user = f.UserFactory.create()
    m.project_member_with_perms = f.UserFactory.create()
    m.project_member_without_perms = f.UserFactory.create()
    m.project_owner = f.UserFactory.create()
    m.other_user = f.UserFactory.create()

    m.public_project = f.ProjectFactory(
        is_private=False,
        anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)),
        public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)),
        owner=m.project_owner,
        userstories_csv_uuid=uuid.uuid4().hex)
    m.private_project1 = f.ProjectFactory(
        is_private=True,
        anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)),
        public_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)),
        owner=m.project_owner,
        userstories_csv_uuid=uuid.uuid4().hex)
    m.private_project2 = f.ProjectFactory(
        is_private=True,
        anon_permissions=[],
        public_permissions=[],
        owner=m.project_owner,
        userstories_csv_uuid=uuid.uuid4().hex)
    m.blocked_project = f.ProjectFactory(
        is_private=True,
        anon_permissions=[],
        public_permissions=[],
        owner=m.project_owner,
        userstories_csv_uuid=uuid.uuid4().hex,
        blocked_code=project_choices.BLOCKED_BY_STAFF)

    m.public_membership = f.MembershipFactory(project=m.public_project,
                                              user=m.project_member_with_perms,
                                              role__project=m.public_project,
                                              role__permissions=list(
                                                  map(lambda x: x[0],
                                                      MEMBERS_PERMISSIONS)))
    m.private_membership1 = f.MembershipFactory(
        project=m.private_project1,
        user=m.project_member_with_perms,
        role__project=m.private_project1,
        role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS)))
    f.MembershipFactory(project=m.private_project1,
                        user=m.project_member_without_perms,
                        role__project=m.private_project1,
                        role__permissions=[])
    m.private_membership2 = f.MembershipFactory(
        project=m.private_project2,
        user=m.project_member_with_perms,
        role__project=m.private_project2,
        role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS)))
    f.MembershipFactory(project=m.private_project2,
                        user=m.project_member_without_perms,
                        role__project=m.private_project2,
                        role__permissions=[])
    m.blocked_membership = f.MembershipFactory(
        project=m.blocked_project,
        user=m.project_member_with_perms,
        role__project=m.blocked_project,
        role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS)))
    f.MembershipFactory(project=m.blocked_project,
                        user=m.project_member_without_perms,
                        role__project=m.blocked_project,
                        role__permissions=[])

    f.MembershipFactory(project=m.public_project,
                        user=m.project_owner,
                        is_admin=True)

    f.MembershipFactory(project=m.private_project1,
                        user=m.project_owner,
                        is_admin=True)

    f.MembershipFactory(project=m.private_project2,
                        user=m.project_owner,
                        is_admin=True)

    f.MembershipFactory(project=m.blocked_project,
                        user=m.project_owner,
                        is_admin=True)

    m.public_points = f.PointsFactory(project=m.public_project)
    m.private_points1 = f.PointsFactory(project=m.private_project1)
    m.private_points2 = f.PointsFactory(project=m.private_project2)
    m.blocked_points = f.PointsFactory(project=m.blocked_project)

    m.public_role_points = f.RolePointsFactory(
        role=m.public_project.roles.all()[0],
        points=m.public_points,
        user_story__project=m.public_project,
        user_story__milestone__project=m.public_project,
        user_story__status__project=m.public_project)
    m.private_role_points1 = f.RolePointsFactory(
        role=m.private_project1.roles.all()[0],
        points=m.private_points1,
        user_story__project=m.private_project1,
        user_story__milestone__project=m.private_project1,
        user_story__status__project=m.private_project1)
    m.private_role_points2 = f.RolePointsFactory(
        role=m.private_project2.roles.all()[0],
        points=m.private_points2,
        user_story__project=m.private_project2,
        user_story__milestone__project=m.private_project2,
        user_story__status__project=m.private_project2)
    m.blocked_role_points = f.RolePointsFactory(
        role=m.blocked_project.roles.all()[0],
        points=m.blocked_points,
        user_story__project=m.blocked_project,
        user_story__milestone__project=m.blocked_project,
        user_story__status__project=m.blocked_project)

    m.public_user_story = m.public_role_points.user_story
    m.private_user_story1 = m.private_role_points1.user_story
    m.private_user_story2 = m.private_role_points2.user_story
    m.blocked_user_story = m.blocked_role_points.user_story

    return m
def data():
    m = type("Models", (object, ), {})

    m.registered_user = f.UserFactory.create()
    m.project_member_with_perms = f.UserFactory.create()
    m.project_member_without_perms = f.UserFactory.create()
    m.project_owner = f.UserFactory.create()
    m.other_user = f.UserFactory.create()

    m.public_project = f.ProjectFactory(
        is_private=False,
        anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)),
        public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)),
        owner=m.project_owner)
    m.private_project1 = f.ProjectFactory(
        is_private=True,
        anon_permissions=list(map(lambda x: x[0], ANON_PERMISSIONS)),
        public_permissions=list(map(lambda x: x[0], USER_PERMISSIONS)),
        owner=m.project_owner)
    m.private_project2 = f.ProjectFactory(is_private=True,
                                          anon_permissions=[],
                                          public_permissions=[],
                                          owner=m.project_owner)

    m.public_membership = f.MembershipFactory(project=m.public_project,
                                              user=m.project_member_with_perms,
                                              role__project=m.public_project,
                                              role__permissions=list(
                                                  map(lambda x: x[0],
                                                      MEMBERS_PERMISSIONS)))
    m.private_membership1 = f.MembershipFactory(
        project=m.private_project1,
        user=m.project_member_with_perms,
        role__project=m.private_project1,
        role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS)))
    f.MembershipFactory(project=m.private_project1,
                        user=m.project_member_without_perms,
                        role__project=m.private_project1,
                        role__permissions=[])
    m.private_membership2 = f.MembershipFactory(
        project=m.private_project2,
        user=m.project_member_with_perms,
        role__project=m.private_project2,
        role__permissions=list(map(lambda x: x[0], MEMBERS_PERMISSIONS)))
    f.MembershipFactory(project=m.private_project2,
                        user=m.project_member_without_perms,
                        role__project=m.private_project2,
                        role__permissions=[])

    m.public_points = f.PointsFactory(project=m.public_project)
    m.private_points1 = f.PointsFactory(project=m.private_project1)
    m.private_points2 = f.PointsFactory(project=m.private_project2)

    m.public_role_points = f.RolePointsFactory(
        role=m.public_project.roles.all()[0],
        points=m.public_points,
        user_story__project=m.public_project)
    m.private_role_points1 = f.RolePointsFactory(
        role=m.private_project1.roles.all()[0],
        points=m.private_points1,
        user_story__project=m.private_project1)
    m.private_role_points2 = f.RolePointsFactory(
        role=m.private_project2.roles.all()[0],
        points=m.private_points2,
        user_story__project=m.private_project2)

    m.public_user_story = m.public_role_points.user_story
    m.private_user_story1 = m.private_role_points1.user_story
    m.private_user_story2 = m.private_role_points2.user_story

    return m