Skip to content

Admin

hypha.apply.projects.admin

DocumentCategoryAdmin

Bases: ModelAdmin

model class-attribute instance-attribute

menu_icon class-attribute instance-attribute

menu_icon = str(DOCUMENT_CATEGORY)

list_display class-attribute instance-attribute

list_display = ('name', 'required')

ContractDocumentCategoryAdmin

Bases: ModelAdmin

model class-attribute instance-attribute

menu_icon class-attribute instance-attribute

menu_icon = str(CONTRACT_DOCUMENT_CATEGORY)

list_display class-attribute instance-attribute

list_display = ('name', 'required')

ProjectFormAdmin

Bases: ListRelatedMixin, ModelAdmin

model class-attribute instance-attribute

model = ProjectForm

menu_label class-attribute instance-attribute

menu_label = 'Project Forms'

menu_icon class-attribute instance-attribute

menu_icon = str(PROJECT_FORM)

list_display class-attribute instance-attribute

list_display = ('name', 'used_by')

create_view_class class-attribute instance-attribute

create_view_class = CreateProjectFormView

edit_view_class class-attribute instance-attribute

edit_view_class = EditProjectFormView

related_models class-attribute instance-attribute

related_models = [('applicationbaseprojectform', 'application'), ('labbaseprojectform', '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))

ProjectSOWFormAdmin

Bases: ListRelatedMixin, ModelAdmin

model class-attribute instance-attribute

menu_label class-attribute instance-attribute

menu_label = 'SOW Forms'

menu_icon class-attribute instance-attribute

menu_icon = str(PROJECT_SOW_FORM)

list_display class-attribute instance-attribute

list_display = ('name', 'used_by')

create_view_class class-attribute instance-attribute

create_view_class = CreateProjectSOWFormView

edit_view_class class-attribute instance-attribute

edit_view_class = EditProjectSOWFormView

related_models class-attribute instance-attribute

related_models = [('applicationbaseprojectsowform', 'application'), ('labbaseprojectsowform', '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))

ProjectReportFormAdmin

Bases: ListRelatedMixin, ModelAdmin

model class-attribute instance-attribute

menu_label class-attribute instance-attribute

menu_label = 'Report Forms'

menu_icon class-attribute instance-attribute

menu_icon = str(PROJECT_REPORT_FORM)

list_display class-attribute instance-attribute

list_display = ('name', 'used_by')

create_view_class class-attribute instance-attribute

create_view_class = CreateProjectReportFormView

edit_view_class class-attribute instance-attribute

edit_view_class = EditProjectReportFormView

related_models class-attribute instance-attribute

related_models = [('applicationbaseprojectreportform', 'application'), ('labbaseprojectreportform', '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))

ProjectSettingsAdmin

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

ProjectAdminGroup

Bases: ModelAdminGroup

menu_label class-attribute instance-attribute

menu_label = 'Projects'

menu_icon class-attribute instance-attribute

menu_icon = str(PROJECT)