You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.9 KiB
56 lines
1.9 KiB
# -*- coding: utf-8 -*-
|
|
from django.contrib import admin
|
|
from django.contrib.auth.admin import UserAdmin
|
|
from django.utils.translation import ugettext_lazy as _
|
|
|
|
from customer.utils import check_confirm_bonus_to_user
|
|
from myauth.models import DokUser, ConfirmEmail
|
|
from myauth.forms import CustomUserChangeForm, CustomUserCreationForm
|
|
|
|
|
|
class CustomUserAdmin(UserAdmin):
|
|
# The forms to add and change user instances
|
|
|
|
# The fields to be used in displaying the User model.
|
|
# These override the definitions on the base UserAdmin
|
|
# that reference the removed 'username' field
|
|
fieldsets = (
|
|
(None, {'fields': ('username', 'email', 'password')}),
|
|
(_('Personal info'), {'fields': ('first_name', 'last_name', 'profile')}),
|
|
(_('Permissions'), {'fields': ('is_active', 'is_staff', 'is_superuser',
|
|
'groups', 'user_permissions')}),
|
|
(_('Important dates'), {'fields': ('last_login', 'date_joined')}),
|
|
)
|
|
add_fieldsets = (
|
|
(None, {
|
|
'classes': ('wide',),
|
|
'fields': ('username', 'email', 'password1', 'password2')}
|
|
),
|
|
)
|
|
form = CustomUserChangeForm
|
|
add_form = CustomUserCreationForm
|
|
list_display = (
|
|
'username',
|
|
'email',
|
|
'first_name',
|
|
'last_name',
|
|
'is_staff',
|
|
'date_joined',
|
|
'remain_confirm_bonus_days',
|
|
'is_active',
|
|
)
|
|
search_fields = ('username', 'email', 'first_name', 'last_name')
|
|
ordering = ('email',)
|
|
|
|
def remain_confirm_bonus_days(self, obj):
|
|
confirm_bonus_days = check_confirm_bonus_to_user(obj)
|
|
if confirm_bonus_days != -1:
|
|
return confirm_bonus_days
|
|
else:
|
|
return '-'
|
|
|
|
remain_confirm_bonus_days.short_description = 'Дней для активации бонуса'
|
|
|
|
|
|
admin.site.register(DokUser, CustomUserAdmin)
|
|
admin.site.register(ConfirmEmail)
|
|
|