1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
from django import forms
from django.contrib import admin
from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
from archweb_dev.main.models import (AltForum, Arch, Donor,
Mirror, MirrorProtocol, MirrorUrl, MirrorRsync,
Package, Press, Repo, UserProfile)
class AltForumAdmin(admin.ModelAdmin):
list_display = ('language', 'name')
list_filter = ('language',)
ordering = ['name']
search_fields = ('name',)
class DonorAdmin(admin.ModelAdmin):
ordering = ['name']
search_fields = ('name',)
class MirrorUrlForm(forms.ModelForm):
class Meta:
model = MirrorUrl
def clean_url(self):
# ensure we always save the URL with a trailing slash
url = self.cleaned_data["url"].strip()
if url[-1] == '/':
return url
return url + '/'
class MirrorUrlInlineAdmin(admin.TabularInline):
model = MirrorUrl
form = MirrorUrlForm
extra = 3
class MirrorRsyncInlineAdmin(admin.TabularInline):
model = MirrorRsync
extra = 2
class MirrorAdmin(admin.ModelAdmin):
list_display = ('name', 'country', 'active', 'public', 'isos', 'notes')
list_filter = ('country', 'active', 'public')
ordering = ['country', 'name']
search_fields = ('name',)
inlines = [
MirrorUrlInlineAdmin,
MirrorRsyncInlineAdmin,
]
class PackageAdmin(admin.ModelAdmin):
list_display = ('pkgname', '_reponame', '_archname', '_maintainername')
list_filter = ('repo', 'arch', 'maintainer')
ordering = ['pkgname']
search_fields = ('pkgname',)
class PressAdmin(admin.ModelAdmin):
list_display = ('name', 'url')
ordering = ['name']
search_fields = ('name',)
admin.site.unregister(User)
class UserProfileInline(admin.StackedInline):
model = UserProfile
class UserProfileAdmin(UserAdmin):
inlines = [UserProfileInline]
admin.site.register(User, UserProfileAdmin)
admin.site.register(AltForum, AltForumAdmin)
admin.site.register(Donor, DonorAdmin)
admin.site.register(Mirror, MirrorAdmin)
admin.site.register(MirrorProtocol)
admin.site.register(Package, PackageAdmin)
admin.site.register(Press, PressAdmin)
admin.site.register(Arch)
admin.site.register(Repo)
# vim: set ts=4 sw=4 et:
|