Esempio n. 1
0
def test_project_defined_points(client, data):
    project_stats = get_stats_for_project(data.project)
    assert project_stats["defined_points_per_role"] == {data.role1.pk: 63}
    data.role_points1.role = data.role2
    data.role_points1.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["defined_points_per_role"] == {data.role1.pk: 62, data.role2.pk: 1}
Esempio n. 2
0
def test_project_defined_points(client, data):
    project_stats = get_stats_for_project(data.project)
    assert project_stats["defined_points_per_role"] == {data.role1.pk: 63, data.role2.pk: 0}
    data.user_story1.role_points.filter(role=data.role1).update(points=data.default_points)
    data.user_story1.role_points.filter(role=data.role2).update(points=data.points1)
    project_stats = get_stats_for_project(data.project)
    assert project_stats["defined_points_per_role"] == {data.role1.pk: 62, data.role2.pk: 1}
Esempio n. 3
0
def test_project_assigned_points(client, data):
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {
        data.role1.pk: 48,
        data.role2.pk: 0
    }
    data.user_story1.milestone = data.user_story6.milestone
    data.user_story1.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {
        data.role1.pk: 49,
        data.role2.pk: 0
    }
    data.user_story2.milestone = data.user_story6.milestone
    data.user_story2.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {
        data.role1.pk: 51,
        data.role2.pk: 0
    }
    data.user_story3.milestone = data.user_story6.milestone
    data.user_story3.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {
        data.role1.pk: 55,
        data.role2.pk: 0
    }
    data.user_story4.milestone = data.user_story6.milestone
    data.user_story4.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {
        data.role1.pk: 63,
        data.role2.pk: 0
    }
Esempio n. 4
0
def test_project_defined_points(client, data):
    project_stats = get_stats_for_project(data.project)
    assert project_stats["defined_points_per_role"] == {data.role1.pk: 63, data.role2.pk: 0}
    data.user_story1.role_points.filter(role=data.role1).update(points=data.default_points)
    data.user_story1.role_points.filter(role=data.role2).update(points=data.points1)
    project_stats = get_stats_for_project(data.project)
    assert project_stats["defined_points_per_role"] == {data.role1.pk: 62, data.role2.pk: 1}
Esempio n. 5
0
def test_project_defined_points(client, data):
    project_stats = get_stats_for_project(data.project)
    assert project_stats["defined_points_per_role"] == {data.role1.pk: 63}
    data.role_points1.role = data.role2
    data.role_points1.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["defined_points_per_role"] == {
        data.role1.pk: 62,
        data.role2.pk: 1
    }
Esempio n. 6
0
def test_project_closed_points(client, data):
    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points_per_role"] == {}
    data.user_story1.is_closed = True
    data.user_story1.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points_per_role"] == {data.role1.pk: 1, data.role2.pk: 0}
    data.user_story2.is_closed = True
    data.user_story2.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points_per_role"] == {data.role1.pk: 3, data.role2.pk: 0}
    data.user_story3.is_closed = True
    data.user_story3.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points_per_role"] == {data.role1.pk: 7, data.role2.pk: 0}
    data.user_story4.is_closed = True
    data.user_story4.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points_per_role"] == {data.role1.pk: 15, data.role2.pk: 0}
    data.user_story5.is_closed = True
    data.user_story5.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points_per_role"] == {data.role1.pk: 31, data.role2.pk: 0}
    data.user_story6.is_closed = True
    data.user_story6.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points_per_role"] == {data.role1.pk: 63, data.role2.pk: 0}

    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points"] == 63
    assert project_stats["speed"] == 24
Esempio n. 7
0
def test_project_closed_points(client, data):
    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points_per_role"] == {}
    data.user_story1.is_closed = True
    data.user_story1.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points_per_role"] == {data.role1.pk: 1, data.role2.pk: 0}
    data.user_story2.is_closed = True
    data.user_story2.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points_per_role"] == {data.role1.pk: 3, data.role2.pk: 0}
    data.user_story3.is_closed = True
    data.user_story3.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points_per_role"] == {data.role1.pk: 7, data.role2.pk: 0}
    data.user_story4.is_closed = True
    data.user_story4.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points_per_role"] == {data.role1.pk: 15, data.role2.pk: 0}
    data.user_story5.is_closed = True
    data.user_story5.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points_per_role"] == {data.role1.pk: 31, data.role2.pk: 0}
    data.user_story6.is_closed = True
    data.user_story6.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points_per_role"] == {data.role1.pk: 63, data.role2.pk: 0}

    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points"] == 63
    assert project_stats["speed"] == 24
Esempio n. 8
0
def test_project_closed_points(client, data):
    assert data.project.closed_points == {}
    data.role_points1.role = data.role2
    data.role_points1.save()
    assert data.project.closed_points == {}
    data.user_story1.is_closed = True
    data.user_story1.save()
    assert data.project.closed_points == {data.role2.pk: 1}
    data.user_story2.is_closed = True
    data.user_story2.save()
    assert data.project.closed_points == {data.role1.pk: 2, data.role2.pk: 1}
    data.user_story3.is_closed = True
    data.user_story3.save()
    assert data.project.closed_points == {data.role1.pk: 6, data.role2.pk: 1}
    data.user_story4.is_closed = True
    data.user_story4.save()
    assert data.project.closed_points == {data.role1.pk: 14, data.role2.pk: 1}

    data.user_story5.is_closed = True
    data.user_story5.save()
    assert data.project.closed_points == {data.role1.pk: 30, data.role2.pk: 1}
    data.user_story6.is_closed = True
    data.user_story6.save()
    assert data.project.closed_points == {data.role1.pk: 62, data.role2.pk: 1}

    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points"] == 63
    assert project_stats["speed"] == 24
Esempio n. 9
0
def test_project_closed_points(client, data):
    assert data.project.closed_points == {}
    data.role_points1.role = data.role2
    data.role_points1.save()
    assert data.project.closed_points == {}
    data.user_story1.is_closed = True
    data.user_story1.save()
    assert data.project.closed_points == {data.role2.pk: 1}
    data.user_story2.is_closed = True
    data.user_story2.save()
    assert data.project.closed_points == {data.role1.pk: 2, data.role2.pk: 1}
    data.user_story3.is_closed = True
    data.user_story3.save()
    assert data.project.closed_points == {data.role1.pk: 6, data.role2.pk: 1}
    data.user_story4.is_closed = True
    data.user_story4.save()
    assert data.project.closed_points == {data.role1.pk: 14, data.role2.pk: 1}

    data.user_story5.is_closed = True
    data.user_story5.save()
    assert data.project.closed_points == {data.role1.pk: 30, data.role2.pk: 1}
    data.user_story6.is_closed = True
    data.user_story6.save()
    assert data.project.closed_points == {data.role1.pk: 62, data.role2.pk: 1}

    project_stats = get_stats_for_project(data.project)
    assert project_stats["closed_points"] == 63
    assert project_stats["speed"] == 24
Esempio n. 10
0
def test_project_assigned_points(client, data):
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {data.role1.pk: 48, data.role2.pk: 0}
    data.user_story1.milestone = data.user_story6.milestone
    data.user_story1.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {data.role1.pk: 49, data.role2.pk: 0}
    data.user_story2.milestone = data.user_story6.milestone
    data.user_story2.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {data.role1.pk: 51, data.role2.pk: 0}
    data.user_story3.milestone = data.user_story6.milestone
    data.user_story3.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {data.role1.pk: 55, data.role2.pk: 0}
    data.user_story4.milestone = data.user_story6.milestone
    data.user_story4.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {data.role1.pk: 63, data.role2.pk: 0}
Esempio n. 11
0
def test_project_assigned_points(client, data):
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {data.role1.pk: 48}
    data.role_points1.role = data.role2
    data.role_points1.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {data.role1.pk: 48}
    data.user_story1.milestone = data.milestone
    data.user_story1.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {
        data.role1.pk: 48,
        data.role2.pk: 1
    }
    data.user_story2.milestone = data.milestone
    data.user_story2.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {
        data.role1.pk: 50,
        data.role2.pk: 1
    }
    data.user_story3.milestone = data.milestone
    data.user_story3.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {
        data.role1.pk: 54,
        data.role2.pk: 1
    }
    data.user_story4.milestone = data.milestone
    data.user_story4.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {
        data.role1.pk: 62,
        data.role2.pk: 1
    }
Esempio n. 12
0
def test_project_assigned_points(client, data):
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {data.role1.pk: 48}
    data.role_points1.role = data.role2
    data.role_points1.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {data.role1.pk: 48}
    data.user_story1.milestone = data.milestone
    data.user_story1.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {data.role1.pk: 48, data.role2.pk: 1}
    data.user_story2.milestone = data.milestone
    data.user_story2.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {data.role1.pk: 50, data.role2.pk: 1}
    data.user_story3.milestone = data.milestone
    data.user_story3.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {data.role1.pk: 54, data.role2.pk: 1}
    data.user_story4.milestone = data.milestone
    data.user_story4.save()
    project_stats = get_stats_for_project(data.project)
    assert project_stats["assigned_points_per_role"] == {data.role1.pk: 62, data.role2.pk: 1}
Esempio n. 13
0
    def handle(self, *args, **options):
        # Prevent events emission when sample data is running
        disconnect_events_signals()

        self.users = [User.objects.get(is_superuser=True)]

        # create users
        if BASE_USERS:
            for username, full_name, email in BASE_USERS:
                self.users.append(self.create_user(username=username, full_name=full_name, email=email))
        else:
            for x in range(NUM_USERS):
                self.users.append(self.create_user(counter=x))

        # create project
        for x in range(NUM_PROJECTS + NUM_EMPTY_PROJECTS):
            project = self.create_project(x, is_private=(x in [2, 4] or self.sd.boolean()))

            # added memberships
            computable_project_roles = set()
            for user in self.users:
                if user == project.owner:
                    continue

                role = self.sd.db_object_from_queryset(project.roles.all())

                Membership.objects.create(email=user.email,
                                          project=project,
                                          role=role,
                                          is_owner=self.sd.boolean(),
                                          user=user)

                if role.computable:
                    computable_project_roles.add(role)

            # added invitations
            for i in range(NUM_INVITATIONS):
                role = self.sd.db_object_from_queryset(project.roles.all())

                Membership.objects.create(email=self.sd.email(),
                                          project=project,
                                          role=role,
                                          is_owner=self.sd.boolean(),
                                          token=''.join(random.sample('abcdef0123456789', 10)))

                if role.computable:
                    computable_project_roles.add(role)

            # added custom attributes
            if self.sd.boolean:
                for i in range(1, 4):
                    UserStoryCustomAttribute.objects.create(name=self.sd.words(1, 3),
                                                            description=self.sd.words(3, 12),
                                                            type=self.sd.choice(TYPES_CHOICES)[0],
                                                            project=project,
                                                            order=i)
            if self.sd.boolean:
                for i in range(1, 4):
                    TaskCustomAttribute.objects.create(name=self.sd.words(1, 3),
                                                       description=self.sd.words(3, 12),
                                                       type=self.sd.choice(TYPES_CHOICES)[0],
                                                       project=project,
                                                       order=i)
            if self.sd.boolean:
                for i in range(1, 4):
                    IssueCustomAttribute.objects.create(name=self.sd.words(1, 3),
                                                        description=self.sd.words(3, 12),
                                                        type=self.sd.choice(TYPES_CHOICES)[0],
                                                        project=project,
                                                        order=i)


            if x < NUM_PROJECTS:
                start_date = now() - datetime.timedelta(55)

                # create milestones
                for y in range(self.sd.int(*NUM_MILESTONES)):
                    end_date = start_date + datetime.timedelta(15)
                    milestone = self.create_milestone(project, start_date, end_date)

                    # create uss asociated to milestones
                    for z in range(self.sd.int(*NUM_USS)):
                        us = self.create_us(project, milestone, computable_project_roles)

                        # create tasks
                        rang = NUM_TASKS_FINISHED if start_date <= now() and end_date <= now() else NUM_TASKS
                        for w in range(self.sd.int(*rang)):
                            if start_date <= now() and end_date <= now():
                                task = self.create_task(project, milestone, us, start_date,
                                                        end_date, closed=True)
                            elif start_date <= now() and end_date >= now():
                                task = self.create_task(project, milestone, us, start_date,
                                                        now())
                            else:
                                # No task on not initiated milestones
                                pass

                    start_date = end_date

                # created unassociated uss.
                for y in range(self.sd.int(*NUM_USS_BACK)):
                    us = self.create_us(project, None, computable_project_roles)

                # create bugs.
                for y in range(self.sd.int(*NUM_ISSUES)):
                    bug = self.create_bug(project)

                # create a wiki page
                wiki_page = self.create_wiki(project, "home")

            # Set a value to total_story_points to show the deadline in the backlog
            project_stats = get_stats_for_project(project)
            defined_points = project_stats["defined_points"]
            project.total_story_points = int(defined_points * self.sd.int(5,12) / 10)
            project.save()

            self.create_likes(project)
Esempio n. 14
0
    def handle(self, *args, **options):
        # Prevent events emission when sample data is running
        disconnect_events_signals()

        self.users = [User.objects.get(is_superuser=True)]

        # create users
        if BASE_USERS:
            for username, full_name, email in BASE_USERS:
                self.users.append(
                    self.create_user(username=username,
                                     full_name=full_name,
                                     email=email))
        else:
            for x in range(NUM_USERS):
                self.users.append(self.create_user(counter=x))

        # create project
        projects_range = range(NUM_PROJECTS + NUM_EMPTY_PROJECTS +
                               NUM_BLOCKED_PROJECTS)
        empty_projects_range = range(NUM_PROJECTS,
                                     NUM_PROJECTS + NUM_EMPTY_PROJECTS)
        blocked_projects_range = range(
            NUM_PROJECTS + NUM_EMPTY_PROJECTS,
            NUM_PROJECTS + NUM_EMPTY_PROJECTS + NUM_BLOCKED_PROJECTS)

        for x in projects_range:
            project = self.create_project(
                x,
                is_private=x in [2, 4],
                blocked_code=BLOCKED_BY_STAFF
                if x in (blocked_projects_range) else None)

            # added memberships
            computable_project_roles = set()
            for user in self.users:
                if user == project.owner:
                    continue

                role = self.sd.db_object_from_queryset(project.roles.all())

                Membership.objects.create(email=user.email,
                                          project=project,
                                          role=role,
                                          is_admin=self.sd.boolean(),
                                          user=user)

                if role.computable:
                    computable_project_roles.add(role)

            # Delete a random member so all the projects doesn't have the same team
            Membership.objects.filter(project=project).exclude(
                user=project.owner).order_by("?").first().delete()

            # added invitations
            for i in range(NUM_INVITATIONS):
                role = self.sd.db_object_from_queryset(project.roles.all())

                Membership.objects.create(email=self.sd.email(),
                                          project=project,
                                          role=role,
                                          is_admin=self.sd.boolean(),
                                          token=self.sd.hex_chars(10, 10))

                if role.computable:
                    computable_project_roles.add(role)

            # If the project isn't empty
            if x not in empty_projects_range:
                # added custom attributes
                names = set([self.sd.words(1, 3) for i in range(1, 6)])
                for name in names:
                    EpicCustomAttribute.objects.create(
                        name=name,
                        description=self.sd.words(3, 12),
                        type=self.sd.choice(TYPES_CHOICES)[0],
                        project=project,
                        order=i)
                names = set([self.sd.words(1, 3) for i in range(1, 6)])
                for name in names:
                    UserStoryCustomAttribute.objects.create(
                        name=name,
                        description=self.sd.words(3, 12),
                        type=self.sd.choice(TYPES_CHOICES)[0],
                        project=project,
                        order=i)
                names = set([self.sd.words(1, 3) for i in range(1, 6)])
                for name in names:
                    TaskCustomAttribute.objects.create(
                        name=name,
                        description=self.sd.words(3, 12),
                        type=self.sd.choice(TYPES_CHOICES)[0],
                        project=project,
                        order=i)
                names = set([self.sd.words(1, 3) for i in range(1, 6)])
                for name in names:
                    IssueCustomAttribute.objects.create(
                        name=name,
                        description=self.sd.words(3, 12),
                        type=self.sd.choice(TYPES_CHOICES)[0],
                        project=project,
                        order=i)

                start_date = now() - datetime.timedelta(55)

                # create milestones
                for y in range(self.sd.int(*NUM_MILESTONES)):
                    end_date = start_date + datetime.timedelta(15)
                    milestone = self.create_milestone(project, start_date,
                                                      end_date)

                    # create uss asociated to milestones
                    for z in range(self.sd.int(*NUM_USS)):
                        us = self.create_us(project, milestone,
                                            computable_project_roles)

                        # create tasks
                        rang = NUM_TASKS_FINISHED if start_date <= now(
                        ) and end_date <= now() else NUM_TASKS
                        for w in range(self.sd.int(*rang)):
                            if start_date <= now() and end_date <= now():
                                task = self.create_task(project,
                                                        milestone,
                                                        us,
                                                        start_date,
                                                        end_date,
                                                        closed=True)
                            elif start_date <= now() and end_date >= now():
                                task = self.create_task(
                                    project, milestone, us, start_date, now())
                            else:
                                # No task on not initiated milestones
                                pass

                    start_date = end_date

                # created unassociated uss.
                for y in range(self.sd.int(*NUM_USS_BACK)):
                    us = self.create_us(project, None,
                                        computable_project_roles)

                # create bugs.
                for y in range(self.sd.int(*NUM_ISSUES)):
                    bug = self.create_bug(project)

                # create a wiki pages and wiki links
                wiki_page = self.create_wiki_page(project, "home")

                for y in range(self.sd.int(*NUM_WIKI_LINKS)):
                    wiki_link = self.create_wiki_link(project)
                    if self.sd.boolean():
                        self.create_wiki_page(project, wiki_link.href)

                # create epics
                for y in range(self.sd.int(*NUM_EPICS)):
                    epic = self.create_epic(project)

            project.refresh_from_db()

            # Set color for some tags:
            for tag in project.tags_colors:
                if self.sd.boolean():
                    tag[1] = self.generate_color(tag[0])

            # Set a value to total_story_points to show the deadline in the backlog
            project_stats = get_stats_for_project(project)
            defined_points = project_stats["defined_points"]
            project.total_story_points = int(defined_points *
                                             self.sd.int(5, 12) / 10)
            project.save()

            self.create_likes(project)
Esempio n. 15
0
    def handle(self, *args, **options):
        # Prevent events emission when sample data is running
        disconnect_events_signals()

        self.users = [User.objects.get(is_superuser=True)]

        # create users
        if BASE_USERS:
            for username, full_name, email in BASE_USERS:
                self.users.append(self.create_user(username=username, full_name=full_name, email=email))
        else:
            for x in range(NUM_USERS):
                self.users.append(self.create_user(counter=x))

        # create project
        for x in range(NUM_PROJECTS + NUM_EMPTY_PROJECTS):
            project = self.create_project(x, is_private=(x in [2, 4] or self.sd.boolean()))

            # added memberships
            computable_project_roles = set()
            for user in self.users:
                if user == project.owner:
                    continue

                role = self.sd.db_object_from_queryset(project.roles.all())

                Membership.objects.create(email=user.email,
                                          project=project,
                                          role=role,
                                          is_owner=self.sd.boolean(),
                                          user=user)

                if role.computable:
                    computable_project_roles.add(role)

            # added invitations
            for i in range(NUM_INVITATIONS):
                role = self.sd.db_object_from_queryset(project.roles.all())

                Membership.objects.create(email=self.sd.email(),
                                          project=project,
                                          role=role,
                                          is_owner=self.sd.boolean(),
                                          token=''.join(random.sample('abcdef0123456789', 10)))

                if role.computable:
                    computable_project_roles.add(role)

            # added custom attributes
            if self.sd.boolean:
                for i in range(1, 4):
                    UserStoryCustomAttribute.objects.create(name=self.sd.words(1, 3),
                                                            description=self.sd.words(3, 12),
                                                            type=self.sd.choice(TYPES_CHOICES)[0],
                                                            project=project,
                                                            order=i)
            if self.sd.boolean:
                for i in range(1, 4):
                    TaskCustomAttribute.objects.create(name=self.sd.words(1, 3),
                                                       description=self.sd.words(3, 12),
                                                       type=self.sd.choice(TYPES_CHOICES)[0],
                                                       project=project,
                                                       order=i)
            if self.sd.boolean:
                for i in range(1, 4):
                    IssueCustomAttribute.objects.create(name=self.sd.words(1, 3),
                                                        description=self.sd.words(3, 12),
                                                        type=self.sd.choice(TYPES_CHOICES)[0],
                                                        project=project,
                                                        order=i)


            if x < NUM_PROJECTS:
                start_date = now() - datetime.timedelta(55)

                # create milestones
                for y in range(self.sd.int(*NUM_MILESTONES)):
                    end_date = start_date + datetime.timedelta(15)
                    milestone = self.create_milestone(project, start_date, end_date)

                    # create uss asociated to milestones
                    for z in range(self.sd.int(*NUM_USS)):
                        us = self.create_us(project, milestone, computable_project_roles)

                        # create tasks
                        rang = NUM_TASKS_FINISHED if start_date <= now() and end_date <= now() else NUM_TASKS
                        for w in range(self.sd.int(*rang)):
                            if start_date <= now() and end_date <= now():
                                task = self.create_task(project, milestone, us, start_date,
                                                        end_date, closed=True)
                            elif start_date <= now() and end_date >= now():
                                task = self.create_task(project, milestone, us, start_date,
                                                        now())
                            else:
                                # No task on not initiated milestones
                                pass

                    start_date = end_date

                # created unassociated uss.
                for y in range(self.sd.int(*NUM_USS_BACK)):
                    us = self.create_us(project, None, computable_project_roles)

                # create bugs.
                for y in range(self.sd.int(*NUM_ISSUES)):
                    bug = self.create_bug(project)

                # create a wiki page
                wiki_page = self.create_wiki(project, "home")

            # Set a value to total_story_points to show the deadline in the backlog
            get_stats_for_project(project)
            project.total_story_points = int(project._defined_points * self.sd.int(5,12) / 10)
            project.save()

            self.create_likes(project)
Esempio n. 16
0
    def handle(self, *args, **options):
        # Prevent events emission when sample data is running
        disconnect_events_signals()

        self.users = [User.objects.get(is_superuser=True)]

        # create users
        if BASE_USERS:
            for username, full_name, email in BASE_USERS:
                self.users.append(self.create_user(username=username, full_name=full_name, email=email))
        else:
            for x in range(NUM_USERS):
                self.users.append(self.create_user(counter=x))

        # create project
        projects_range = range(NUM_PROJECTS + NUM_EMPTY_PROJECTS + NUM_BLOCKED_PROJECTS)
        empty_projects_range = range(NUM_PROJECTS, NUM_PROJECTS + NUM_EMPTY_PROJECTS )
        blocked_projects_range = range(
            NUM_PROJECTS + NUM_EMPTY_PROJECTS,
            NUM_PROJECTS + NUM_EMPTY_PROJECTS + NUM_BLOCKED_PROJECTS
        )

        for x in projects_range:
            project = self.create_project(
                x,
                is_private=x in [2, 4],
                blocked_code = BLOCKED_BY_STAFF if x in(blocked_projects_range) else None
            )

            # added memberships
            computable_project_roles = set()
            for user in self.users:
                if user == project.owner:
                    continue

                role = self.sd.db_object_from_queryset(project.roles.all())

                Membership.objects.create(email=user.email,
                                          project=project,
                                          role=role,
                                          is_admin=self.sd.boolean(),
                                          user=user)

                if role.computable:
                    computable_project_roles.add(role)

            # Delete a random member so all the projects doesn't have the same team
            Membership.objects.filter(project=project).exclude(user=project.owner).order_by("?").first().delete()

            # added invitations
            for i in range(NUM_INVITATIONS):
                role = self.sd.db_object_from_queryset(project.roles.all())

                Membership.objects.create(email=self.sd.email(),
                                          project=project,
                                          role=role,
                                          is_admin=self.sd.boolean(),
                                          token=self.sd.hex_chars(10,10))

                if role.computable:
                    computable_project_roles.add(role)

            # If the project isn't empty
            if x not in empty_projects_range:
                # added custom attributes
                names = set([self.sd.words(1, 3) for i in range(1, 6)])
                for name in names:
                    EpicCustomAttribute.objects.create(name=name,
                                                       description=self.sd.words(3, 12),
                                                       type=self.sd.choice(TYPES_CHOICES)[0],
                                                       project=project,
                                                       order=i)
                names = set([self.sd.words(1, 3) for i in range(1, 6)])
                for name in names:
                    UserStoryCustomAttribute.objects.create(name=name,
                                                            description=self.sd.words(3, 12),
                                                            type=self.sd.choice(TYPES_CHOICES)[0],
                                                            project=project,
                                                            order=i)
                names = set([self.sd.words(1, 3) for i in range(1, 6)])
                for name in names:
                    TaskCustomAttribute.objects.create(name=name,
                                                       description=self.sd.words(3, 12),
                                                       type=self.sd.choice(TYPES_CHOICES)[0],
                                                       project=project,
                                                       order=i)
                names = set([self.sd.words(1, 3) for i in range(1, 6)])
                for name in names:
                    IssueCustomAttribute.objects.create(name=name,
                                                        description=self.sd.words(3, 12),
                                                        type=self.sd.choice(TYPES_CHOICES)[0],
                                                        project=project,
                                                        order=i)

                start_date = now() - datetime.timedelta(55)

                # create milestones
                for y in range(self.sd.int(*NUM_MILESTONES)):
                    end_date = start_date + datetime.timedelta(15)
                    milestone = self.create_milestone(project, start_date, end_date)

                    # create uss asociated to milestones
                    for z in range(self.sd.int(*NUM_USS)):
                        us = self.create_us(project, milestone, computable_project_roles)

                        # create tasks
                        rang = NUM_TASKS_FINISHED if start_date <= now() and end_date <= now() else NUM_TASKS
                        for w in range(self.sd.int(*rang)):
                            if start_date <= now() and end_date <= now():
                                task = self.create_task(project, milestone, us, start_date,
                                                        end_date, closed=True)
                            elif start_date <= now() and end_date >= now():
                                task = self.create_task(project, milestone, us, start_date,
                                                        now())
                            else:
                                # No task on not initiated milestones
                                pass

                    start_date = end_date

                # created unassociated uss.
                for y in range(self.sd.int(*NUM_USS_BACK)):
                    us = self.create_us(project, None, computable_project_roles)

                # create bugs.
                for y in range(self.sd.int(*NUM_ISSUES)):
                    bug = self.create_bug(project)

                # create a wiki pages and wiki links
                wiki_page = self.create_wiki_page(project, "home")

                for y in range(self.sd.int(*NUM_WIKI_LINKS)):
                    wiki_link = self.create_wiki_link(project)
                    if self.sd.boolean():
                        self.create_wiki_page(project, wiki_link.href)

                # create epics
                for y in range(self.sd.int(*NUM_EPICS)):
                    epic = self.create_epic(project)

            project.refresh_from_db()

            # Set color for some tags:
            for tag in project.tags_colors:
                if self.sd.boolean():
                    tag[1] = self.generate_color(tag[0])

            # Set a value to total_story_points to show the deadline in the backlog
            project_stats = get_stats_for_project(project)
            defined_points = project_stats["defined_points"]
            project.total_story_points = int(defined_points * self.sd.int(5,12) / 10)
            project.save()

            self.create_likes(project)