admin.py 1.04 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
6
from . import models
from .models import brokers as broker_models
7
from .auth.v1.models import OIDCConfig
Lukas Burgey's avatar
Lukas Burgey committed
8
9


Lukas Burgey's avatar
Lukas Burgey committed
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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
26
admin.site.register(OIDCConfig)
27
admin.site.register(broker_models.RabbitMQInstance)
Lukas Burgey's avatar
Lukas Burgey committed
28

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

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