admin.py 1.02 KB
Newer Older
Lukas Burgey's avatar
Lukas Burgey committed
1
from django.contrib import admin
Lukas Burgey's avatar
Lukas Burgey committed
2
from django.contrib.auth.admin import UserAdmin
3
from django.contrib.auth.models import Group
Lukas Burgey's avatar
Lukas Burgey committed
4

5
from .auth.v1.models import OIDCConfig
Lukas Burgey's avatar
Lukas Burgey committed
6
from .models import models, brokers as broker_models
Lukas Burgey's avatar
Lukas Burgey committed
7
8


Lukas Burgey's avatar
Lukas Burgey committed
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,)

Lukas Burgey's avatar
Lukas Burgey committed
25
admin.site.register(OIDCConfig)
26
admin.site.register(broker_models.RabbitMQInstance)
Lukas Burgey's avatar
Lukas Burgey committed
27

Lukas Burgey's avatar
Lukas Burgey committed
28
admin.site.register(models.User, ClientAdmin)
29
30
admin.site.unregister(Group)
admin.site.register(Group)
31
32
admin.site.register(models.Site)
admin.site.register(models.Service)
Lukas Burgey's avatar
Lukas Burgey committed
33
34
35
36
37
admin.site.register(models.SSHPublicKey)

admin.site.register(models.Deployment)
admin.site.register(models.DeploymentState)
admin.site.register(models.DeploymentStateItem)