Админка
This commit is contained in:
1 parent
2a569ae3c9
commit
2e661083ad
9 files changed
+84
-52
No files matched your search
@@ -3,8 +3,12 @@ from .models import *
|
||||
# Register your models here.
|
||||
|
||||
class UserAdmin(admin.ModelAdmin):
|
||||
list_display=('username','fio', 'created_at', 'updated_at', 'is_active', 'is_staff')
|
||||
save_on_top = True
|
||||
list_display=('username','names', 'is_active', 'is_staff')
|
||||
search_fields = ('username',)
|
||||
ordering=('username',)
|
||||
|
||||
# fields=(('user', 'username'), 'is_active', 'is_staff', 'updated_at',)
|
||||
|
||||
|
||||
|
||||
|
||||
+16
-6
@@ -17,7 +17,7 @@ from django.contrib.auth import authenticate
|
||||
import json
|
||||
from django.forms.models import model_to_dict
|
||||
from userauth.models import DictEmployee
|
||||
from userauth.serializers import *
|
||||
|
||||
# all_fk: dict = {
|
||||
# "otdel": Otdel,
|
||||
# "department": Department,
|
||||
@@ -54,28 +54,38 @@ class UserManager(BaseUserManager):
|
||||
class User(AbstractBaseUser, PermissionsMixin):
|
||||
user = models.ForeignKey(DictEmployee, on_delete=models.PROTECT, null=True, blank=True, verbose_name='Сотрудник')
|
||||
password = models.CharField(max_length=128, null=True,blank=True,verbose_name='Пароль')
|
||||
username = models.CharField(db_index=True, max_length=255, unique=True, verbose_name='Имя пользователя')
|
||||
username = models.CharField(db_index=True, max_length=255, unique=True, verbose_name='Логин')
|
||||
# username2 = models.CharField(db_index=True, null=True, max_length=255, unique=True)
|
||||
is_active = models.BooleanField(default=True)
|
||||
is_staff = models.BooleanField(default=False)
|
||||
is_active = models.BooleanField(default=True, verbose_name='Активность')
|
||||
is_staff = models.BooleanField(default=False, verbose_name='Доступ в Админку')
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
# last_login = models.DateTimeField(auto_now=True, null=True)
|
||||
# external=models.ForeignKey(DictEmployee,db_constraint=False, null=True, on_delete=models.PROTECT)
|
||||
objects = UserManager()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
class Meta:
|
||||
|
||||
verbose_name = "Зарегистрированный участник"
|
||||
verbose_name_plural = "Зарегистрированные участники"
|
||||
|
||||
USERNAME_FIELD = 'username'
|
||||
|
||||
# REQUIRED_FIELDS = ['username']
|
||||
def __str__(self):
|
||||
return str(self.username)
|
||||
|
||||
def fio(self):
|
||||
print('--------------------------helloooooooooooooooooo--------------------')
|
||||
|
||||
return self.user.login
|
||||
# return ShortUserSerializer(DictEmployee.objects.get(login=self.username)).data
|
||||
# return DictEmployee.objects.using('user_directory').get(login=self.username).fio
|
||||
# return DictEmployee.objects.using('user_directory').get(login=self.username).fio
|
||||
|
||||
def names(self):
|
||||
return DictEmployee.objects.get(login=self.username)
|
||||
|
||||
names.short_description="ФИО"
|
||||
Reference in new issue
Block a user