Django admin management

This commit is contained in:
Yohann D'ANELLO 2020-04-29 04:51:25 +02:00
parent 706de5bd41
commit bc869241b6
9 changed files with 104 additions and 35 deletions

View File

@ -0,0 +1 @@
default_app_config = 'member.apps.MemberConfig'

View File

@ -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

View File

@ -1,5 +1,7 @@
from django.apps import AppConfig from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class MemberConfig(AppConfig): class MemberConfig(AppConfig):
name = 'apps.member' name = 'member'
verbose_name = _('member')

View File

@ -139,6 +139,13 @@ class TFJMUser(AbstractUser):
verbose_name = _("user") verbose_name = _("user")
verbose_name_plural = _("users") 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): class AbstractDocument(PolymorphicModel):
file = models.FileField( file = models.FileField(

View File

@ -0,0 +1 @@
default_app_config = 'tournament.apps.TournamentConfig'

View File

@ -1,3 +1,18 @@
from django.contrib import admin from django.contrib.auth.admin import admin
# Register your models here. from tournament.models import Team, Tournament, Payment
@admin.register(Team)
class TeamAdmin(admin.ModelAdmin):
pass
@admin.register(Tournament)
class TournamentAdmin(admin.ModelAdmin):
pass
@admin.register(Payment)
class PaymentAdmin(admin.ModelAdmin):
pass

View File

@ -1,5 +1,7 @@
from django.apps import AppConfig from django.apps import AppConfig
from django.utils.translation import gettext_lazy as _
class TournamentConfig(AppConfig): class TournamentConfig(AppConfig):
name = 'apps.tournament' name = 'tournament'
verbose_name = _('tournament')

View File

@ -169,3 +169,7 @@ class Payment(models.Model):
], ],
verbose_name=_("validation status"), verbose_name=_("validation status"),
) )
class Meta:
verbose_name = _("payment")
verbose_name_plural = _("payments")

View File

@ -1,15 +1,15 @@
# SOME DESCRIPTIVE TITLE. # SOME DESCRIPTIVE TITLE.
# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
# This file is distributed under the same license as the PACKAGE package. # This file is distributed under the same license as the PACKAGE package.
# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. # FIRST AUTHOR yohann.danello@animath.fr, 2020.
# #
#, fuzzy #, fuzzy
msgid "" msgid ""
msgstr "" msgstr ""
"Project-Id-Version: TFJM2\n" "Project-Id-Version: TFJM2\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-04-29 02:09+0000\n" "POT-Creation-Date: 2020-04-29 02:45+0000\n"
"PO-Revision-Date: 2020-04-29 02:09+0000\n" "PO-Revision-Date: 2020-04-29 02:30+0000\n"
"Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n" "Last-Translator: Yohann D'ANELLO <yohann.danello@animath.fr>\n"
"Language-Team: fr <LL@li.org>\n" "Language-Team: fr <LL@li.org>\n"
"Language: fr\n" "Language: fr\n"
@ -18,11 +18,15 @@ msgstr ""
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n > 1);\n" "Plural-Forms: nplurals=2; plural=(n > 1);\n"
#: apps/member/apps.py:7
msgid "member"
msgstr "membre"
#: apps/member/models.py:15 #: apps/member/models.py:15
msgid "email" msgid "email"
msgstr "Adresse électronique" msgstr "Adresse électronique"
#: apps/member/models.py:23 apps/member/models.py:154 #: apps/member/models.py:23 apps/member/models.py:161
#: apps/tournament/models.py:129 apps/tournament/models.py:146 #: apps/tournament/models.py:129 apps/tournament/models.py:146
msgid "team" msgid "team"
msgstr "équipe" msgstr "équipe"
@ -43,8 +47,7 @@ msgstr "Femme"
msgid "Non binary" msgid "Non binary"
msgstr "Non binaire" msgstr "Non binaire"
#: apps/member/models.py:41 #: apps/member/models.py:41 apps/member/models.py:48
#: apps/member/models.py:48
msgid "address" msgid "address"
msgstr "adresse" msgstr "adresse"
@ -125,84 +128,84 @@ msgstr "utilisateur"
msgid "users" msgid "users"
msgstr "utilisateurs" msgstr "utilisateurs"
#: apps/member/models.py:147 #: apps/member/models.py:154
msgid "file" msgid "file"
msgstr "fichier" msgstr "fichier"
#: apps/member/models.py:161 apps/tournament/models.py:69 #: apps/member/models.py:168 apps/tournament/apps.py:7
#: apps/tournament/models.py:87 #: apps/tournament/models.py:69 apps/tournament/models.py:87
msgid "tournament" msgid "tournament"
msgstr "tournoi" msgstr "tournoi"
#: apps/member/models.py:167 #: apps/member/models.py:174
msgid "Parental consent" msgid "Parental consent"
msgstr "Autorisation parentale" msgstr "Autorisation parentale"
#: apps/member/models.py:168 #: apps/member/models.py:175
msgid "Photo consent" msgid "Photo consent"
msgstr "Autorisation de droit à l'image" msgstr "Autorisation de droit à l'image"
#: apps/member/models.py:169 #: apps/member/models.py:176
msgid "Sanitary plug" msgid "Sanitary plug"
msgstr "Fiche sanitaire" msgstr "Fiche sanitaire"
#: apps/member/models.py:170 #: apps/member/models.py:177
msgid "Motivation letter" msgid "Motivation letter"
msgstr "Lettre de motivation" msgstr "Lettre de motivation"
#: apps/member/models.py:171 apps/tournament/models.py:157 #: apps/member/models.py:178 apps/tournament/models.py:157
msgid "Scholarship" msgid "Scholarship"
msgstr "Bourse" msgstr "Bourse"
#: apps/member/models.py:172 #: apps/member/models.py:179
msgid "Solution" msgid "Solution"
msgstr "Solution" msgstr "Solution"
#: apps/member/models.py:173 #: apps/member/models.py:180
msgid "Synthesis" msgid "Synthesis"
msgstr "Synthèse" msgstr "Synthèse"
#: apps/member/models.py:175 #: apps/member/models.py:182
msgid "type" msgid "type"
msgstr "type" msgstr "type"
#: apps/member/models.py:180 #: apps/member/models.py:187
msgid "uploaded at" msgid "uploaded at"
msgstr "téléversé le" msgstr "téléversé le"
#: apps/member/models.py:184 #: apps/member/models.py:191
msgid "abstract document" msgid "abstract document"
msgstr "document abstrait" msgstr "document générique"
#: apps/member/models.py:185 #: apps/member/models.py:192
msgid "abstract documents" msgid "abstract documents"
msgstr "documents abstraits" msgstr "documents génériques"
#: apps/member/models.py:190 #: apps/member/models.py:197
msgid "document" msgid "document"
msgstr "document" msgstr "document"
#: apps/member/models.py:191 #: apps/member/models.py:198
msgid "documents" msgid "documents"
msgstr "documents" msgstr "documents"
#: apps/member/models.py:196 apps/member/models.py:210 #: apps/member/models.py:203 apps/member/models.py:217
msgid "problem" msgid "problem"
msgstr "problème" msgstr "problème"
#: apps/member/models.py:204 #: apps/member/models.py:211
msgid "solution" msgid "solution"
msgstr "solution" msgstr "solution"
#: apps/member/models.py:205 #: apps/member/models.py:212
msgid "solutions" msgid "solutions"
msgstr "solutions" msgstr "solutions"
#: apps/member/models.py:218 #: apps/member/models.py:225
msgid "synthesis" msgid "synthesis"
msgstr "synthèse" msgstr "synthèse"
#: apps/member/models.py:219 #: apps/member/models.py:226
msgid "syntheses" msgid "syntheses"
msgstr "synthèses" msgstr "synthèses"
@ -310,6 +313,14 @@ msgstr "Espèces"
msgid "payment method" msgid "payment method"
msgstr "moyen de paiement" msgstr "moyen de paiement"
#: apps/tournament/models.py:174
msgid "payment"
msgstr "paiement"
#: apps/tournament/models.py:175
msgid "payments"
msgstr "paiements"
#: tfjm/settings.py:123 #: tfjm/settings.py:123
msgid "English" msgid "English"
msgstr "Anglais" msgstr "Anglais"