admin.py 907 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
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
24
25
26
admin.site.register(OIDCConfig)
admin.site.register(models.RabbitMQInstance)

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

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