当前位置: 首页>>代码示例>>Python>>正文


Python services.get_voters函数代码示例

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


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

示例1: test_get_voters

def test_get_voters():
    f.UserFactory()
    project = f.ProjectFactory()
    project_type = ContentType.objects.get_for_model(project)
    vote = f.VoteFactory(content_type=project_type, object_id=project.id)

    assert list(votes.get_voters(project)) == [vote.user]
开发者ID:0-T-0,项目名称:taiga-back,代码行数:7,代码来源:test_votes.py

示例2: issues_to_csv

def issues_to_csv(project, queryset):
    csv_data = io.StringIO()
    fieldnames = [
        "ref",
        "subject",
        "description",
        "milestone",
        "owner",
        "owner_full_name",
        "assigned_to",
        "assigned_to_full_name",
        "status",
        "severity",
        "priority",
        "type",
        "is_closed",
        "attachments",
        "external_reference",
        "tags",
        "watchers",
        "voters",
    ]
    for custom_attr in project.issuecustomattributes.all():
        fieldnames.append(custom_attr.name)

    writer = csv.DictWriter(csv_data, fieldnames=fieldnames)
    writer.writeheader()
    for issue in queryset:
        issue_data = {
            "ref": issue.ref,
            "subject": issue.subject,
            "description": issue.description,
            "milestone": issue.milestone.name if issue.milestone else None,
            "owner": issue.owner.username,
            "owner_full_name": issue.owner.get_full_name(),
            "assigned_to": issue.assigned_to.username if issue.assigned_to else None,
            "assigned_to_full_name": issue.assigned_to.get_full_name() if issue.assigned_to else None,
            "status": issue.status.name,
            "severity": issue.severity.name,
            "priority": issue.priority.name,
            "type": issue.type.name,
            "is_closed": issue.is_closed,
            "attachments": issue.attachments.count(),
            "external_reference": issue.external_reference,
            "tags": ",".join(issue.tags or []),
            "watchers": [u.id for u in issue.get_watchers()],
            "voters": votes_services.get_voters(issue).count(),
        }

        for custom_attr in project.issuecustomattributes.all():
            value = issue.custom_attributes_values.attributes_values.get(str(custom_attr.id), None)
            issue_data[custom_attr.name] = value

        writer.writerow(issue_data)

    return csv_data
开发者ID:ndjido,项目名称:taiga-back,代码行数:56,代码来源:services.py

示例3: retrieve

    def retrieve(self, request, *args, **kwargs):
        pk = kwargs.get("pk", None)
        issue_id = kwargs.get("issue_id", None)
        issue = get_object_or_404(models.Issue, pk=issue_id)

        self.check_permissions(request, 'retrieve', issue)

        try:
            self.object = votes_service.get_voters(issue).get(pk=pk)
        except User.DoesNotExist:
            raise Http404

        serializer = self.get_serializer(self.object)
        return response.Ok(serializer.data)
开发者ID:lcyhff,项目名称:taiga-back,代码行数:14,代码来源:api.py

示例4: retrieve

    def retrieve(self, request, *args, **kwargs):
        pk = kwargs.get("pk", None)
        resource_id = kwargs.get("resource_id", None)
        resource = get_object_or_404(self.resource_model, pk=resource_id)

        self.check_permissions(request, "retrieve", resource)

        try:
            self.object = services.get_voters(resource).get(pk=pk)
        except ObjectDoesNotExist:  # or User.DoesNotExist
            return response.NotFound()

        serializer = self.get_serializer(self.object)
        return response.Ok(serializer.data)
开发者ID:rubixware,项目名称:taiga-back,代码行数:14,代码来源:viewsets.py

示例5: tasks_to_csv

def tasks_to_csv(project, queryset):
    csv_data = io.StringIO()
    fieldnames = ["ref", "subject", "description", "user_story", "milestone", "owner",
                  "owner_full_name", "assigned_to", "assigned_to_full_name",
                  "status", "is_iocaine", "is_closed", "us_order",
                  "taskboard_order", "attachments", "external_reference", "tags",
                  "watchers", "voters"]
    for custom_attr in project.taskcustomattributes.all():
        fieldnames.append(custom_attr.name)

    writer = csv.DictWriter(csv_data, fieldnames=fieldnames)
    writer.writeheader()
    for task in queryset:
        task_data = {
            "ref": task.ref,
            "subject": task.subject,
            "description": task.description,
            "user_story": task.user_story.ref if task.user_story else None,
            "milestone": task.milestone.name if task.milestone else None,
            "owner": task.owner.username if task.owner else None,
            "owner_full_name": task.owner.get_full_name() if task.owner else None,
            "assigned_to": task.assigned_to.username if task.assigned_to else None,
            "assigned_to_full_name": task.assigned_to.get_full_name() if task.assigned_to else None,
            "status": task.status.name,
            "is_iocaine": task.is_iocaine,
            "is_closed": task.status.is_closed,
            "us_order": task.us_order,
            "taskboard_order": task.taskboard_order,
            "attachments": task.attachments.count(),
            "external_reference": task.external_reference,
            "tags": ",".join(task.tags or []),
            "watchers": [u.id for u in task.get_watchers()],
            "voters": votes_services.get_voters(task).count(),
        }
        for custom_attr in project.taskcustomattributes.all():
            value = task.custom_attributes_values.attributes_values.get(str(custom_attr.id), None)
            task_data[custom_attr.name] = value

        writer.writerow(task_data)

    return csv_data
开发者ID:cubettech,项目名称:taiga-back,代码行数:41,代码来源:services.py

示例6: get_votes

 def get_votes(self, obj):
     return [x.email for x in votes_service.get_voters(obj)]
开发者ID:andrewchenshx,项目名称:taiga-back,代码行数:2,代码来源:serializers.py

示例7: userstories_to_csv

def userstories_to_csv(project,queryset):
    csv_data = io.StringIO()
    fieldnames = ["ref", "subject", "description", "milestone", "owner",
                  "owner_full_name", "assigned_to", "assigned_to_full_name",
                  "status", "is_closed"]
    for role in project.roles.filter(computable=True).order_by('name'):
        fieldnames.append("{}-points".format(role.slug))
    fieldnames.append("total-points")

    fieldnames += ["backlog_order", "sprint_order", "kanban_order",
                   "created_date", "modified_date", "finish_date",
                   "client_requirement", "team_requirement", "attachments",
                   "generated_from_issue", "external_reference", "tasks",
                   "tags",
                   "watchers", "voters"]

    for custom_attr in project.userstorycustomattributes.all():
        fieldnames.append(custom_attr.name)

    writer = csv.DictWriter(csv_data, fieldnames=fieldnames)
    writer.writeheader()
    for us in queryset:
        row = {
            "ref": us.ref,
            "subject": us.subject,
            "description": us.description,
            "milestone": us.milestone.name if us.milestone else None,
            "owner": us.owner.username if us.owner else None,
            "owner_full_name": us.owner.get_full_name() if us.owner else None,
            "assigned_to": us.assigned_to.username if us.assigned_to else None,
            "assigned_to_full_name": us.assigned_to.get_full_name() if us.assigned_to else None,
            "status": us.status.name,
            "is_closed": us.is_closed,
            "backlog_order": us.backlog_order,
            "sprint_order": us.sprint_order,
            "kanban_order": us.kanban_order,
            "created_date": us.created_date,
            "modified_date": us.modified_date,
            "finish_date": us.finish_date,
            "client_requirement": us.client_requirement,
            "team_requirement": us.team_requirement,
            "attachments": us.attachments.count(),
            "generated_from_issue": us.generated_from_issue.ref if us.generated_from_issue else None,
            "external_reference": us.external_reference,
            "tasks": ",".join([str(task.ref) for task in us.tasks.all()]),
            "tags": ",".join(us.tags or []),
            "watchers": [u.id for u in us.get_watchers()],
            "voters": votes_services.get_voters(us).count(),
        }

        for role in us.project.roles.filter(computable=True).order_by('name'):
            if us.role_points.filter(role_id=role.id).count() == 1:
                row["{}-points".format(role.slug)] = us.role_points.get(role_id=role.id).points.value
            else:
                row["{}-points".format(role.slug)] = 0
        row['total-points'] = us.get_total_points()

        for custom_attr in project.userstorycustomattributes.all():
            value = us.custom_attributes_values.attributes_values.get(str(custom_attr.id), None)
            row[custom_attr.name] = value

        writer.writerow(row)

    return csv_data
开发者ID:cubettech,项目名称:taiga-back,代码行数:64,代码来源:services.py

示例8: get_queryset

 def get_queryset(self):
     issue = models.Issue.objects.get(pk=self.kwargs.get("issue_id"))
     return votes_service.get_voters(issue)
开发者ID:lcyhff,项目名称:taiga-back,代码行数:3,代码来源:api.py

示例9: get_queryset

 def get_queryset(self):
     resource = self.resource_model.objects.get(pk=self.kwargs.get("resource_id"))
     return services.get_voters(resource)
开发者ID:rubixware,项目名称:taiga-back,代码行数:3,代码来源:viewsets.py


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