Skip to content

Admin

hypha.apply.funds.admin

BaseRoundAdmin

Bases: ModelAdmin

choose_parent_view_class class-attribute instance-attribute

choose_parent_view_class = RoundFundChooserView

choose_parent_template_name class-attribute instance-attribute

choose_parent_template_name = 'funds/admin/parent_chooser.html'

button_helper_class class-attribute instance-attribute

button_helper_class = ButtonsWithPreview

fund

fund(obj)
Source code in hypha/apply/funds/admin.py
def fund(self, obj):
    return obj.get_parent()

RoundAdmin

Bases: BaseRoundAdmin, RelatedFormsMixin

choose_parent_view_class class-attribute instance-attribute

choose_parent_view_class = RoundFundChooserView

choose_parent_template_name class-attribute instance-attribute

choose_parent_template_name = 'funds/admin/parent_chooser.html'

button_helper_class class-attribute instance-attribute

button_helper_class = ButtonsWithPreview

model class-attribute instance-attribute

model = Round

menu_icon class-attribute instance-attribute

menu_icon = str(ROUND)

list_display class-attribute instance-attribute

list_display = ('title', 'fund', 'start_date', 'end_date', 'application_forms', 'review_forms')

list_filter class-attribute instance-attribute

list_filter = (RoundStateListFilter)

url_helper_class class-attribute instance-attribute

url_helper_class = RoundAdminURLHelper

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))

fund

fund(obj)
Source code in hypha/apply/funds/admin.py
def fund(self, obj):
    url = self.url_helper.get_action_url("edit", obj.fund.id)
    url_tag = f'<a href="{url}">{obj.fund}</a>'
    return mark_safe(url_tag)

ScreeningStatusPermissionHelper

Bases: PermissionHelper

user_can_edit_obj

user_can_edit_obj(user, obj)

Return a boolean to indicate whether user is permitted to 'change' a specific self.model instance.

Source code in hypha/apply/funds/admin.py
def user_can_edit_obj(self, user, obj):
    """
    Return a boolean to indicate whether `user` is permitted to 'change'
    a specific `self.model` instance.
    """
    return user.is_superuser

user_can_delete_obj

user_can_delete_obj(user, obj)

Return a boolean to indicate whether user is permitted to 'delete' a specific self.model instance.

Source code in hypha/apply/funds/admin.py
def user_can_delete_obj(self, user, obj):
    """
    Return a boolean to indicate whether `user` is permitted to 'delete'
    a specific `self.model` instance.
    """
    return user.is_superuser

ScreeningStatusAdmin

Bases: ModelAdmin

model class-attribute instance-attribute

menu_icon class-attribute instance-attribute

menu_icon = str(SCREENING_STATUS)

permission_helper_class class-attribute instance-attribute

permission_helper_class = ScreeningStatusPermissionHelper

list_display class-attribute instance-attribute

list_display = ('title', 'yes', 'default')

SealedRoundAdmin

Bases: BaseRoundAdmin

choose_parent_view_class class-attribute instance-attribute

choose_parent_view_class = RoundFundChooserView

choose_parent_template_name class-attribute instance-attribute

choose_parent_template_name = 'funds/admin/parent_chooser.html'

button_helper_class class-attribute instance-attribute

button_helper_class = ButtonsWithPreview

model class-attribute instance-attribute

model = SealedRound

menu_icon class-attribute instance-attribute

menu_icon = str(SEALED_ROUND)

menu_label class-attribute instance-attribute

menu_label = 'Sealed Rounds'

list_display class-attribute instance-attribute

list_display = ('title', 'fund', 'start_date', 'end_date')

fund

fund(obj)
Source code in hypha/apply/funds/admin.py
def fund(self, obj):
    return obj.get_parent()

FundAdmin

Bases: ModelAdmin, RelatedFormsMixin

model class-attribute instance-attribute

model = FundType

menu_icon class-attribute instance-attribute

menu_icon = str(FUND)

menu_label class-attribute instance-attribute

menu_label = 'Funds'

list_display class-attribute instance-attribute

list_display = ('title', 'application_forms', 'review_forms', 'determination_forms')

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))

RFPAdmin

Bases: ModelAdmin

model class-attribute instance-attribute

model = RequestForPartners

menu_icon class-attribute instance-attribute

menu_icon = str(REQUEST_FOR_PARTNERS)

menu_label class-attribute instance-attribute

menu_label = 'Request For Partners'

LabAdmin

Bases: ModelAdmin, RelatedFormsMixin

model class-attribute instance-attribute

model = LabType

menu_icon class-attribute instance-attribute

menu_icon = str(LAB)

menu_label class-attribute instance-attribute

menu_label = 'Labs'

list_display class-attribute instance-attribute

list_display = ('title', 'application_forms', 'review_forms', 'determination_forms')

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))

ReviewerRoleAdmin

Bases: ModelAdmin

model class-attribute instance-attribute

model = ReviewerRole

menu_icon class-attribute instance-attribute

menu_icon = str(REVIEWER_ROLE)

menu_label class-attribute instance-attribute

menu_label = 'Reviewer Roles'

DeletePermission

Bases: PermissionHelper, ListRelatedMixin

related_models class-attribute instance-attribute

related_models = [('applicationbaseform', 'application'), ('roundbaseform', 'round'), ('labbaseform', 'lab')]

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))

user_can_delete_obj

user_can_delete_obj(user, obj)
Source code in hypha/apply/funds/admin.py
def user_can_delete_obj(self, user, obj):
    if str(self.used_by(obj)):
        return False
    return True

ApplicationFormAdmin

Bases: ListRelatedMixin, ModelAdmin

model class-attribute instance-attribute

menu_icon class-attribute instance-attribute

menu_icon = str(APPLICATION_FORM)

list_display class-attribute instance-attribute

list_display = ('name', 'used_by')

list_filter class-attribute instance-attribute

list_filter = (FormsFundRoundListFilter)

permission_helper_class class-attribute instance-attribute

permission_helper_class = DeletePermission

button_helper_class class-attribute instance-attribute

button_helper_class = ApplicationFormButtonHelper

create_view_class class-attribute instance-attribute

create_view_class = CreateApplicationFormView

edit_view_class class-attribute instance-attribute

edit_view_class = EditApplicationFormView

related_models class-attribute instance-attribute

related_models = [('applicationbaseform', 'application'), ('roundbaseform', 'round'), ('labbaseform', 'lab')]

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))

copy_form_view

copy_form_view(request, instance_pk)
Source code in hypha/apply/funds/admin.py
def copy_form_view(self, request, instance_pk):
    kwargs = {"model_admin": self, "form_pk": instance_pk}
    view_class = CopyApplicationFormViewClass
    return view_class.as_view(**kwargs)(request)

get_admin_urls_for_registration

get_admin_urls_for_registration()

Add the url for creating form copy.

Source code in hypha/apply/funds/admin.py
def get_admin_urls_for_registration(self):
    """Add the url for creating form copy."""
    urls = super().get_admin_urls_for_registration()
    copy_form_url = re_path(
        self.url_helper.get_action_url_pattern("copy_form"),
        self.copy_form_view,
        name=self.url_helper.get_action_url_name("copy_form"),
    )
    return urls + (copy_form_url,)

ApplicationSettingAdmin

ApplicationSettingAdmin(parent=None)

Bases: SettingModelAdmin

Don't allow initialization unless self.model is set to a valid model

Source code in hypha/core/wagtail/admin/options.py
def __init__(self, parent=None):
    """
    Don't allow initialization unless self.model is set to a valid model
    """
    if not self.model or not issubclass(self.model, BaseSiteSetting):
        raise ImproperlyConfigured(
            "The model attribute on your '%s' class must be set, and "
            "must be inherit BaseSiteSetting class." % self.__class__.__name__
        )
    self.parent = parent

    self.is_pagemodel = issubclass(self.model, Page)
    self.permission_helper = self.get_permission_helper_class()(
        self.model, self.inspect_view_enabled
    )

inspect_view_enabled class-attribute instance-attribute

inspect_view_enabled = False

permission_helper_class class-attribute instance-attribute

permission_helper_class = None

parent instance-attribute

parent = parent

is_pagemodel instance-attribute

is_pagemodel = issubclass(model, Page)

permission_helper instance-attribute

permission_helper = get_permission_helper_class()(model, inspect_view_enabled)

model class-attribute instance-attribute

get_menu_item

get_menu_item(order=None)
Source code in hypha/core/wagtail/admin/options.py
def get_menu_item(self, order=None):
    return SettingMenuItem(self.model)

get_admin_urls_for_registration

get_admin_urls_for_registration()
Source code in hypha/core/wagtail/admin/options.py
def get_admin_urls_for_registration(self):
    return ()

get_permission_helper_class

get_permission_helper_class()

Returns a permission_helper class to help with permission-based logic for the given model.

Copied from the wagtail's ModelAdmin

Source code in hypha/core/wagtail/admin/options.py
def get_permission_helper_class(self):
    """
    Returns a permission_helper class to help with permission-based logic
    for the given model.

    **Copied from the wagtail's ModelAdmin**
    """
    if self.permission_helper_class:
        return self.permission_helper_class
    if self.is_pagemodel:
        return PagePermissionHelper
    return PermissionHelper

get_permissions_for_registration

get_permissions_for_registration()

Utilised by Wagtail's 'register_permissions' hook to allow permissions for a model to be assigned to groups in settings. This is only required if the model isn't a Page model, and isn't registered as a Snippet

Copied from the wagtail's ModelAdmin

Source code in hypha/core/wagtail/admin/options.py
def get_permissions_for_registration(self):
    """
    Utilised by Wagtail's 'register_permissions' hook to allow permissions
    for a model to be assigned to groups in settings. This is only required
    if the model isn't a Page model, and isn't registered as a Snippet

    **Copied from the wagtail's ModelAdmin**
    """
    from wagtail.snippets.models import SNIPPET_MODELS

    if not self.is_pagemodel and self.model not in SNIPPET_MODELS:
        return self.permission_helper.get_all_model_permissions()
    return Permission.objects.none()

ReviewerSettingAdmin

ReviewerSettingAdmin(parent=None)

Bases: SettingModelAdmin

Don't allow initialization unless self.model is set to a valid model

Source code in hypha/core/wagtail/admin/options.py
def __init__(self, parent=None):
    """
    Don't allow initialization unless self.model is set to a valid model
    """
    if not self.model or not issubclass(self.model, BaseSiteSetting):
        raise ImproperlyConfigured(
            "The model attribute on your '%s' class must be set, and "
            "must be inherit BaseSiteSetting class." % self.__class__.__name__
        )
    self.parent = parent

    self.is_pagemodel = issubclass(self.model, Page)
    self.permission_helper = self.get_permission_helper_class()(
        self.model, self.inspect_view_enabled
    )

inspect_view_enabled class-attribute instance-attribute

inspect_view_enabled = False

permission_helper_class class-attribute instance-attribute

permission_helper_class = None

parent instance-attribute

parent = parent

is_pagemodel instance-attribute

is_pagemodel = issubclass(model, Page)

permission_helper instance-attribute

permission_helper = get_permission_helper_class()(model, inspect_view_enabled)

model class-attribute instance-attribute

get_menu_item

get_menu_item(order=None)
Source code in hypha/core/wagtail/admin/options.py
def get_menu_item(self, order=None):
    return SettingMenuItem(self.model)

get_admin_urls_for_registration

get_admin_urls_for_registration()
Source code in hypha/core/wagtail/admin/options.py
def get_admin_urls_for_registration(self):
    return ()

get_permission_helper_class

get_permission_helper_class()

Returns a permission_helper class to help with permission-based logic for the given model.

Copied from the wagtail's ModelAdmin

Source code in hypha/core/wagtail/admin/options.py
def get_permission_helper_class(self):
    """
    Returns a permission_helper class to help with permission-based logic
    for the given model.

    **Copied from the wagtail's ModelAdmin**
    """
    if self.permission_helper_class:
        return self.permission_helper_class
    if self.is_pagemodel:
        return PagePermissionHelper
    return PermissionHelper

get_permissions_for_registration

get_permissions_for_registration()

Utilised by Wagtail's 'register_permissions' hook to allow permissions for a model to be assigned to groups in settings. This is only required if the model isn't a Page model, and isn't registered as a Snippet

Copied from the wagtail's ModelAdmin

Source code in hypha/core/wagtail/admin/options.py
def get_permissions_for_registration(self):
    """
    Utilised by Wagtail's 'register_permissions' hook to allow permissions
    for a model to be assigned to groups in settings. This is only required
    if the model isn't a Page model, and isn't registered as a Snippet

    **Copied from the wagtail's ModelAdmin**
    """
    from wagtail.snippets.models import SNIPPET_MODELS

    if not self.is_pagemodel and self.model not in SNIPPET_MODELS:
        return self.permission_helper.get_all_model_permissions()
    return Permission.objects.none()

ApplyAdminGroup

Bases: ModelAdminGroup

menu_label class-attribute instance-attribute

menu_label = 'Apply'

menu_icon class-attribute instance-attribute

menu_icon = str(APPLY)