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)

[((355, 375), 'django.contrib.admin.register', 'admin.register', (['User'], {}), '(User)\n', (369, 375), False, 'from django.contrib import admin\n'), ((1093, 1121), 'django.contrib.admin.site.unregister', 'admin.site.unregister', (['Group'], {}), '(Group)\n', (1114, 1121), False, 'from django.contrib import admin\n'), ((1122, 1148), 'django.contrib.admin.site.register', 'admin.site.register', (['Child'], {}), '(Child)\n', (1141, 1148), False, 'from django.contrib import admin\n'), ((1149, 1179), 'django.contrib.admin.site.register', 'admin.site.register', (['Volunteer'], {}), '(Volunteer)\n', (1168, 1179), False, 'from django.contrib import admin\n'), ((1180, 1206), 'django.contrib.admin.site.register', 'admin.site.register', (['Donor'], {}), '(Donor)\n', (1199, 1206), False, 'from django.contrib import admin\n'), ((1207, 1234), 'django.contrib.admin.site.register', 'admin.site.register', (['Letter'], {}), '(Letter)\n', (1226, 1234), False, 'from django.contrib import admin\n'), ((1235, 1260), 'django.contrib.admin.site.register', 'admin.site.register', (['Need'], {}), '(Need)\n', (1254, 1260), False, 'from django.contrib import admin\n'), ((1261, 1302), 'django.contrib.admin.site.register', 'admin.site.register', (['PurchaseForInstitute'], {}), '(PurchaseForInstitute)\n', (1280, 1302), False, 'from django.contrib import admin\n'), ((1303, 1339), 'django.contrib.admin.site.register', 'admin.site.register', (['PurchaseForNeed'], {}), '(PurchaseForNeed)\n', (1322, 1339), False, 'from django.contrib import admin\n'), ((1340, 1369), 'django.contrib.admin.site.register', 'admin.site.register', (['Activity'], {}), '(Activity)\n', (1359, 1369), False, 'from django.contrib import admin\n'), ((1370, 1406), 'django.contrib.admin.site.register', 'admin.site.register', (['OngoingUserInfo'], {}), '(OngoingUserInfo)\n', (1389, 1406), False, 'from django.contrib import admin\n'), ((599, 615), 'django.utils.translation.ugettext_lazy', '_', (['"""Permissions"""'], {}), "('Permissions')\n", (600, 615), True, 'from django.utils.translation import ugettext_lazy as _\n'), ((682, 702), 'django.utils.translation.ugettext_lazy', '_', (['"""Important dates"""'], {}), "('Important dates')\n", (683, 702), True, 'from django.utils.translation import ugettext_lazy as _\n')]