admin.py 1 KB
Newer Older
Guilhem Saurel's avatar
Guilhem Saurel committed
1
from django.contrib import admin
Guilhem Saurel's avatar
initial  
Guilhem Saurel committed
2

Guilhem Saurel's avatar
admin    
Guilhem Saurel committed
3
from . import models
Guilhem Saurel's avatar
Guilhem Saurel committed
4

Guilhem Saurel's avatar
flake8    
Guilhem Saurel committed
5

Guilhem Saurel's avatar
Guilhem Saurel committed
6
class RobotpkgInline(admin.TabularInline):
7
8
9
    model = models.Robotpkg


Guilhem Saurel's avatar
Guilhem Saurel committed
10
11
@admin.register(models.Contributor)
class ContributorAdmin(admin.ModelAdmin):
Guilhem Saurel's avatar
Guilhem Saurel committed
12
    def get_queryset(self, request):
Guilhem Saurel's avatar
Guilhem Saurel committed
13
        return super().get_queryset(request).gepettist().distinct()
Guilhem Saurel's avatar
flake8    
Guilhem Saurel committed
14
15


Guilhem Saurel's avatar
Guilhem Saurel committed
16
17
@admin.register(models.Dependency)
class DependencyAdmin(admin.ModelAdmin):
18
19
20
    autocomplete_fields = ('project', 'library')


Guilhem Saurel's avatar
Guilhem Saurel committed
21
22
@admin.register(models.Project)
class ProjectAdmin(admin.ModelAdmin):
23
    search_fields = ('name', 'slug')
24
    inlines = [RobotpkgInline]
25
26


Guilhem Saurel's avatar
Guilhem Saurel committed
27
@admin.register(models.Target)
Guilhem Saurel's avatar
typo    
Guilhem Saurel committed
28
class TargetAdmin(admin.ModelAdmin):
Guilhem Saurel's avatar
Guilhem Saurel committed
29
30
31
    list_display = ('name', 'active', 'main', 'public')


Guilhem Saurel's avatar
admin    
Guilhem Saurel committed
32
33
for model in [
        models.License,
Guilhem Saurel's avatar
Guilhem Saurel committed
34
        models.Forge,
Guilhem Saurel's avatar
admin    
Guilhem Saurel committed
35
36
37
38
39
40
41
42
        models.Namespace,
        models.Repo,
        models.Branch,
        models.Robotpkg,
        models.Image,
        models.Tag,
        models.ContributorName,
        models.ContributorMail,
Guilhem Saurel's avatar
Guilhem Saurel committed
43
        models.IssuePr,
Guilhem Saurel's avatar
admin    
Guilhem Saurel committed
44
]:
Guilhem Saurel's avatar
Guilhem Saurel committed
45
    admin.site.register(model)