def attach_extra_info(queryset, user=None): # Userstories prefetching UserStory = apps.get_model("userstories", "UserStory") us_queryset = UserStory.objects.select_related("milestone", "project", "status", "owner", "assigned_to", "generated_from_issue") us_queryset = userstories_utils.attach_total_points(us_queryset) us_queryset = userstories_utils.attach_role_points(us_queryset) us_queryset = attach_total_voters_to_queryset(us_queryset) us_queryset = attach_watchers_to_queryset(us_queryset) us_queryset = attach_total_watchers_to_queryset(us_queryset) us_queryset = attach_is_voter_to_queryset(us_queryset, user) us_queryset = attach_is_watcher_to_queryset(us_queryset, user) queryset = queryset.prefetch_related(Prefetch("user_stories", queryset=us_queryset)) queryset = attach_total_points(queryset) queryset = attach_closed_points(queryset) queryset = attach_total_voters_to_queryset(queryset) queryset = attach_watchers_to_queryset(queryset) queryset = attach_total_watchers_to_queryset(queryset) queryset = attach_is_voter_to_queryset(queryset, user) queryset = attach_is_watcher_to_queryset(queryset, user) return queryset
def attach_extra_info(queryset, user=None): # Userstories prefetching UserStory = apps.get_model("userstories", "UserStory") us_queryset = UserStory.objects.select_related("milestone", "project", "status", "owner", "assigned_to", "generated_from_issue", "generated_from_task") us_queryset = userstories_utils.attach_total_points(us_queryset) us_queryset = userstories_utils.attach_total_attachments(us_queryset) us_queryset = userstories_utils.attach_role_points(us_queryset) us_queryset = userstories_utils.attach_epics(us_queryset) us_queryset = attach_total_voters_to_queryset(us_queryset) us_queryset = attach_watchers_to_queryset(us_queryset) us_queryset = attach_total_watchers_to_queryset(us_queryset) us_queryset = attach_is_voter_to_queryset(us_queryset, user) us_queryset = attach_is_watcher_to_queryset(us_queryset, user) queryset = queryset.prefetch_related( Prefetch("user_stories", queryset=us_queryset)) queryset = attach_total_points(queryset) queryset = attach_closed_points(queryset) queryset = attach_total_voters_to_queryset(queryset) queryset = attach_watchers_to_queryset(queryset) queryset = attach_total_watchers_to_queryset(queryset) queryset = attach_is_voter_to_queryset(queryset, user) queryset = attach_is_watcher_to_queryset(queryset, user) return queryset
def attach_watchers_attrs_to_queryset(self, queryset): qs = attach_watchers_to_queryset(queryset) qs = attach_total_watchers_to_queryset(queryset) if self.request.user.is_authenticated(): qs = attach_is_watcher_to_queryset(qs, self.request.user) return qs
def attach_extra_info(queryset, user=None, include_attachments=False, include_tasks=False, epic_id=None): queryset = attach_total_points(queryset) queryset = attach_role_points(queryset) queryset = attach_epics(queryset) if include_attachments: queryset = attach_basic_attachments(queryset) queryset = queryset.extra(select={"include_attachments": "True"}) if include_tasks: queryset = attach_tasks(queryset) queryset = queryset.extra(select={"include_tasks": "True"}) if epic_id is not None: queryset = attach_epic_order(queryset, epic_id) queryset = queryset.extra(select={"include_epic_order": "True"}) queryset = attach_total_voters_to_queryset(queryset) queryset = attach_watchers_to_queryset(queryset) queryset = attach_total_watchers_to_queryset(queryset) queryset = attach_is_voter_to_queryset(queryset, user) queryset = attach_is_watcher_to_queryset(queryset, user) queryset = attach_total_comments_to_queryset(queryset) return queryset
def get_queryset(self): qs = super().get_queryset() # Userstories prefetching UserStory = apps.get_model("userstories", "UserStory") us_qs = UserStory.objects.prefetch_related("role_points", "role_points__points", "role_points__role") us_qs = us_qs.select_related("milestone", "project", "status", "owner", "assigned_to", "generated_from_issue") us_qs = self.attach_watchers_attrs_to_queryset(us_qs) if self.request.user.is_authenticated(): us_qs = attach_is_voter_to_queryset(self.request.user, us_qs) us_qs = attach_is_watcher_to_queryset(self.request.user, us_qs) qs = qs.prefetch_related(Prefetch("user_stories", queryset=us_qs)) # Milestones prefetching qs = qs.select_related("project", "owner") qs = self.attach_watchers_attrs_to_queryset(qs) qs = qs.order_by("-estimated_start") return qs
def get_queryset(self): qs = super().get_queryset() # Userstories prefetching UserStory = apps.get_model("userstories", "UserStory") us_qs = UserStory.objects.prefetch_related("role_points", "role_points__points", "role_points__role") us_qs = us_qs.select_related("milestone", "project", "status", "owner", "assigned_to", "generated_from_issue") us_qs = self.attach_watchers_attrs_to_queryset(us_qs) if self.request.user.is_authenticated(): us_qs = attach_is_voter_to_queryset(self.request.user, us_qs) us_qs = attach_is_watcher_to_queryset(us_qs, self.request.user) qs = qs.prefetch_related(Prefetch("user_stories", queryset=us_qs)) # Milestones prefetching qs = qs.select_related("project", "owner") qs = self.attach_watchers_attrs_to_queryset(qs) qs = qs.order_by("-estimated_start") return qs
def attach_extra_info(queryset, user=None, include_attachments=False, include_tasks=False, epic_id=None): queryset = attach_total_points(queryset) queryset = attach_role_points(queryset) queryset = attach_epics(queryset) if include_attachments: queryset = attach_basic_attachments(queryset) queryset = queryset.extra(select={"include_attachments": "True"}) if include_tasks: queryset = attach_tasks(queryset) queryset = queryset.extra(select={"include_tasks": "True"}) if epic_id is not None: queryset = attach_epic_order(queryset, epic_id) queryset = queryset.extra(select={"include_epic_order": "True"}) queryset = attach_total_attachments(queryset) queryset = attach_total_voters_to_queryset(queryset) queryset = attach_watchers_to_queryset(queryset) queryset = attach_total_watchers_to_queryset(queryset) queryset = attach_is_voter_to_queryset(queryset, user) queryset = attach_is_watcher_to_queryset(queryset, user) queryset = attach_total_comments_to_queryset(queryset) return queryset
def attach_extra_info(queryset, user=None): queryset = attach_generated_user_stories(queryset) queryset = attach_total_voters_to_queryset(queryset) queryset = attach_watchers_to_queryset(queryset) queryset = attach_total_watchers_to_queryset(queryset) queryset = attach_is_voter_to_queryset(queryset, user) queryset = attach_is_watcher_to_queryset(queryset, user) return queryset
def attach_extra_info(queryset, user=None, include_attachments=False): if include_attachments: queryset = attach_basic_attachments(queryset) queryset = queryset.extra(select={"include_attachments": "True"}) queryset = attach_generated_user_stories(queryset) queryset = attach_total_voters_to_queryset(queryset) queryset = attach_watchers_to_queryset(queryset) queryset = attach_total_watchers_to_queryset(queryset) queryset = attach_is_voter_to_queryset(queryset, user) queryset = attach_is_watcher_to_queryset(queryset, user) return queryset
def attach_extra_info(queryset, user=None, include_attachments=False): if include_attachments: queryset = attach_basic_attachments(queryset) queryset = queryset.extra(select={"include_attachments": "True"}) queryset = attach_user_stories_counts_to_queryset(queryset) queryset = attach_child_epics_counts_to_queryset(queryset) queryset = attach_epic_progress_to_queryset(queryset) queryset = attach_total_voters_to_queryset(queryset) queryset = attach_watchers_to_queryset(queryset) queryset = attach_total_watchers_to_queryset(queryset) queryset = attach_is_voter_to_queryset(queryset, user) queryset = attach_is_watcher_to_queryset(queryset, user) return queryset
def attach_extra_info(queryset, user=None, include_attachments=False, include_tasks=False): queryset = attach_total_points(queryset) queryset = attach_role_points(queryset) if include_attachments: queryset = attach_basic_attachments(queryset) queryset = queryset.extra(select={"include_attachments": "True"}) if include_tasks: queryset = attach_tasks(queryset) queryset = queryset.extra(select={"include_tasks": "True"}) queryset = attach_total_voters_to_queryset(queryset) queryset = attach_watchers_to_queryset(queryset) queryset = attach_total_watchers_to_queryset(queryset) queryset = attach_is_voter_to_queryset(queryset, user) queryset = attach_is_watcher_to_queryset(queryset, user) return queryset
def attach_extra_info(queryset, user=None, include_attachments=False): queryset = attach_watchers_to_queryset(queryset) queryset = attach_total_watchers_to_queryset(queryset) queryset = attach_is_watcher_to_queryset(queryset, user) return queryset