admin.py 958 Bytes
Newer Older
1 2 3 4 5 6 7
from django.contrib import admin

from test_oauth.models import Character, TESTOAuth2Data


class CharacterAdmin(admin.ModelAdmin):
    fieldsets = (
ozzeh's avatar
ozzeh committed
8
        ('Character Information', {'fields': ('name')}),
9 10 11
        ('Allegiance', {'fields': ('alliance_id', 'corporation_id')}),
    )

ozzeh's avatar
ozzeh committed
12 13
    list_display = ('name', 'alliance_id', 'corporation_id')
    readonly_fields = ('name', 'alliance_id', 'corporation_id')
14 15 16 17 18 19 20 21 22 23 24 25
    search_fields = ('name', 'alliance_id', 'corporation_id')


class TESTOAuth2DataAdmin(admin.ModelAdmin):
    fieldsets = (
        ('User', {'fields': ('user',)}),
        ('OAuth2', {'fields': ('access_token', 'refresh_token')}),
        ('Data', {'fields': ('primary_character',)}),
    )

    list_display = ('user', 'primary_character')
    readonly_fields = ('user',)
ozzeh's avatar
ozzeh committed
26
    search_fields = ('user__username',)
27 28 29 30 31
    ordering = ('user',)


admin.site.register(Character, CharacterAdmin)
admin.site.register(TESTOAuth2Data, TESTOAuth2DataAdmin)