Skip to content

Admin

hypha.apply.utils.admin

ListRelatedMixin

Provides a used_by column which can be found by defining related models in the following format:

related_models = [ (, ), ]

e.g. This would be object._set.field

get_queryset

get_queryset(request)
Source code in hypha/apply/utils/admin.py
def get_queryset(self, request):
    qs = super().get_queryset(request)
    related = [f"{form}_set__{field}" for form, field in self.related_models]
    return qs.prefetch_related(*related)

used_by

used_by(obj)
Source code in hypha/apply/utils/admin.py
def used_by(self, obj):
    rows = []
    for form, field in self.related_models:
        related = self._list_related(obj, form, field)
        if related:
            rows.append(related)
    return mark_safe(", ".join(rows))

RelatedFormsMixin

Provide columns for Application forms, Review forms, and Determination forms attached to the object.

Using to show the related forms in funds, labs and rounds listing.

application_forms

application_forms(obj)
Source code in hypha/apply/utils/admin.py
def application_forms(self, obj):
    def build_urls(application_forms):
        for application_form in application_forms:
            url = reverse(
                "funds_applicationform_modeladmin_edit",
                args=[application_form.form.id],
            )
            yield f'<a href="{url}">{application_form}</a>'

    urls = list(build_urls(obj.forms.all()))

    if not urls:
        return

    return mark_safe("<br />".join(urls))

review_forms

review_forms(obj)
Source code in hypha/apply/utils/admin.py
def review_forms(self, obj):
    def build_urls(review_forms):
        for review_form in review_forms:
            url = reverse(
                "review_reviewform_modeladmin_edit", args=[review_form.form.id]
            )
            yield f'<a href="{url}">{review_form}</a>'

    urls = list(build_urls(obj.review_forms.all()))

    if not urls:
        return

    return mark_safe("<br />".join(urls))

determination_forms

determination_forms(obj)
Source code in hypha/apply/utils/admin.py
def determination_forms(self, obj):
    def build_urls(determination_forms):
        for determination_form in determination_forms:
            url = reverse(
                "determinations_determinationform_modeladmin_edit",
                args=[determination_form.form.id],
            )
            yield f'<a href="{url}">{determination_form}</a>'

    urls = list(build_urls(obj.determination_forms.all()))

    if not urls:
        return

    return mark_safe("<br />".join(urls))

AdminIcon

Bases: Enum

Enum used to keep Wagtail icons consistent across the admin interface

Icon names pulled from https://docs.wagtail.org/en/stable/advanced_topics/icons.html#available-icons

ROUND class-attribute instance-attribute

ROUND = auto()

SCREENING_STATUS class-attribute instance-attribute

SCREENING_STATUS = auto()

SEALED_ROUND class-attribute instance-attribute

SEALED_ROUND = auto()

FUND class-attribute instance-attribute

FUND = auto()

REQUEST_FOR_PARTNERS class-attribute instance-attribute

REQUEST_FOR_PARTNERS = auto()

LAB class-attribute instance-attribute

LAB = auto()

REVIEWER_ROLE class-attribute instance-attribute

REVIEWER_ROLE = auto()

APPLICATION_FORM class-attribute instance-attribute

APPLICATION_FORM = auto()

APPLY class-attribute instance-attribute

APPLY = auto()

DOCUMENT_CATEGORY class-attribute instance-attribute

DOCUMENT_CATEGORY = auto()

CONTRACT_DOCUMENT_CATEGORY class-attribute instance-attribute

CONTRACT_DOCUMENT_CATEGORY = auto()

PROJECT_FORM class-attribute instance-attribute

PROJECT_FORM = auto()

PROJECT_SOW_FORM class-attribute instance-attribute

PROJECT_SOW_FORM = auto()

PROJECT_REPORT_FORM class-attribute instance-attribute

PROJECT_REPORT_FORM = auto()

PROJECT class-attribute instance-attribute

PROJECT = auto()

REVIEW_FORM class-attribute instance-attribute

REVIEW_FORM = auto()

CATEGORY class-attribute instance-attribute

CATEGORY = auto()

META_TERM class-attribute instance-attribute

META_TERM = auto()

DETERMINATION_FORM class-attribute instance-attribute

DETERMINATION_FORM = auto()