This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
2018-11-14 18:14:14 +00:00
|
|
|
"""passbook core admin"""
|
|
|
|
|
|
|
|
from django.apps import apps
|
|
|
|
from django.contrib import admin
|
|
|
|
from django.contrib.admin.sites import AlreadyRegistered
|
|
|
|
from django.contrib.auth.admin import UserAdmin
|
2019-10-10 08:45:51 +00:00
|
|
|
from guardian.admin import GuardedModelAdmin
|
2018-11-14 18:14:14 +00:00
|
|
|
|
|
|
|
from passbook.core.models import User
|
|
|
|
|
|
|
|
|
|
|
|
def admin_autoregister(app):
|
|
|
|
"""Automatically register all models from app"""
|
|
|
|
app_models = apps.get_app_config(app).get_models()
|
|
|
|
for model in app_models:
|
|
|
|
try:
|
2019-10-10 08:45:51 +00:00
|
|
|
admin.site.register(model, GuardedModelAdmin)
|
2018-11-14 18:14:14 +00:00
|
|
|
except AlreadyRegistered:
|
|
|
|
pass
|
|
|
|
|
|
|
|
|
|
|
|
admin.site.register(User, UserAdmin)
|