admin.py 733 Bytes
Newer Older
Lukas Burgey's avatar
Lukas Burgey committed
1
from django.contrib import admin
Lukas Burgey's avatar
Lukas Burgey committed
2
3
from django.contrib.auth.admin import UserAdmin

Lukas Burgey's avatar
Lukas Burgey committed
4
from . import models
5
from .auth.v1.models import OIDCConfig
Lukas Burgey's avatar
Lukas Burgey committed
6
7


Lukas Burgey's avatar
Lukas Burgey committed
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class TypeFilter(admin.SimpleListFilter):
    title = 'Type'
    parameter_name = 'user_type'

    def lookups(self, request, model_admin):
        return models.User.TYPE_CHOICES

    def queryset(self, request, queryset):
        if self.value():
            return queryset.filter(user_type=self.value())
        return queryset


class ClientAdmin(UserAdmin):
    list_filter = (TypeFilter,)

admin.site.register(models.User, ClientAdmin)
25
26
admin.site.register(models.Site)
admin.site.register(models.Service)
Lukas Burgey's avatar
Lukas Burgey committed
27
admin.site.register(models.RabbitMQInstance)
Lukas Burgey's avatar
Lukas Burgey committed
28
admin.site.register(OIDCConfig)