admin.py 2.33 KB
Newer Older
Valentin Samir's avatar
Valentin Samir committed
1 2 3 4 5 6 7 8 9 10
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU General Public License version 3 for
# more details.
#
# You should have received a copy of the GNU General Public License version 3
# along with this program; if not, write to the Free Software Foundation, Inc., 51
# Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
#
# (c) 2015 Valentin Samir
Valentin Samir's avatar
Valentin Samir committed
11
"""module for the admin interface of the app"""
Valentin Samir's avatar
Valentin Samir committed
12
from django.contrib import admin
Valentin Samir's avatar
Valentin Samir committed
13 14 15
from .models import ServiceTicket, ProxyTicket, ProxyGrantingTicket, User, ServicePattern
from .models import Username, ReplaceAttributName, ReplaceAttributValue, FilterAttributValue
from .forms import TicketForm
Valentin Samir's avatar
Valentin Samir committed
16 17

class ServiceTicketInline(admin.TabularInline):
Valentin Samir's avatar
Valentin Samir committed
18
    """`ServiceTicket` in admin interface"""
Valentin Samir's avatar
Valentin Samir committed
19 20 21 22
    model = ServiceTicket
    extra = 0
    form = TicketForm
class ProxyTicketInline(admin.TabularInline):
Valentin Samir's avatar
Valentin Samir committed
23
    """`ProxyTicket` in admin interface"""
Valentin Samir's avatar
Valentin Samir committed
24 25 26 27
    model = ProxyTicket
    extra = 0
    form = TicketForm
class ProxyGrantingInline(admin.TabularInline):
Valentin Samir's avatar
Valentin Samir committed
28
    """`ProxyGrantingTicket` in admin interface"""
Valentin Samir's avatar
Valentin Samir committed
29 30 31 32 33
    model = ProxyGrantingTicket
    extra = 0
    form = TicketForm

class UserAdmin(admin.ModelAdmin):
Valentin Samir's avatar
Valentin Samir committed
34
    """`User` in admin interface"""
Valentin Samir's avatar
Valentin Samir committed
35 36
    inlines = (ServiceTicketInline, ProxyTicketInline, ProxyGrantingInline)

Valentin Samir's avatar
Valentin Samir committed
37
class UsernamesInline(admin.TabularInline):
Valentin Samir's avatar
Valentin Samir committed
38 39
    """`Username` in admin interface"""
    model = Username
Valentin Samir's avatar
Valentin Samir committed
40 41
    extra = 0
class ReplaceAttributNameInline(admin.TabularInline):
Valentin Samir's avatar
Valentin Samir committed
42
    """`ReplaceAttributName` in admin interface"""
Valentin Samir's avatar
Valentin Samir committed
43 44 45
    model = ReplaceAttributName
    extra = 0
class ReplaceAttributValueInline(admin.TabularInline):
Valentin Samir's avatar
Valentin Samir committed
46
    """`ReplaceAttributValue` in admin interface"""
Valentin Samir's avatar
Valentin Samir committed
47 48 49
    model = ReplaceAttributValue
    extra = 0
class FilterAttributValueInline(admin.TabularInline):
Valentin Samir's avatar
Valentin Samir committed
50
    """`FilterAttributValue` in admin interface"""
Valentin Samir's avatar
Valentin Samir committed
51 52 53
    model = FilterAttributValue
    extra = 0

Valentin Samir's avatar
Valentin Samir committed
54
class ServicePatternAdmin(admin.ModelAdmin):
Valentin Samir's avatar
Valentin Samir committed
55 56 57 58 59 60 61
    """`ServicePattern` in admin interface"""
    inlines = (
        UsernamesInline,
        ReplaceAttributNameInline,
        ReplaceAttributValueInline,
        FilterAttributValueInline
    )
Valentin Samir's avatar
Valentin Samir committed
62
    list_display = ('pos', 'name', 'pattern', 'proxy')
Valentin Samir's avatar
Valentin Samir committed
63 64 65 66


admin.site.register(User, UserAdmin)
admin.site.register(ServicePattern, ServicePatternAdmin)