admin.py 989 Bytes
Newer Older
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
from django.contrib import admin

from test_oauth.models import Character, TESTOAuth2Data


class CharacterAdmin(admin.ModelAdmin):
    fieldsets = (
        ('Character Information', {'fields': ('id', 'name')}),
        ('Allegiance', {'fields': ('alliance_id', 'corporation_id')}),
    )

    list_display = ('id', 'name', 'alliance_id', 'corporation_id')
    readonly_fields = ('id', 'name', 'alliance_id', 'corporation_id')
    search_fields = ('name', 'alliance_id', 'corporation_id')
    ordering = ('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',)
    search_fields = ('user',)
    ordering = ('user',)


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