Skip to content

Views

hypha.apply.funds.views

User module-attribute

User = get_user_model()

SubmissionStatsMixin

get_context_data

get_context_data(**kwargs)
Source code in hypha/apply/funds/views.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,
    )

BaseAdminSubmissionsTable

Bases: SingleTableMixin, FilterView

table_class class-attribute instance-attribute

table_class = AdminSubmissionsTable

filterset_class class-attribute instance-attribute

filterset_class = SubmissionFilterAndSearch

filter_action class-attribute instance-attribute

filter_action = ''

search_action class-attribute instance-attribute

search_action = ''

paginator_class class-attribute instance-attribute

paginator_class = LazyPaginator

table_pagination class-attribute instance-attribute

table_pagination = {'per_page': 25}

excluded_fields class-attribute instance-attribute

excluded_fields = SUBMISSIONS_TABLE_EXCLUDED_FIELDS

excluded property

excluded

get_table_kwargs

get_table_kwargs(**kwargs)
Source code in hypha/apply/funds/views.py
def get_table_kwargs(self, **kwargs):
    return {**self.excluded, **kwargs}

get_filterset_kwargs

get_filterset_kwargs(filterset_class, **kwargs)
Source code in hypha/apply/funds/views.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.py
def get_queryset(self):
    submissions = self.filterset_class._meta.model.objects.current().for_table(
        self.request.user
    )

    if not can_access_drafts(self.request.user):
        submissions = submissions.exclude_draft()

    return submissions

get_context_data

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

    return super().get_context_data(
        search_term=search_term,
        search_action=self.search_action,
        filter_action=self.filter_action,
        can_export=can_export_submissions(self.request.user),
        **kwargs,
    )

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/funds/views.py
def dispatch(self, request, *args, **kwargs):
    disp = super().dispatch(request, *args, **kwargs)
    if "export" in request.GET and can_export_submissions(request.user):
        csv_data = export_submissions_to_csv(self.object_list)
        response = HttpResponse(csv_data.readlines(), content_type="text/csv")
        response["Content-Disposition"] = "attachment; filename=submissions.csv"
        return response
    return disp

BatchUpdateLeadView

Bases: DelegatedViewMixin, FormView

form_class class-attribute instance-attribute

context_name class-attribute instance-attribute

context_name = 'batch_lead_form'

setup

setup(request, *args, **kwargs)

Initialize attributes shared by all view methods.

Source code in hypha/apply/utils/views.py
def setup(self, request, *args, **kwargs):
    """Initialize attributes shared by all view methods."""
    self.request = request
    self.args = args
    self.kwargs = kwargs

get_object

get_object()
Source code in hypha/apply/utils/views.py
def get_object(self):
    # Make sure the form instance, bound at the parent class level,  is the same as the
    # value we work with on the class.
    # If we don't have self.object, bind the parent instance to it. This value will then
    # be used by the form. Any further calls to get_object will get a new instance of the object
    if not hasattr(self, "object"):
        parent_object = self.get_parent_object()
        if isinstance(parent_object, self.model):
            return parent_object

    return super().get_object()

get_template_names

get_template_names()
Source code in hypha/apply/utils/views.py
def get_template_names(self):
    return self.kwargs["template_names"]

get_form_name

get_form_name()
Source code in hypha/apply/utils/views.py
def get_form_name(self):
    return self.context_name

get_form_kwargs

get_form_kwargs()
Source code in hypha/apply/utils/views.py
def get_form_kwargs(self):
    form_kwargs = super().get_form_kwargs()
    form_kwargs["user"] = self.request.user
    form_kwargs.update(**self.get_parent_kwargs())
    return form_kwargs

get_parent_kwargs

get_parent_kwargs()
Source code in hypha/apply/utils/views.py
def get_parent_kwargs(self):
    try:
        return self.parent.get_form_kwargs()
    except AttributeError:
        return self.kwargs["parent"].get_form_kwargs()

get_parent_object

get_parent_object()
Source code in hypha/apply/utils/views.py
def get_parent_object(self):
    return self.get_parent_kwargs()["instance"]

get_form

get_form(*args, **kwargs)
Source code in hypha/apply/utils/views.py
def get_form(self, *args, **kwargs):
    form = super().get_form(*args, **kwargs)
    form.name = self.get_form_name()
    return form

get_context_data

get_context_data(**kwargs)
Source code in hypha/apply/utils/views.py
def get_context_data(self, **kwargs):
    # Use the previous context but override the validated form
    form = kwargs.pop("form")
    kwargs.update(self.kwargs["context"])
    kwargs.update(**{self.context_name: form})
    return super().get_context_data(**kwargs)

is_model_form classmethod

is_model_form()
Source code in hypha/apply/utils/views.py
@classmethod
def is_model_form(cls):
    return issubclass(cls.form_class, ModelForm)

contribute_form

contribute_form(parent)
Source code in hypha/apply/utils/views.py
def contribute_form(self, parent):
    self.parent = parent

    # We do not want to bind any forms generated this way
    # pretend we are doing a get request to avoid passing data to forms
    old_method = None
    if self.request.method in ("POST", "PUT"):
        old_method = self.request.method
        self.request.method = "GET"

    form = self.get_form()

    if old_method:
        self.request.method = old_method
    return self.context_name, form

get_success_url

get_success_url()
Source code in hypha/apply/utils/views.py
def get_success_url(self):
    query = self.request.GET.urlencode()
    if query:
        query = "?" + query
    return self.request.path + query

form_valid

form_valid(form)
Source code in hypha/apply/funds/views.py
def form_valid(self, form):
    new_lead = form.cleaned_data["lead"]
    submissions = form.cleaned_data["submissions"]
    services.bulk_update_lead(
        submissions=submissions,
        user=self.request.user,
        lead=new_lead,
        request=self.request,
    )
    return super().form_valid(form)

form_invalid

form_invalid(form)
Source code in hypha/apply/funds/views.py
def form_invalid(self, form):
    messages.error(
        self.request,
        mark_safe(_("Sorry something went wrong") + form.errors.as_ul()),
    )
    return super().form_invalid(form)

BatchUpdateReviewersView

Bases: DelegatedViewMixin, FormView

form_class class-attribute instance-attribute

context_name class-attribute instance-attribute

context_name = 'batch_reviewer_form'

setup

setup(request, *args, **kwargs)

Initialize attributes shared by all view methods.

Source code in hypha/apply/utils/views.py
def setup(self, request, *args, **kwargs):
    """Initialize attributes shared by all view methods."""
    self.request = request
    self.args = args
    self.kwargs = kwargs

get_object

get_object()
Source code in hypha/apply/utils/views.py
def get_object(self):
    # Make sure the form instance, bound at the parent class level,  is the same as the
    # value we work with on the class.
    # If we don't have self.object, bind the parent instance to it. This value will then
    # be used by the form. Any further calls to get_object will get a new instance of the object
    if not hasattr(self, "object"):
        parent_object = self.get_parent_object()
        if isinstance(parent_object, self.model):
            return parent_object

    return super().get_object()

get_template_names

get_template_names()
Source code in hypha/apply/utils/views.py
def get_template_names(self):
    return self.kwargs["template_names"]

get_form_name

get_form_name()
Source code in hypha/apply/utils/views.py
def get_form_name(self):
    return self.context_name

get_form_kwargs

get_form_kwargs()
Source code in hypha/apply/utils/views.py
def get_form_kwargs(self):
    form_kwargs = super().get_form_kwargs()
    form_kwargs["user"] = self.request.user
    form_kwargs.update(**self.get_parent_kwargs())
    return form_kwargs

get_parent_kwargs

get_parent_kwargs()
Source code in hypha/apply/utils/views.py
def get_parent_kwargs(self):
    try:
        return self.parent.get_form_kwargs()
    except AttributeError:
        return self.kwargs["parent"].get_form_kwargs()

get_parent_object

get_parent_object()
Source code in hypha/apply/utils/views.py
def get_parent_object(self):
    return self.get_parent_kwargs()["instance"]

get_form

get_form(*args, **kwargs)
Source code in hypha/apply/utils/views.py
def get_form(self, *args, **kwargs):
    form = super().get_form(*args, **kwargs)
    form.name = self.get_form_name()
    return form

get_context_data

get_context_data(**kwargs)
Source code in hypha/apply/utils/views.py
def get_context_data(self, **kwargs):
    # Use the previous context but override the validated form
    form = kwargs.pop("form")
    kwargs.update(self.kwargs["context"])
    kwargs.update(**{self.context_name: form})
    return super().get_context_data(**kwargs)

is_model_form classmethod

is_model_form()
Source code in hypha/apply/utils/views.py
@classmethod
def is_model_form(cls):
    return issubclass(cls.form_class, ModelForm)

contribute_form

contribute_form(parent)
Source code in hypha/apply/utils/views.py
def contribute_form(self, parent):
    self.parent = parent

    # We do not want to bind any forms generated this way
    # pretend we are doing a get request to avoid passing data to forms
    old_method = None
    if self.request.method in ("POST", "PUT"):
        old_method = self.request.method
        self.request.method = "GET"

    form = self.get_form()

    if old_method:
        self.request.method = old_method
    return self.context_name, form

get_success_url

get_success_url()
Source code in hypha/apply/utils/views.py
def get_success_url(self):
    query = self.request.GET.urlencode()
    if query:
        query = "?" + query
    return self.request.path + query

form_valid

form_valid(form)
Source code in hypha/apply/funds/views.py
def form_valid(self, form):
    submissions = form.cleaned_data["submissions"]
    external_reviewers = form.cleaned_data["external_reviewers"]
    assigned_roles = {
        role: form.cleaned_data[field] for field, role in form.role_fields.items()
    }
    services.bulk_update_reviewers(
        submissions=submissions,
        external_reviewers=external_reviewers,
        assigned_roles=assigned_roles,
        user=self.request.user,
        request=self.request,
    )

    return super().form_valid(form)

form_invalid

form_invalid(form)
Source code in hypha/apply/funds/views.py
def form_invalid(self, form):
    messages.error(
        self.request,
        mark_safe(_("Sorry something went wrong") + form.errors.as_ul()),
    )
    return super().form_invalid(form)

BatchDeleteSubmissionView

Bases: DelegatedViewMixin, FormView

form_class class-attribute instance-attribute

context_name class-attribute instance-attribute

context_name = 'batch_delete_submission_form'

setup

setup(request, *args, **kwargs)

Initialize attributes shared by all view methods.

Source code in hypha/apply/utils/views.py
def setup(self, request, *args, **kwargs):
    """Initialize attributes shared by all view methods."""
    self.request = request
    self.args = args
    self.kwargs = kwargs

get_object

get_object()
Source code in hypha/apply/utils/views.py
def get_object(self):
    # Make sure the form instance, bound at the parent class level,  is the same as the
    # value we work with on the class.
    # If we don't have self.object, bind the parent instance to it. This value will then
    # be used by the form. Any further calls to get_object will get a new instance of the object
    if not hasattr(self, "object"):
        parent_object = self.get_parent_object()
        if isinstance(parent_object, self.model):
            return parent_object

    return super().get_object()

get_template_names

get_template_names()
Source code in hypha/apply/utils/views.py
def get_template_names(self):
    return self.kwargs["template_names"]

get_form_name

get_form_name()
Source code in hypha/apply/utils/views.py
def get_form_name(self):
    return self.context_name

get_form_kwargs

get_form_kwargs()
Source code in hypha/apply/utils/views.py
def get_form_kwargs(self):
    form_kwargs = super().get_form_kwargs()
    form_kwargs["user"] = self.request.user
    form_kwargs.update(**self.get_parent_kwargs())
    return form_kwargs

get_parent_kwargs

get_parent_kwargs()
Source code in hypha/apply/utils/views.py
def get_parent_kwargs(self):
    try:
        return self.parent.get_form_kwargs()
    except AttributeError:
        return self.kwargs["parent"].get_form_kwargs()

get_parent_object

get_parent_object()
Source code in hypha/apply/utils/views.py
def get_parent_object(self):
    return self.get_parent_kwargs()["instance"]

get_form

get_form(*args, **kwargs)
Source code in hypha/apply/utils/views.py
def get_form(self, *args, **kwargs):
    form = super().get_form(*args, **kwargs)
    form.name = self.get_form_name()
    return form

get_context_data

get_context_data(**kwargs)
Source code in hypha/apply/utils/views.py
def get_context_data(self, **kwargs):
    # Use the previous context but override the validated form
    form = kwargs.pop("form")
    kwargs.update(self.kwargs["context"])
    kwargs.update(**{self.context_name: form})
    return super().get_context_data(**kwargs)

is_model_form classmethod

is_model_form()
Source code in hypha/apply/utils/views.py
@classmethod
def is_model_form(cls):
    return issubclass(cls.form_class, ModelForm)

contribute_form

contribute_form(parent)
Source code in hypha/apply/utils/views.py
def contribute_form(self, parent):
    self.parent = parent

    # We do not want to bind any forms generated this way
    # pretend we are doing a get request to avoid passing data to forms
    old_method = None
    if self.request.method in ("POST", "PUT"):
        old_method = self.request.method
        self.request.method = "GET"

    form = self.get_form()

    if old_method:
        self.request.method = old_method
    return self.context_name, form

get_success_url

get_success_url()
Source code in hypha/apply/utils/views.py
def get_success_url(self):
    query = self.request.GET.urlencode()
    if query:
        query = "?" + query
    return self.request.path + query

form_valid

form_valid(form)
Source code in hypha/apply/funds/views.py
def form_valid(self, form):
    submissions = form.cleaned_data["submissions"]
    services.bulk_delete_submissions(
        submissions=submissions,
        user=self.request.user,
        request=self.request,
    )
    return super().form_valid(form)

form_invalid

form_invalid(form)
Source code in hypha/apply/funds/views.py
def form_invalid(self, form):
    messages.error(
        self.request,
        mark_safe(_("Sorry something went wrong") + form.errors.as_ul()),
    )
    return super().form_invalid(form)

BatchArchiveSubmissionView

Bases: DelegatedViewMixin, FormView

form_class class-attribute instance-attribute

context_name class-attribute instance-attribute

context_name = 'batch_archive_submission_form'

setup

setup(request, *args, **kwargs)

Initialize attributes shared by all view methods.

Source code in hypha/apply/utils/views.py
def setup(self, request, *args, **kwargs):
    """Initialize attributes shared by all view methods."""
    self.request = request
    self.args = args
    self.kwargs = kwargs

get_object

get_object()
Source code in hypha/apply/utils/views.py
def get_object(self):
    # Make sure the form instance, bound at the parent class level,  is the same as the
    # value we work with on the class.
    # If we don't have self.object, bind the parent instance to it. This value will then
    # be used by the form. Any further calls to get_object will get a new instance of the object
    if not hasattr(self, "object"):
        parent_object = self.get_parent_object()
        if isinstance(parent_object, self.model):
            return parent_object

    return super().get_object()

get_template_names

get_template_names()
Source code in hypha/apply/utils/views.py
def get_template_names(self):
    return self.kwargs["template_names"]

get_form_name

get_form_name()
Source code in hypha/apply/utils/views.py
def get_form_name(self):
    return self.context_name

get_form_kwargs

get_form_kwargs()
Source code in hypha/apply/utils/views.py
def get_form_kwargs(self):
    form_kwargs = super().get_form_kwargs()
    form_kwargs["user"] = self.request.user
    form_kwargs.update(**self.get_parent_kwargs())
    return form_kwargs

get_parent_kwargs

get_parent_kwargs()
Source code in hypha/apply/utils/views.py
def get_parent_kwargs(self):
    try:
        return self.parent.get_form_kwargs()
    except AttributeError:
        return self.kwargs["parent"].get_form_kwargs()

get_parent_object

get_parent_object()
Source code in hypha/apply/utils/views.py
def get_parent_object(self):
    return self.get_parent_kwargs()["instance"]

get_form

get_form(*args, **kwargs)
Source code in hypha/apply/utils/views.py
def get_form(self, *args, **kwargs):
    form = super().get_form(*args, **kwargs)
    form.name = self.get_form_name()
    return form

get_context_data

get_context_data(**kwargs)
Source code in hypha/apply/utils/views.py
def get_context_data(self, **kwargs):
    # Use the previous context but override the validated form
    form = kwargs.pop("form")
    kwargs.update(self.kwargs["context"])
    kwargs.update(**{self.context_name: form})
    return super().get_context_data(**kwargs)

is_model_form classmethod

is_model_form()
Source code in hypha/apply/utils/views.py
@classmethod
def is_model_form(cls):
    return issubclass(cls.form_class, ModelForm)

contribute_form

contribute_form(parent)
Source code in hypha/apply/utils/views.py
def contribute_form(self, parent):
    self.parent = parent

    # We do not want to bind any forms generated this way
    # pretend we are doing a get request to avoid passing data to forms
    old_method = None
    if self.request.method in ("POST", "PUT"):
        old_method = self.request.method
        self.request.method = "GET"

    form = self.get_form()

    if old_method:
        self.request.method = old_method
    return self.context_name, form

get_success_url

get_success_url()
Source code in hypha/apply/utils/views.py
def get_success_url(self):
    query = self.request.GET.urlencode()
    if query:
        query = "?" + query
    return self.request.path + query

form_valid

form_valid(form)
Source code in hypha/apply/funds/views.py
def form_valid(self, form):
    # If a user without archive edit access is somehow able to access batch archive submissions
    # (ie. they were looking at the submission list when permissions changed) "refresh" the page
    if not can_alter_archived_submissions(self.request.user):
        return HttpResponseRedirect(self.request.path)
    submissions = form.cleaned_data["submissions"]
    services.bulk_archive_submissions(
        submissions=submissions,
        user=self.request.user,
        request=self.request,
    )
    return super().form_valid(form)

form_invalid

form_invalid(form)
Source code in hypha/apply/funds/views.py
def form_invalid(self, form):
    messages.error(
        self.request,
        mark_safe(_("Sorry something went wrong") + form.errors.as_ul()),
    )
    return super().form_invalid(form)

BatchProgressSubmissionView

Bases: DelegatedViewMixin, FormView

form_class class-attribute instance-attribute

context_name class-attribute instance-attribute

context_name = 'batch_progress_form'

setup

setup(request, *args, **kwargs)

Initialize attributes shared by all view methods.

Source code in hypha/apply/utils/views.py
def setup(self, request, *args, **kwargs):
    """Initialize attributes shared by all view methods."""
    self.request = request
    self.args = args
    self.kwargs = kwargs

get_object

get_object()
Source code in hypha/apply/utils/views.py
def get_object(self):
    # Make sure the form instance, bound at the parent class level,  is the same as the
    # value we work with on the class.
    # If we don't have self.object, bind the parent instance to it. This value will then
    # be used by the form. Any further calls to get_object will get a new instance of the object
    if not hasattr(self, "object"):
        parent_object = self.get_parent_object()
        if isinstance(parent_object, self.model):
            return parent_object

    return super().get_object()

get_template_names

get_template_names()
Source code in hypha/apply/utils/views.py
def get_template_names(self):
    return self.kwargs["template_names"]

get_form_name

get_form_name()
Source code in hypha/apply/utils/views.py
def get_form_name(self):
    return self.context_name

get_form_kwargs

get_form_kwargs()
Source code in hypha/apply/utils/views.py
def get_form_kwargs(self):
    form_kwargs = super().get_form_kwargs()
    form_kwargs["user"] = self.request.user
    form_kwargs.update(**self.get_parent_kwargs())
    return form_kwargs

get_parent_kwargs

get_parent_kwargs()
Source code in hypha/apply/utils/views.py
def get_parent_kwargs(self):
    try:
        return self.parent.get_form_kwargs()
    except AttributeError:
        return self.kwargs["parent"].get_form_kwargs()

get_parent_object

get_parent_object()
Source code in hypha/apply/utils/views.py
def get_parent_object(self):
    return self.get_parent_kwargs()["instance"]

get_form

get_form(*args, **kwargs)
Source code in hypha/apply/utils/views.py
def get_form(self, *args, **kwargs):
    form = super().get_form(*args, **kwargs)
    form.name = self.get_form_name()
    return form

get_context_data

get_context_data(**kwargs)
Source code in hypha/apply/utils/views.py
def get_context_data(self, **kwargs):
    # Use the previous context but override the validated form
    form = kwargs.pop("form")
    kwargs.update(self.kwargs["context"])
    kwargs.update(**{self.context_name: form})
    return super().get_context_data(**kwargs)

is_model_form classmethod

is_model_form()
Source code in hypha/apply/utils/views.py
@classmethod
def is_model_form(cls):
    return issubclass(cls.form_class, ModelForm)

contribute_form

contribute_form(parent)
Source code in hypha/apply/utils/views.py
def contribute_form(self, parent):
    self.parent = parent

    # We do not want to bind any forms generated this way
    # pretend we are doing a get request to avoid passing data to forms
    old_method = None
    if self.request.method in ("POST", "PUT"):
        old_method = self.request.method
        self.request.method = "GET"

    form = self.get_form()

    if old_method:
        self.request.method = old_method
    return self.context_name, form

get_success_url

get_success_url()
Source code in hypha/apply/utils/views.py
def get_success_url(self):
    query = self.request.GET.urlencode()
    if query:
        query = "?" + query
    return self.request.path + query

form_valid

form_valid(form)
Source code in hypha/apply/funds/views.py
def form_valid(self, form):
    submissions = form.cleaned_data["submissions"]
    transitions = form.cleaned_data.get("action")

    try:
        redirect = BatchDeterminationCreateView.should_redirect(
            self.request, submissions, transitions
        )
    except ValueError as e:
        messages.warning(self.request, "Could not determine: " + str(e))
        return self.form_invalid(form)
    else:
        if redirect:
            return redirect

    failed = []
    phase_changes = {}
    for submission in submissions:
        valid_actions = {
            action
            for action, _ in submission.get_actions_for_user(self.request.user)
        }
        old_phase = submission.phase
        try:
            transition = (valid_actions & set(transitions)).pop()
            submission.perform_transition(
                transition,
                self.request.user,
                request=self.request,
                notify=False,
            )
        except (PermissionDenied, KeyError):
            failed.append(submission)
        else:
            phase_changes[submission.id] = old_phase

    if failed:
        messages.warning(
            self.request,
            _("Failed to update: ")
            + ", ".join(str(submission) for submission in failed),
        )

    succeeded_submissions = submissions.exclude(
        id__in=[submission.id for submission in failed]
    )
    messenger(
        MESSAGES.BATCH_TRANSITION,
        user=self.request.user,
        request=self.request,
        sources=succeeded_submissions,
        related=phase_changes,
    )

    ready_for_review = [phase for phase in transitions if phase in review_statuses]
    if ready_for_review:
        messenger(
            MESSAGES.BATCH_READY_FOR_REVIEW,
            user=self.request.user,
            request=self.request,
            sources=succeeded_submissions.filter(status__in=ready_for_review),
        )

    return super().form_valid(form)

BaseReviewerSubmissionsTable

Bases: BaseAdminSubmissionsTable

filter_action class-attribute instance-attribute

filter_action = ''

search_action class-attribute instance-attribute

search_action = ''

paginator_class class-attribute instance-attribute

paginator_class = LazyPaginator

table_pagination class-attribute instance-attribute

table_pagination = {'per_page': 25}

excluded_fields class-attribute instance-attribute

excluded_fields = SUBMISSIONS_TABLE_EXCLUDED_FIELDS

excluded property

excluded

table_class class-attribute instance-attribute

filterset_class class-attribute instance-attribute

get_table_kwargs

get_table_kwargs(**kwargs)
Source code in hypha/apply/funds/views.py
def get_table_kwargs(self, **kwargs):
    return {**self.excluded, **kwargs}

get_filterset_kwargs

get_filterset_kwargs(filterset_class, **kwargs)
Source code in hypha/apply/funds/views.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_context_data

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

    return super().get_context_data(
        search_term=search_term,
        search_action=self.search_action,
        filter_action=self.filter_action,
        can_export=can_export_submissions(self.request.user),
        **kwargs,
    )

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/funds/views.py
def dispatch(self, request, *args, **kwargs):
    disp = super().dispatch(request, *args, **kwargs)
    if "export" in request.GET and can_export_submissions(request.user):
        csv_data = export_submissions_to_csv(self.object_list)
        response = HttpResponse(csv_data.readlines(), content_type="text/csv")
        response["Content-Disposition"] = "attachment; filename=submissions.csv"
        return response
    return disp

get_queryset

get_queryset()

If use_settings variable is set for ReviewerSettings use settings parameters to filter submissions or return only reviewed_by as it was by default.

Source code in hypha/apply/funds/views.py
def get_queryset(self):
    """
    If use_settings variable is set for ReviewerSettings use settings
    parameters to filter submissions or return only reviewed_by as it
    was by default.
    """
    reviewer_settings = ReviewerSettings.for_request(self.request)
    if reviewer_settings.use_settings:
        return (
            super()
            .get_queryset()
            .for_reviewer_settings(self.request.user, reviewer_settings)
            .order_by("-submit_time")
        )
    return super().get_queryset().reviewed_by(self.request.user)

AwaitingReviewSubmissionsListView

Bases: SingleTableMixin, ListView

model class-attribute instance-attribute

table_class class-attribute instance-attribute

table_class = AdminSubmissionsTable

template_name class-attribute instance-attribute

template_name = 'funds/submissions_awaiting_review.html'

paginator_class class-attribute instance-attribute

paginator_class = LazyPaginator

table_pagination class-attribute instance-attribute

table_pagination = {'per_page': 25}

excluded_fields class-attribute instance-attribute

excluded_fields = SUBMISSIONS_TABLE_EXCLUDED_FIELDS

excluded property

excluded

get_table_kwargs

get_table_kwargs(**kwargs)
Source code in hypha/apply/funds/views.py
def get_table_kwargs(self, **kwargs):
    return {**self.excluded, **kwargs}

get_queryset

get_queryset()
Source code in hypha/apply/funds/views.py
def get_queryset(self):
    submissions = ApplicationSubmission.objects.in_review_for(
        self.request.user
    ).order_by("-submit_time")
    return submissions.for_table(self.request.user)

SubmissionAdminListView

SubmissionAdminListView(*args, **kwargs)

Bases: BaseAdminSubmissionsTable, DelegateableListView

Source code in hypha/apply/utils/views.py
def __init__(self, *args, **kwargs):
    self._form_views = {
        self.form_prefix + form_view.context_name: form_view
        for form_view in self.form_views
    }

form_prefix class-attribute instance-attribute

form_prefix = 'form-submitted-'

table_class class-attribute instance-attribute

table_class = AdminSubmissionsTable

filterset_class class-attribute instance-attribute

filterset_class = SubmissionFilterAndSearch

filter_action class-attribute instance-attribute

filter_action = ''

search_action class-attribute instance-attribute

search_action = ''

paginator_class class-attribute instance-attribute

paginator_class = LazyPaginator

table_pagination class-attribute instance-attribute

table_pagination = {'per_page': 25}

excluded_fields class-attribute instance-attribute

excluded_fields = SUBMISSIONS_TABLE_EXCLUDED_FIELDS

excluded property

excluded

template_name class-attribute instance-attribute

template_name = 'funds/submissions.html'

get_form_kwargs

get_form_kwargs()
Source code in hypha/apply/utils/views.py
def get_form_kwargs(self):
    return {
        "user": self.request.user,
    }

post

post(request, *args, **kwargs)
Source code in hypha/apply/utils/views.py
def post(self, request, *args, **kwargs):
    self.object_list = self.get_queryset()
    return super().post(request, *args, **kwargs)

get_table_kwargs

get_table_kwargs(**kwargs)
Source code in hypha/apply/funds/views.py
def get_table_kwargs(self, **kwargs):
    return {**self.excluded, **kwargs}

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/funds/views.py
def dispatch(self, request, *args, **kwargs):
    disp = super().dispatch(request, *args, **kwargs)
    if "export" in request.GET and can_export_submissions(request.user):
        csv_data = export_submissions_to_csv(self.object_list)
        response = HttpResponse(csv_data.readlines(), content_type="text/csv")
        response["Content-Disposition"] = "attachment; filename=submissions.csv"
        return response
    return disp

get_filterset_kwargs

get_filterset_kwargs(filterset_class, **kwargs)
Source code in hypha/apply/funds/views.py
def get_filterset_kwargs(self, filterset_class, **kwargs):
    new_kwargs = super().get_filterset_kwargs(filterset_class)
    archived_kwargs = {"archived": self.request.GET.get("archived", 0)}
    new_kwargs.update(archived_kwargs)
    new_kwargs.update(kwargs)
    return new_kwargs

get_queryset

get_queryset()
Source code in hypha/apply/funds/views.py
def get_queryset(self):
    if self.request.GET.get("archived"):
        # if archived is in param, let archived filter handle the queryset as per its value.
        submissions = (
            self.filterset_class._meta.model.objects.include_archive().for_table(
                self.request.user
            )
        )
    else:
        submissions = self.filterset_class._meta.model.objects.current().for_table(
            self.request.user
        )

    if not can_access_drafts(self.request.user):
        submissions = submissions.exclude_draft()

    return submissions

get_context_data

get_context_data(**kwargs)
Source code in hypha/apply/funds/views.py
def get_context_data(self, **kwargs):
    show_archive = can_view_archived_submissions(self.request.user)
    can_archive = can_bulk_archive_submissions(self.request.user)

    return super().get_context_data(
        show_archive=show_archive,
        can_bulk_archive=can_archive,
        **kwargs,
    )

GroupingApplicationsListView

Bases: TemplateView

Template view for grouped submissions

template_name class-attribute instance-attribute

template_name = 'funds/grouped_application_list.html'

SubmissionReviewerListView

Bases: BaseReviewerSubmissionsTable

table_class class-attribute instance-attribute

filterset_class class-attribute instance-attribute

filter_action class-attribute instance-attribute

filter_action = ''

search_action class-attribute instance-attribute

search_action = ''

paginator_class class-attribute instance-attribute

paginator_class = LazyPaginator

table_pagination class-attribute instance-attribute

table_pagination = {'per_page': 25}

excluded_fields class-attribute instance-attribute

excluded_fields = SUBMISSIONS_TABLE_EXCLUDED_FIELDS

excluded property

excluded

template_name class-attribute instance-attribute

template_name = 'funds/submissions.html'

get_table_kwargs

get_table_kwargs(**kwargs)
Source code in hypha/apply/funds/views.py
def get_table_kwargs(self, **kwargs):
    return {**self.excluded, **kwargs}

get_filterset_kwargs

get_filterset_kwargs(filterset_class, **kwargs)
Source code in hypha/apply/funds/views.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()

If use_settings variable is set for ReviewerSettings use settings parameters to filter submissions or return only reviewed_by as it was by default.

Source code in hypha/apply/funds/views.py
def get_queryset(self):
    """
    If use_settings variable is set for ReviewerSettings use settings
    parameters to filter submissions or return only reviewed_by as it
    was by default.
    """
    reviewer_settings = ReviewerSettings.for_request(self.request)
    if reviewer_settings.use_settings:
        return (
            super()
            .get_queryset()
            .for_reviewer_settings(self.request.user, reviewer_settings)
            .order_by("-submit_time")
        )
    return super().get_queryset().reviewed_by(self.request.user)

get_context_data

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

    return super().get_context_data(
        search_term=search_term,
        search_action=self.search_action,
        filter_action=self.filter_action,
        can_export=can_export_submissions(self.request.user),
        **kwargs,
    )

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/funds/views.py
def dispatch(self, request, *args, **kwargs):
    disp = super().dispatch(request, *args, **kwargs)
    if "export" in request.GET and can_export_submissions(request.user):
        csv_data = export_submissions_to_csv(self.object_list)
        response = HttpResponse(csv_data.readlines(), content_type="text/csv")
        response["Content-Disposition"] = "attachment; filename=submissions.csv"
        return response
    return disp

SubmissionListView

Bases: ViewDispatcher

partner_view class-attribute instance-attribute

partner_view = None

community_view class-attribute instance-attribute

community_view = None

applicant_view class-attribute instance-attribute

applicant_view = None

finance_view class-attribute instance-attribute

finance_view = None

contracting_view class-attribute instance-attribute

contracting_view = None

admin_view class-attribute instance-attribute

reviewer_view class-attribute instance-attribute

admin_check

admin_check(request)
Source code in hypha/apply/utils/views.py
def admin_check(self, request):
    return request.user.is_apply_staff

reviewer_check

reviewer_check(request)
Source code in hypha/apply/utils/views.py
def reviewer_check(self, request):
    return request.user.is_reviewer

partner_check

partner_check(request)
Source code in hypha/apply/utils/views.py
def partner_check(self, request):
    return request.user.is_partner

community_check

community_check(request)
Source code in hypha/apply/utils/views.py
def community_check(self, request):
    return request.user.is_community_reviewer

finance_check

finance_check(request)
Source code in hypha/apply/utils/views.py
def finance_check(self, request):
    return request.user.is_finance

contracting_check

contracting_check(request)
Source code in hypha/apply/utils/views.py
def contracting_check(self, request):
    return request.user.is_contracting

applicant_check

applicant_check(request)
Source code in hypha/apply/utils/views.py
def applicant_check(self, request):
    return request.user.is_applicant

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/utils/views.py
def dispatch(self, request, *args, **kwargs):
    view = None

    if self.admin_check(request):
        view = self.admin_view
    elif self.reviewer_check(request):
        view = self.reviewer_view
    elif self.partner_check(request):
        view = self.partner_view
    elif self.community_check(request):
        view = self.community_view
    elif settings.PROJECTS_ENABLED and self.finance_check(request):
        view = self.finance_view
    elif settings.PROJECTS_ENABLED and self.contracting_check(request):
        view = self.contracting_view
    elif self.applicant_check(request):
        view = self.applicant_view

    if view:
        return view.as_view()(request, *args, **kwargs)
    return HttpResponseForbidden()

ExportSubmissionsByRound

Bases: UserPassesTestMixin, BaseAdminSubmissionsTable

table_class class-attribute instance-attribute

table_class = AdminSubmissionsTable

filterset_class class-attribute instance-attribute

filterset_class = SubmissionFilterAndSearch

filter_action class-attribute instance-attribute

filter_action = ''

search_action class-attribute instance-attribute

search_action = ''

paginator_class class-attribute instance-attribute

paginator_class = LazyPaginator

table_pagination class-attribute instance-attribute

table_pagination = {'per_page': 25}

excluded_fields class-attribute instance-attribute

excluded_fields = SUBMISSIONS_TABLE_EXCLUDED_FIELDS

excluded property

excluded

get_table_kwargs

get_table_kwargs(**kwargs)
Source code in hypha/apply/funds/views.py
def get_table_kwargs(self, **kwargs):
    return {**self.excluded, **kwargs}

get_filterset_kwargs

get_filterset_kwargs(filterset_class, **kwargs)
Source code in hypha/apply/funds/views.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_context_data

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

    return super().get_context_data(
        search_term=search_term,
        search_action=self.search_action,
        filter_action=self.filter_action,
        can_export=can_export_submissions(self.request.user),
        **kwargs,
    )

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/funds/views.py
def dispatch(self, request, *args, **kwargs):
    disp = super().dispatch(request, *args, **kwargs)
    if "export" in request.GET and can_export_submissions(request.user):
        csv_data = export_submissions_to_csv(self.object_list)
        response = HttpResponse(csv_data.readlines(), content_type="text/csv")
        response["Content-Disposition"] = "attachment; filename=submissions.csv"
        return response
    return disp

get_queryset

get_queryset()
Source code in hypha/apply/funds/views.py
def get_queryset(self):
    try:
        self.obj = Page.objects.get(pk=self.kwargs.get("pk")).specific
    except Page.DoesNotExist as exc:
        raise Http404(_("No Round or Lab found matching the query")) from exc

    if not isinstance(self.obj, (LabBase, RoundBase)):
        raise Http404(_("No Round or Lab found matching the query"))
    return super().get_queryset().filter(Q(round=self.obj) | Q(page=self.obj))

get

get(request, pk)
Source code in hypha/apply/funds/views.py
def get(self, request, pk):
    self.get_queryset()
    csv_data = export_submissions_to_csv(
        ApplicationSubmission.objects.filter(round=pk)
    )
    response = HttpResponse(csv_data.readlines(), content_type="text/csv")
    response["Content-Disposition"] = (
        "attachment; filename=" + str(self.obj) + ".csv"
    )
    return response

test_func

test_func()
Source code in hypha/apply/funds/views.py
def test_func(self):
    return can_export_submissions(self.request.user)

SubmissionsByRound

SubmissionsByRound(*args, **kwargs)

Bases: BaseAdminSubmissionsTable, DelegateableListView

Source code in hypha/apply/utils/views.py
def __init__(self, *args, **kwargs):
    self._form_views = {
        self.form_prefix + form_view.context_name: form_view
        for form_view in self.form_views
    }

form_prefix class-attribute instance-attribute

form_prefix = 'form-submitted-'

table_class class-attribute instance-attribute

table_class = AdminSubmissionsTable

filterset_class class-attribute instance-attribute

filterset_class = SubmissionFilterAndSearch

filter_action class-attribute instance-attribute

filter_action = ''

search_action class-attribute instance-attribute

search_action = ''

paginator_class class-attribute instance-attribute

paginator_class = LazyPaginator

table_pagination class-attribute instance-attribute

table_pagination = {'per_page': 25}

excluded property

excluded

template_name class-attribute instance-attribute

template_name = 'funds/submissions_by_round.html'

excluded_fields class-attribute instance-attribute

excluded_fields = ['round', 'fund'] + SUBMISSIONS_TABLE_EXCLUDED_FIELDS

post

post(request, *args, **kwargs)
Source code in hypha/apply/utils/views.py
def post(self, request, *args, **kwargs):
    self.object_list = self.get_queryset()
    return super().post(request, *args, **kwargs)

get_table_kwargs

get_table_kwargs(**kwargs)
Source code in hypha/apply/funds/views.py
def get_table_kwargs(self, **kwargs):
    return {**self.excluded, **kwargs}

get_filterset_kwargs

get_filterset_kwargs(filterset_class, **kwargs)
Source code in hypha/apply/funds/views.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

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/funds/views.py
def dispatch(self, request, *args, **kwargs):
    disp = super().dispatch(request, *args, **kwargs)
    if "export" in request.GET and can_export_submissions(request.user):
        csv_data = export_submissions_to_csv(self.object_list)
        response = HttpResponse(csv_data.readlines(), content_type="text/csv")
        response["Content-Disposition"] = "attachment; filename=submissions.csv"
        return response
    return disp

get_form_kwargs

get_form_kwargs()
Source code in hypha/apply/funds/views.py
def get_form_kwargs(self):
    kwargs = super().get_form_kwargs()
    kwargs["round"] = self.obj
    return kwargs

get_queryset

get_queryset()
Source code in hypha/apply/funds/views.py
def get_queryset(self):
    # We want to only show lab or Rounds in this view, their base class is Page
    try:
        self.obj = Page.objects.get(pk=self.kwargs.get("pk")).specific
    except Page.DoesNotExist as e:
        raise Http404(_("No Round or Lab found matching the query")) from e

    if not isinstance(self.obj, (LabBase, RoundBase)):
        raise Http404(_("No Round or Lab found matching the query"))
    return super().get_queryset().filter(Q(round=self.obj) | Q(page=self.obj))

get_context_data

get_context_data(**kwargs)
Source code in hypha/apply/funds/views.py
def get_context_data(self, **kwargs):
    return super().get_context_data(object=self.obj, **kwargs)

SubmissionsByStatus

SubmissionsByStatus(*args, **kwargs)

Bases: BaseAdminSubmissionsTable, DelegateableListView

Source code in hypha/apply/utils/views.py
def __init__(self, *args, **kwargs):
    self._form_views = {
        self.form_prefix + form_view.context_name: form_view
        for form_view in self.form_views
    }

form_prefix class-attribute instance-attribute

form_prefix = 'form-submitted-'

table_class class-attribute instance-attribute

table_class = AdminSubmissionsTable

filterset_class class-attribute instance-attribute

filterset_class = SubmissionFilterAndSearch

filter_action class-attribute instance-attribute

filter_action = ''

search_action class-attribute instance-attribute

search_action = ''

paginator_class class-attribute instance-attribute

paginator_class = LazyPaginator

table_pagination class-attribute instance-attribute

table_pagination = {'per_page': 25}

excluded_fields class-attribute instance-attribute

excluded_fields = SUBMISSIONS_TABLE_EXCLUDED_FIELDS

excluded property

excluded

template_name class-attribute instance-attribute

template_name = 'funds/submissions_by_status.html'

status_mapping class-attribute instance-attribute

status_mapping = PHASES_MAPPING

get_form_kwargs

get_form_kwargs()
Source code in hypha/apply/utils/views.py
def get_form_kwargs(self):
    return {
        "user": self.request.user,
    }

post

post(request, *args, **kwargs)
Source code in hypha/apply/utils/views.py
def post(self, request, *args, **kwargs):
    self.object_list = self.get_queryset()
    return super().post(request, *args, **kwargs)

get_table_kwargs

get_table_kwargs(**kwargs)
Source code in hypha/apply/funds/views.py
def get_table_kwargs(self, **kwargs):
    return {**self.excluded, **kwargs}

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/funds/views.py
def dispatch(self, request, *args, **kwargs):
    self.status = kwargs.get("status")
    try:
        status_data = self.status_mapping[self.status]
    except KeyError:
        raise Http404(_("No statuses match the requested value")) from None
    self.status_name = status_data["name"]
    self.statuses = status_data["statuses"]
    return super().dispatch(request, *args, **kwargs)

get_filterset_kwargs

get_filterset_kwargs(filterset_class, **kwargs)
Source code in hypha/apply/funds/views.py
def get_filterset_kwargs(self, filterset_class, **kwargs):
    return super().get_filterset_kwargs(
        filterset_class, limit_statuses=self.statuses, **kwargs
    )

get_queryset

get_queryset()
Source code in hypha/apply/funds/views.py
def get_queryset(self):
    return super().get_queryset().filter(status__in=self.statuses)

get_context_data

get_context_data(**kwargs)
Source code in hypha/apply/funds/views.py
def get_context_data(self, **kwargs):
    return super().get_context_data(
        status=self.status_name,
        statuses=self.statuses,
        **kwargs,
    )

ProgressSubmissionView

Bases: View

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/funds/views.py
def dispatch(self, request, *args, **kwargs):
    self.submission = get_object_or_404(ApplicationSubmission, id=kwargs.get("pk"))
    permission, reason = has_permission(
        "submission_edit",
        request.user,
        object=self.submission,
        raise_exception=False,
    )
    if not permission:
        messages.warning(self.request, reason)
        return HttpResponseRedirect(self.submission.get_absolute_url())
    return super(ProgressSubmissionView, self).dispatch(request, *args, **kwargs)

get

get(*args, **kwargs)
Source code in hypha/apply/funds/views.py
def get(self, *args, **kwargs):
    project_creation_form = ProgressSubmissionForm(
        instance=self.submission, user=self.request.user
    )
    return render(
        self.request,
        "funds/includes/progress_form.html",
        context={
            "form": project_creation_form,
            "value": _("Progress"),
            "object": self.submission,
        },
    )

post

post(*args, **kwargs)
Source code in hypha/apply/funds/views.py
def post(self, *args, **kwargs):
    form = ProgressSubmissionForm(
        self.request.POST, instance=self.submission, user=self.request.user
    )
    if form.is_valid():
        action = form.cleaned_data.get("action")
        redirect = DeterminationCreateOrUpdateView.should_redirect(
            self.request, self.submission, action
        )
        message_storage = messages.get_messages(self.request)
        if redirect:
            return HttpResponseClientRedirect(redirect.url, content=message_storage)

        self.submission.perform_transition(
            action, self.request.user, request=self.request
        )
        form.save()
        return HttpResponseClientRefresh()
    return render(
        self.request,
        "funds/includes/progress_form.html",
        context={"form": form, "value": _("Progress"), "object": self.submission},
        status=400,
    )

CreateProjectView

Bases: View

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/funds/views.py
def dispatch(self, request, *args, **kwargs):
    self.submission = get_object_or_404(ApplicationSubmission, id=kwargs.get("pk"))
    permission, reason = has_permission(
        "submission_edit",
        request.user,
        object=self.submission,
        raise_exception=False,
    )
    if not permission:
        messages.warning(self.request, reason)
        return HttpResponseRedirect(self.submission.get_absolute_url())
    return super(CreateProjectView, self).dispatch(request, *args, **kwargs)

get

get(*args, **kwargs)
Source code in hypha/apply/funds/views.py
def get(self, *args, **kwargs):
    project_creation_form = ProjectCreateForm(instance=self.submission)
    return render(
        self.request,
        "funds/includes/create_project_form.html",
        context={
            "form": project_creation_form,
            "value": _("Confirm"),
            "object": self.submission,
        },
    )

post

post(*args, **kwargs)
Source code in hypha/apply/funds/views.py
def post(self, *args, **kwargs):
    form = ProjectCreateForm(self.request.POST, instance=self.submission)
    if form.is_valid():
        project = form.save()
        # Record activity
        messenger(
            MESSAGES.CREATED_PROJECT,
            request=self.request,
            user=self.request.user,
            source=project,
            related=project.submission,
        )
        # add task for staff to add PAF to the project
        add_task_to_user_group(
            code=PROJECT_WAITING_PAF,
            user_group=Group.objects.filter(name=STAFF_GROUP_NAME),
            related_obj=project,
        )
        return HttpResponseClientRedirect(project.get_absolute_url())
    return render(
        self.request,
        "funds/includes/create_project_form.html",
        context={"form": form, "value": _("Confirm"), "object": self.object},
        status=400,
    )

UpdateLeadView

Bases: View

model class-attribute instance-attribute

form_class class-attribute instance-attribute

context_name class-attribute instance-attribute

context_name = 'lead_form'

template class-attribute instance-attribute

template = 'funds/modals/update_lead_form.html'

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/funds/views.py
def dispatch(self, request, *args, **kwargs):
    self.object = get_object_or_404(ApplicationSubmission, id=kwargs.get("pk"))
    permission, reason = has_permission(
        "submission_edit", request.user, object=self.object, raise_exception=False
    )
    if not permission:
        messages.warning(self.request, reason)
        return HttpResponseRedirect(self.object.get_absolute_url())
    return super().dispatch(request, *args, **kwargs)

get

get(*args, **kwargs)
Source code in hypha/apply/funds/views.py
def get(self, *args, **kwargs):
    lead_form = UpdateSubmissionLeadForm(instance=self.object)
    return render(
        self.request,
        self.template,
        context={
            "form": lead_form,
            "value": _("Submit"),
            "object": self.object,
        },
    )

post

post(*args, **kwargs)
Source code in hypha/apply/funds/views.py
def post(self, *args, **kwargs):
    form = UpdateSubmissionLeadForm(self.request.POST, instance=self.object)
    old_lead = copy(self.object.lead)
    if form.is_valid():
        form.save()
        messenger(
            MESSAGES.UPDATE_LEAD,
            request=self.request,
            user=self.request.user,
            source=form.instance,
            related=old_lead,
        )
        return HttpResponse(
            status=204,
            headers={
                "HX-Trigger": json.dumps(
                    {"leadUpdated": None, "showMessage": "Submission Lead updated."}
                ),
            },
        )
    return render(
        self.request,
        self.template,
        context={"form": form, "value": _("Update"), "object": self.object},
        status=400,
    )

UpdateReviewersView

Bases: View

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/funds/views.py
def dispatch(self, request, *args, **kwargs):
    self.submission = get_object_or_404(ApplicationSubmission, id=kwargs.get("pk"))
    permission, reason = has_permission(
        "submission_edit",
        request.user,
        object=self.submission,
        raise_exception=False,
    )
    if not permission:
        messages.warning(self.request, reason)
        return HttpResponseRedirect(self.submission.get_absolute_url())
    return super(UpdateReviewersView, self).dispatch(request, *args, **kwargs)

get

get(*args, **kwargs)
Source code in hypha/apply/funds/views.py
def get(self, *args, **kwargs):
    reviewer_form = UpdateReviewersForm(
        user=self.request.user, instance=self.submission
    )
    return render(
        self.request,
        "funds/includes/update_reviewer_form.html",
        context={
            "form": reviewer_form,
            "value": _("Update"),
            "object": self.submission,
        },
    )

post

post(*args, **kwargs)
Source code in hypha/apply/funds/views.py
def post(self, *args, **kwargs):
    form = UpdateReviewersForm(
        self.request.POST, user=self.request.user, instance=self.submission
    )
    old_reviewers = {copy(reviewer) for reviewer in form.instance.assigned.all()}
    if form.is_valid():
        form.save()
        new_reviewers = set(form.instance.assigned.all())
        added = new_reviewers - old_reviewers
        removed = old_reviewers - new_reviewers
        messenger(
            MESSAGES.REVIEWERS_UPDATED,
            request=self.request,
            user=self.request.user,
            source=self.submission,
            added=added,
            removed=removed,
        )
        # Update submission status if needed.
        services.set_status_after_reviewers_assigned(
            submission=form.instance,
            updated_by=self.request.user,
            request=self.request,
        )
        return HttpResponse(
            status=204,
            headers={
                "HX-Trigger": json.dumps(
                    {"reviewerUpdated": None, "showMessage": "Reviewers updated."}
                ),
            },
        )

    return render(
        self.request,
        "funds/includes/update_reviewer_form.html",
        context={"form": form, "value": _("Update"), "object": self.submission},
    )

UpdatePartnersView

Bases: View

model class-attribute instance-attribute

form_class class-attribute instance-attribute

form_class = UpdatePartnersForm

context_name class-attribute instance-attribute

context_name = 'partner_form'

template class-attribute instance-attribute

template = 'funds/modals/update_partner_form.html'

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/funds/views.py
def dispatch(self, request, *args, **kwargs):
    self.submission = get_object_or_404(ApplicationSubmission, id=kwargs.get("pk"))
    permission, reason = has_permission(
        "submission_edit",
        request.user,
        object=self.submission,
        raise_exception=False,
    )
    if not permission:
        messages.warning(self.request, reason)
        return HttpResponseRedirect(self.submission.get_absolute_url())
    return super(UpdatePartnersView, self).dispatch(request, *args, **kwargs)

get

get(*args, **kwargs)
Source code in hypha/apply/funds/views.py
def get(self, *args, **kwargs):
    partner_form = UpdatePartnersForm(
        user=self.request.user, instance=self.submission
    )
    return render(
        self.request,
        self.template,
        context={
            "form": partner_form,
            "value": _("Update"),
            "object": self.submission,
        },
    )

post

post(*args, **kwargs)
Source code in hypha/apply/funds/views.py
def post(self, *args, **kwargs):
    form = UpdatePartnersForm(
        self.request.POST, user=self.request.user, instance=self.submission
    )
    old_partners = set(self.submission.partners.all())
    if form.is_valid():
        form.save()
        new_partners = set(form.instance.partners.all())

        added = new_partners - old_partners
        removed = old_partners - new_partners
        messenger(
            MESSAGES.PARTNERS_UPDATED,
            request=self.request,
            user=self.request.user,
            source=self.submission,
            added=added,
            removed=removed,
        )

        messenger(
            MESSAGES.PARTNERS_UPDATED_PARTNER,
            request=self.request,
            user=self.request.user,
            source=self.submission,
            added=added,
            removed=removed,
        )

        return HttpResponse(
            status=204,
            headers={
                "HX-Trigger": json.dumps(
                    {
                        "partnerUpdated": None,
                        "showMessage": "Partners updated successfully.",
                    }
                ),
            },
        )

    return render(
        self.request,
        self.template,
        context={"form": form, "value": _("Update"), "object": self.submission},
        status=400,
    )

UpdateMetaTermsView

Bases: View

template class-attribute instance-attribute

template = 'funds/includes/update_meta_terms_form.html'

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/funds/views.py
def dispatch(self, request, *args, **kwargs):
    self.submission = get_object_or_404(ApplicationSubmission, id=kwargs.get("pk"))
    permission, reason = has_permission(
        "submission_edit",
        request.user,
        object=self.submission,
        raise_exception=False,
    )
    if not permission:
        messages.warning(self.request, reason)
        return HttpResponseRedirect(self.submission.get_absolute_url())
    return super(UpdateMetaTermsView, self).dispatch(request, *args, **kwargs)

get

get(*args, **kwargs)
Source code in hypha/apply/funds/views.py
def get(self, *args, **kwargs):
    metaterms_form = UpdateMetaTermsForm(
        user=self.request.user, instance=self.submission
    )
    return render(
        self.request,
        self.template,
        context={
            "form": metaterms_form,
            "value": _("Update"),
            "object": self.submission,
        },
    )

post

post(*args, **kwargs)
Source code in hypha/apply/funds/views.py
def post(self, *args, **kwargs):
    form = UpdateMetaTermsForm(
        self.request.POST, instance=self.submission, user=self.request.user
    )
    if form.is_valid():
        form.save()

        return HttpResponse(
            status=204,
            headers={
                "HX-Trigger": json.dumps(
                    {
                        "metaTermsUpdated": None,
                        "showMessage": "Meta terms updated successfully.",
                    }
                ),
            },
        )
    return render(
        self.request,
        self.template,
        context={"form": form, "value": _("Update"), "object": self.submission},
        status=400,
    )

ReminderCreateView

Bases: View

dispatch

dispatch(request, *args, **kwargs)
Source code in hypha/apply/funds/views.py
def dispatch(self, request, *args, **kwargs):
    self.submission = get_object_or_404(ApplicationSubmission, id=kwargs.get("pk"))
    permission, reason = has_permission(
        "submission_edit",
        request.user,
        object=self.submission,
        raise_exception=False,
    )
    if not permission:
        messages.warning(self.request, reason)
        return HttpResponseRedirect(self.submission.get_absolute_url())
    return super(ReminderCreateView, self).dispatch(request, *args, **kwargs)

get

get(*args, **kwargs)
Source code in hypha/apply/funds/views.py
def get(self, *args, **kwargs):
    reminder_form = CreateReminderForm(instance=self.submission)
    return render(
        self.request,
        "funds/includes/create_reminder_form.html",
        context={
            "form": reminder_form,
            "value": _("Create Reminder"),
            "object": self.submission,
        },
    )

post

post(*args, **kwargs