from django.contrib import admin
from django.contrib.auth.admin import UserAdmin as DjangoUserAdmin
from django.contrib.auth.models import Group
from django.utils.translation import ugettext_lazy as _

from main.models import UserInfo, User, Child, Volunteer, Donor, Letter, Need, PurchaseForInstitute, PurchaseForNeed, \
    Activity, OngoingUserInfo


@admin.register(User)
class UserAdmin(DjangoUserAdmin):
    class UserInfoInline(admin.TabularInline):
        model = UserInfo
        extra = 1
        max_num = 1

    fieldsets = (
        (None, {'fields': ('email', 'password')}),
        (_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser')}),
        (_('Important dates'), {'fields': ('last_login', 'date_joined')}),
    )
    add_fieldsets = (
        (None, {
            'classes': ('wide',),
            'fields': ('email', 'password1', 'password2'),
        }),
    )
    list_display = ('email', 'userinfo', 'is_staff')
    search_fields = ('email', 'userinfo__first_name', 'userinfo__last_name')
    ordering = ('email',)
    inlines = [UserInfoInline]


admin.site.unregister(Group)
admin.site.register(Child)
admin.site.register(Volunteer)
admin.site.register(Donor)
admin.site.register(Letter)
admin.site.register(Need)
admin.site.register(PurchaseForInstitute)
admin.site.register(PurchaseForNeed)
admin.site.register(Activity)
admin.site.register(OngoingUserInfo)

[((10, 1, 10, 21), 'django.contrib.admin.register', 'admin.register', ({(10, 16, 10, 20): 'User'}, {}), '(User)', False, 'from django.contrib import admin\n'), ((34, 0, 34, 28), 'django.contrib.admin.site.unregister', 'admin.site.unregister', ({(34, 22, 34, 27): 'Group'}, {}), '(Group)', False, 'from django.contrib import admin\n'), ((35, 0, 35, 26), 'django.contrib.admin.site.register', 'admin.site.register', ({(35, 20, 35, 25): 'Child'}, {}), '(Child)', False, 'from django.contrib import admin\n'), ((36, 0, 36, 30), 'django.contrib.admin.site.register', 'admin.site.register', ({(36, 20, 36, 29): 'Volunteer'}, {}), '(Volunteer)', False, 'from django.contrib import admin\n'), ((37, 0, 37, 26), 'django.contrib.admin.site.register', 'admin.site.register', ({(37, 20, 37, 25): 'Donor'}, {}), '(Donor)', False, 'from django.contrib import admin\n'), ((38, 0, 38, 27), 'django.contrib.admin.site.register', 'admin.site.register', ({(38, 20, 38, 26): 'Letter'}, {}), '(Letter)', False, 'from django.contrib import admin\n'), ((39, 0, 39, 25), 'django.contrib.admin.site.register', 'admin.site.register', ({(39, 20, 39, 24): 'Need'}, {}), '(Need)', False, 'from django.contrib import admin\n'), ((40, 0, 40, 41), 'django.contrib.admin.site.register', 'admin.site.register', ({(40, 20, 40, 40): 'PurchaseForInstitute'}, {}), '(PurchaseForInstitute)', False, 'from django.contrib import admin\n'), ((41, 0, 41, 36), 'django.contrib.admin.site.register', 'admin.site.register', ({(41, 20, 41, 35): 'PurchaseForNeed'}, {}), '(PurchaseForNeed)', False, 'from django.contrib import admin\n'), ((42, 0, 42, 29), 'django.contrib.admin.site.register', 'admin.site.register', ({(42, 20, 42, 28): 'Activity'}, {}), '(Activity)', False, 'from django.contrib import admin\n'), ((43, 0, 43, 36), 'django.contrib.admin.site.register', 'admin.site.register', ({(43, 20, 43, 35): 'OngoingUserInfo'}, {}), '(OngoingUserInfo)', False, 'from django.contrib import admin\n'), ((19, 9, 19, 25), 'django.utils.translation.ugettext_lazy', '_', ({(19, 11, 19, 24): '"""Permissions"""'}, {}), "('Permissions')", True, 'from django.utils.translation import ugettext_lazy as _\n'), ((20, 9, 20, 29), 'django.utils.translation.ugettext_lazy', '_', ({(20, 11, 20, 28): '"""Important dates"""'}, {}), "('Important dates')", True, 'from django.utils.translation import ugettext_lazy as _\n')]