Skip to content

Admin

hypha.apply.review.admin

CloneView

CloneView(*args, **kwargs)

Bases: CreateView, InstanceSpecificView

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

ReviewFormAdmin

Bases: ListRelatedMixin, ModelAdmin

model class-attribute instance-attribute

model = ReviewForm

menu_icon class-attribute instance-attribute

menu_icon = str(REVIEW_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 = CreateReviewFormView

edit_view_class class-attribute instance-attribute

edit_view_class = EditReviewFormView

related_models class-attribute instance-attribute

related_models = [('applicationbasereviewform', 'application'), ('roundbasereviewform', 'round'), ('labbasereviewform', '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/review/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/review/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)