Skip to content

Admin forms

hypha.apply.projects.admin_forms

ContractDocumentCategoryAdminForm

ContractDocumentCategoryAdminForm(*args, **kwargs)

Bases: WagtailAdminModelForm

Source code in hypha/apply/projects/admin_forms.py
def __init__(self, *args, **kwargs):
    super().__init__(*args, **kwargs)

    if not self.instance.pk:  # New instance, not saved yet
        default_groups = Group.objects.filter(name__in=ROLES_ORG_FACULTY)
        self.fields["document_access_view"].queryset = default_groups
        self.fields["document_access_view"].initial = default_groups.values_list(
            "pk", flat=True
        )
        self.initial["document_access_view"] = list(
            default_groups.values_list("pk", flat=True)
        )