Source code for organizations.admin

__copyright__ = "Copyright © Stichting SciPost (SciPost Foundation)"
__license__ = "AGPL v3"


from django.contrib import admin

from guardian.admin import GuardedModelAdmin

from .models import (
    Organization,
    OrganizationLogo,
    OrganizationEvent,
    ContactPerson,
    Contact,
    ContactRole,
)


[docs]class OrganizationLogoInline(admin.TabularInline): model = OrganizationLogo extra = 0
[docs]class OrganizationEventInline(admin.TabularInline): model = OrganizationEvent extra = 0
[docs]class ContactPersonInline(admin.TabularInline): model = ContactPerson extra = 0
[docs]class OrganizationAdmin(GuardedModelAdmin): inlines = [ OrganizationLogoInline, OrganizationEventInline, ContactPersonInline, ] search_fields = ["name", "acronym"] autocomplete_fields = [ "parent", "superseded_by", ]
admin.site.register(Organization, OrganizationAdmin)
[docs]class ContactRoleInline(admin.TabularInline): model = ContactRole extra = 0 autocomplete_fields = [ "organization", ]
[docs]class ContactAdmin(admin.ModelAdmin): inlines = [ ContactRoleInline, ] search_fields = ["user__last_name", "user__first_name", "user__email"] autocomplete_fields = [ "user", ]
admin.site.register(Contact, ContactAdmin)
[docs]class ContactInline(admin.TabularInline): """ For use as an inline in User admin. """ model = Contact extra = 0