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.
80 lines
2.3 KiB
80 lines
2.3 KiB
from django.contrib import admin
|
|
from django.contrib.auth import get_user_model
|
|
from django.contrib.auth.admin import UserAdmin as BaseUserAdmin
|
|
from django.utils.translation import gettext_lazy as _
|
|
|
|
from .models import AuthorRequest, EmailSubscription, SubscriptionCategory, EmailLog
|
|
|
|
User = get_user_model()
|
|
|
|
|
|
class FromLandingFilter(admin.SimpleListFilter):
|
|
title = 'С лендинга'
|
|
parameter_name = 'from_landing'
|
|
|
|
def lookups(self, request, model_admin):
|
|
return (
|
|
('yes', 'Да'),
|
|
)
|
|
|
|
def queryset(self, request, queryset):
|
|
if self.value() == 'yes':
|
|
return queryset.exclude(phone2__isnull=True)
|
|
|
|
|
|
@admin.register(User)
|
|
class UserAdmin(BaseUserAdmin):
|
|
list_display = (
|
|
'email',
|
|
'get_full_name',
|
|
'phone',
|
|
'phone2',
|
|
'role',
|
|
'is_staff',
|
|
'is_active',
|
|
)
|
|
list_filter = (FromLandingFilter, 'is_staff', 'is_superuser', 'is_active',)
|
|
fieldsets = (
|
|
(None, {'fields': ('username', 'password')}),
|
|
(_('Personal info'), {'fields': ('first_name', 'last_name', 'email', 'gender', 'about', 'photo',
|
|
'phone', 'phone2')}),
|
|
('Teacher', {'fields': ('show_in_mainpage', 'trial_lesson', 'instagram_hashtag',)}),
|
|
('Facebook Auth data', {'fields': ('fb_id', 'fb_data', 'is_email_proved')}),
|
|
(_('Permissions'), {'fields': ('role', 'is_active', 'is_staff', 'is_superuser',
|
|
'groups', 'user_permissions', 'show_in_mainpage')}),
|
|
(_('Important dates'), {'fields': ('last_login', 'date_joined')}),
|
|
('Social urls', {'fields': ('instagram', 'facebook', 'twitter', 'pinterest', 'youtube', 'vkontakte', )}),
|
|
)
|
|
|
|
|
|
@admin.register(AuthorRequest)
|
|
class AuthorRequestAdmin(admin.ModelAdmin):
|
|
list_display = (
|
|
'email',
|
|
'first_name',
|
|
'last_name',
|
|
'status',
|
|
'accepted_send_at',
|
|
'declined_send_at',
|
|
'created_at',
|
|
'update_at',
|
|
)
|
|
|
|
|
|
@admin.register(SubscriptionCategory)
|
|
class SubscriptionCategoryAdmin(admin.ModelAdmin):
|
|
list_display = ('title',)
|
|
|
|
|
|
@admin.register(EmailSubscription)
|
|
class EmailSubscriptionAdmin(admin.ModelAdmin):
|
|
list_display = (
|
|
'id',
|
|
'user',
|
|
'email',
|
|
)
|
|
|
|
|
|
@admin.register(EmailLog)
|
|
class EmailLogAdmin(admin.ModelAdmin):
|
|
pass
|
|
|