Skip to content

Admin

hypha.apply.determinations.admin

CloneView

CloneView(*args, **kwargs)

Bases: CreateView, InstanceSpecificView

Source code in hypha/apply/determinations/admin.py
def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)
    self.instance.pk = None

DeterminationFormAdmin

Bases: ListRelatedMixin, ModelAdmin

model class-attribute instance-attribute

menu_icon class-attribute instance-attribute

menu_icon = str(DETERMINATION_FORM)

list_display class-attribute instance-attribute

list_display = ('name', 'used_by')

button_helper_class class-attribute instance-attribute

button_helper_class = ButtonsWithClone

clone_view_class class-attribute instance-attribute

clone_view_class = CloneView

create_view_class class-attribute instance-attribute

create_view_class = CreateDeterminationFormView

edit_view_class class-attribute instance-attribute

edit_view_class = EditDeterminationFormView

related_models class-attribute instance-attribute

related_models = [('applicationbasedeterminationform', 'application'), ('roundbasedeterminationform', 'round'), ('labbasedeterminationform', '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))

get_admin_urls_for_registration

get_admin_urls_for_registration()
Source code in hypha/apply/determinations/admin.py
def get_admin_urls_for_registration(self):
    urls = super().get_admin_urls_for_registration()

    urls += (
        re_path(
            self.url_helper.get_action_url_pattern("clone"),
            self.clone_view,
            name=self.url_helper.get_action_url_name("clone"),
        ),
    )

    return urls

clone_view

clone_view(request, **kwargs)
Source code in hypha/apply/determinations/admin.py
def clone_view(self, request, **kwargs):
    kwargs.update(**{"model_admin": self})
    view_class = self.clone_view_class
    return view_class.as_view(**kwargs)(request)

DeterminationMessageSettingsAdmin

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

DeterminationFormSettingsAdmin

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