Skip to content

Results

hypha.apply.funds.views.results

User module-attribute

User = get_user_model()

SubmissionStatsMixin

get_context_data

get_context_data(**kwargs)
Source code in hypha/apply/funds/views/results.py
def get_context_data(self, **kwargs):
    submissions = ApplicationSubmission.objects.exclude_draft()
    # Getting values is an expensive operation. If there's no valid filters
    # then `count_values` & `total_value` will be encapsulating all submissions
    # and should be used rather than recaluclating these values.
    if not (filter := kwargs.get("filter")) or not is_filter_empty(filter):
        submission_count = kwargs.get("count_values")
        submission_sum = kwargs.get("total_value")
    else:
        submission_count = submissions.count()
        submission_value = submissions.current().value()
        submission_sum = format_submission_sum_value(submission_value)

    submission_undetermined_count = submissions.undetermined().count()
    review_my_count = submissions.reviewed_by(self.request.user).count()

    submission_accepted = submissions.current_accepted()
    submission_accepted_value = submission_accepted.value()
    submission_accepted_sum = format_submission_sum_value(submission_accepted_value)
    submission_accepted_count = submission_accepted.count()

    reviews = Review.objects.submitted()
    review_count = reviews.count()
    review_my_score = reviews.by_user(self.request.user).score()

    return super().get_context_data(
        submission_undetermined_count=submission_undetermined_count,
        review_my_count=review_my_count,
        submission_sum=submission_sum,
        submission_count=submission_count,
        submission_accepted_count=submission_accepted_count,
        submission_accepted_sum=submission_accepted_sum,
        review_count=review_count,
        review_my_score=review_my_score,
        **kwargs,
    )

SubmissionResultView

Bases: SubmissionStatsMixin, FilterView

template_name class-attribute instance-attribute

template_name = 'funds/submissions_result.html'

filterset_class class-attribute instance-attribute

filterset_class = SubmissionFilterAndSearch

filter_action class-attribute instance-attribute

filter_action = ''

excluded_fields class-attribute instance-attribute

excluded_fields = SUBMISSIONS_TABLE_EXCLUDED_FIELDS

excluded property

excluded

get_filterset_kwargs

get_filterset_kwargs(filterset_class, **kwargs)
Source code in hypha/apply/funds/views/results.py
def get_filterset_kwargs(self, filterset_class, **kwargs):
    new_kwargs = super().get_filterset_kwargs(filterset_class)
    new_kwargs.update(self.excluded)
    new_kwargs.update(kwargs)
    return new_kwargs

get_queryset

get_queryset()
Source code in hypha/apply/funds/views/results.py
def get_queryset(self):
    return (
        self.filterset_class._meta.model.objects.current()
        .exclude_draft()
        .defer(
            "search_data",
            "drupal_id",
            "submit_time",
            "workflow_name",
            "search_document",
            "live_revision_id",
            "draft_revision_id",
            "summary",
        )
    )

get_context_data

get_context_data(**kwargs)
Source code in hypha/apply/funds/views/results.py
def get_context_data(self, **kwargs):
    search_term = self.request.GET.get("query")

    if self.object_list:
        submission_values = self.object_list.value()
        count_values = submission_values.get("value__count")
        total_value = format_submission_sum_value(submission_values)
        if value := submission_values.get("value__avg"):
            average_value = round(value)
        else:
            average_value = 0
    else:
        count_values = 0
        total_value = 0
        average_value = 0

    return super().get_context_data(
        search_term=search_term,
        filter_action=self.filter_action,
        count_values=count_values,
        total_value=total_value,
        average_value=average_value,
        **kwargs,
    )