customized admin styling, added get_absolute_url for Note model,
added inline in Sujet admin to show FicheStatistique
This commit is contained in:
@@ -1,17 +1,26 @@
|
||||
from django.contrib import admin
|
||||
|
||||
from .models import *
|
||||
from statistiques.models import FicheStatistique
|
||||
# Register your models here.
|
||||
|
||||
|
||||
class FicheStatistiqueInline(admin.StackedInline):
|
||||
model = FicheStatistique
|
||||
can_delete = False
|
||||
|
||||
|
||||
@admin.register(Sujet)
|
||||
class SujetAdmin(admin.ModelAdmin):
|
||||
|
||||
fieldsets = [
|
||||
('Identité', {'fields': [('nom', 'prenom'), 'genre']}),
|
||||
('Informations', {'fields': ['age', ]}),
|
||||
('Identité', {'fields': [('nom', 'surnom', 'prenom', ), ('genre', 'age')]}),
|
||||
]
|
||||
|
||||
inlines = [
|
||||
FicheStatistiqueInline,
|
||||
]
|
||||
|
||||
|
||||
@admin.register(Note)
|
||||
class NoteAdmin(admin.ModelAdmin):
|
||||
|
||||
@@ -2,7 +2,7 @@ import logging
|
||||
|
||||
from django.utils import timezone
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.urls import reverse
|
||||
from django.shortcuts import reverse
|
||||
|
||||
from django.db import models
|
||||
from . import managers
|
||||
@@ -176,3 +176,6 @@ class Note(models.Model):
|
||||
return getter
|
||||
bg_colors = property(cached_attr('bg_colors'), doc="background color of header")
|
||||
labels = property(cached_attr('labels'), doc="list of string to display as labels")
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("notes:details-sujet", kwargs={"pk": self.sujet.pk})
|
||||
Reference in New Issue
Block a user