mirror of
https://gitlab.com/animath/si/plateforme.git
synced 2025-06-21 21:58:25 +02:00
Django admin management
This commit is contained in:
@ -0,0 +1 @@
|
||||
default_app_config = 'member.apps.MemberConfig'
|
||||
|
@ -1,3 +1,29 @@
|
||||
from django.contrib import admin
|
||||
from django.contrib.auth.admin import admin, UserAdmin
|
||||
from polymorphic.admin import PolymorphicParentModelAdmin, PolymorphicChildModelAdmin
|
||||
from member.models import TFJMUser, AbstractDocument, Document, Solution, Synthesis
|
||||
|
||||
# Register your models here.
|
||||
|
||||
@admin.register(TFJMUser)
|
||||
class TFJMUserAdmin(UserAdmin):
|
||||
list_display = ('email', 'first_name', 'last_name', 'role', )
|
||||
|
||||
|
||||
@admin.register(AbstractDocument)
|
||||
class AbstractDocumentAdmin(PolymorphicParentModelAdmin):
|
||||
child_models = (Document, Solution, Synthesis,)
|
||||
polymorphic_list = True
|
||||
|
||||
|
||||
@admin.register(Document)
|
||||
class DocumentAdmin(PolymorphicChildModelAdmin):
|
||||
pass
|
||||
|
||||
|
||||
@admin.register(Solution)
|
||||
class SolutionAdmin(PolymorphicChildModelAdmin):
|
||||
pass
|
||||
|
||||
|
||||
@admin.register(Synthesis)
|
||||
class SynthesisAdmin(PolymorphicChildModelAdmin):
|
||||
pass
|
||||
|
@ -1,5 +1,7 @@
|
||||
from django.apps import AppConfig
|
||||
from django.utils.translation import gettext_lazy as _
|
||||
|
||||
|
||||
class MemberConfig(AppConfig):
|
||||
name = 'apps.member'
|
||||
name = 'member'
|
||||
verbose_name = _('member')
|
||||
|
@ -139,6 +139,13 @@ class TFJMUser(AbstractUser):
|
||||
verbose_name = _("user")
|
||||
verbose_name_plural = _("users")
|
||||
|
||||
def save(self, *args, **kwargs):
|
||||
self.username = self.email
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
def __str__(self):
|
||||
return self.first_name + " " + self.last_name
|
||||
|
||||
|
||||
class AbstractDocument(PolymorphicModel):
|
||||
file = models.FileField(
|
||||
|
Reference in New Issue
Block a user