small code cleanups
This commit is contained in:
@@ -3,6 +3,7 @@ from django.contrib import admin
|
|||||||
from .models import *
|
from .models import *
|
||||||
# Register your models here.
|
# Register your models here.
|
||||||
|
|
||||||
|
|
||||||
@admin.register(Sujet)
|
@admin.register(Sujet)
|
||||||
class SujetAdmin(admin.ModelAdmin):
|
class SujetAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
@@ -16,12 +17,11 @@ class SujetAdmin(admin.ModelAdmin):
|
|||||||
class NoteAdmin(admin.ModelAdmin):
|
class NoteAdmin(admin.ModelAdmin):
|
||||||
|
|
||||||
fieldsets = [
|
fieldsets = [
|
||||||
('Contexte',
|
('Contexte', {
|
||||||
{'fields': ['created_by', ('created_date', 'created_time')]
|
'fields': ['created_by', ('created_date', 'created_time')]
|
||||||
}
|
}),
|
||||||
),
|
('Note', {
|
||||||
('Note',
|
'fields': ['sujet', 'text']}),
|
||||||
{'fields': ['sujet', 'text']})
|
|
||||||
]
|
]
|
||||||
|
|
||||||
list_display = ['created_date', 'sujet', 'child_class', 'text']
|
list_display = ['created_date', 'sujet', 'child_class', 'text']
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from django.utils.html import format_html
|
|
||||||
from django.core.exceptions import ValidationError
|
from django.core.exceptions import ValidationError
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
|
|
||||||
@@ -37,8 +36,6 @@ class Sujet(models.Model):
|
|||||||
blank=True, null=True
|
blank=True, null=True
|
||||||
)
|
)
|
||||||
|
|
||||||
# referent = models.ForeignKey("utilisateurs.Professionnel", related_name="suivis")
|
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
string = '%s ' % self.genre
|
string = '%s ' % self.genre
|
||||||
if self.nom: string += '%s ' % self.nom
|
if self.nom: string += '%s ' % self.nom
|
||||||
@@ -56,7 +53,7 @@ class Sujet(models.Model):
|
|||||||
if not self.id:
|
if not self.id:
|
||||||
from statistiques.models import FicheStatistique
|
from statistiques.models import FicheStatistique
|
||||||
super().save(*args, **kwargs)
|
super().save(*args, **kwargs)
|
||||||
fiche = FicheStatistique.objects.create(sujet=self)
|
FicheStatistique.objects.create(sujet=self)
|
||||||
else:
|
else:
|
||||||
return super().save(*args, **kwargs)
|
return super().save(*args, **kwargs)
|
||||||
|
|
||||||
@@ -65,8 +62,7 @@ class Sujet(models.Model):
|
|||||||
ordering = ('surnom', 'nom', 'prenom')
|
ordering = ('surnom', 'nom', 'prenom')
|
||||||
|
|
||||||
def get_absolute_url(self):
|
def get_absolute_url(self):
|
||||||
return reverse("notes:details-sujet", kwargs={"pk": self.pk })
|
return reverse("notes:details-sujet", kwargs={"pk": self.pk})
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Note(models.Model):
|
class Note(models.Model):
|
||||||
@@ -108,7 +104,7 @@ class Note(models.Model):
|
|||||||
return super().save(*args, **kwargs)
|
return super().save(*args, **kwargs)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return "<%s: %s>" % (self.child_class.__qualname__, self.sujet)
|
return "<%s: %s>" % (self.child_class, self.sujet)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def __str__(cls):
|
def __str__(cls):
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ PARCOURS_DE_VIE_CHOICES = (
|
|||||||
(PARCOURS_INSTITUTIONNEL, "Parcours institutionnel"),
|
(PARCOURS_INSTITUTIONNEL, "Parcours institutionnel"),
|
||||||
)
|
)
|
||||||
|
|
||||||
#Item: Type d'habitation
|
# Item: Type d'habitation
|
||||||
HABITATION_SANS = "Sans Abri"
|
HABITATION_SANS = "Sans Abri"
|
||||||
HABITATION_LOGEMENT = "Logement"
|
HABITATION_LOGEMENT = "Logement"
|
||||||
HABITATION_TIERS = "Hébergement"
|
HABITATION_TIERS = "Hébergement"
|
||||||
@@ -26,7 +26,7 @@ HABITATION_CHOICES = (
|
|||||||
(HABITATION_MAL_LOGEMENT, "Mal logé"),
|
(HABITATION_MAL_LOGEMENT, "Mal logé"),
|
||||||
)
|
)
|
||||||
|
|
||||||
#Item: Ressources
|
# Item: Ressources
|
||||||
RESSOURCES_RSA = "RSA"
|
RESSOURCES_RSA = "RSA"
|
||||||
RESSOURCES_AAH = "AAH"
|
RESSOURCES_AAH = "AAH"
|
||||||
RESSOURCES_POLE_EMPLOI = "Pôle Emploi"
|
RESSOURCES_POLE_EMPLOI = "Pôle Emploi"
|
||||||
@@ -42,7 +42,6 @@ RESSOURCES_CHOICES = (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class FicheStatistique(models.Model):
|
class FicheStatistique(models.Model):
|
||||||
|
|
||||||
sujet = models.OneToOneField('notes.Sujet',
|
sujet = models.OneToOneField('notes.Sujet',
|
||||||
@@ -50,7 +49,7 @@ class FicheStatistique(models.Model):
|
|||||||
primary_key=True,
|
primary_key=True,
|
||||||
related_name="statistiques")
|
related_name="statistiques")
|
||||||
|
|
||||||
# Logement
|
# Logement
|
||||||
habitation = models.CharField("Type d'habitat", max_length=64,
|
habitation = models.CharField("Type d'habitat", max_length=64,
|
||||||
choices=HABITATION_CHOICES,
|
choices=HABITATION_CHOICES,
|
||||||
default=NSP)
|
default=NSP)
|
||||||
@@ -81,8 +80,7 @@ class FicheStatistique(models.Model):
|
|||||||
'connu_siao', 'lien_familial', 'parcours_de_vie')
|
'connu_siao', 'lien_familial', 'parcours_de_vie')
|
||||||
completed = 0
|
completed = 0
|
||||||
for f in observed:
|
for f in observed:
|
||||||
if getattr(self, f) == None or getattr(self, f) == NSP:
|
if getattr(self, f) not in (None, NSP):
|
||||||
continue
|
|
||||||
else:
|
|
||||||
completed += 1
|
completed += 1
|
||||||
return int(completed / len(observed) * 100)
|
percentage = int(completed / len(observed) * 100)
|
||||||
|
return percentage
|
||||||
|
|||||||
@@ -232,7 +232,6 @@ class FrequentationStatsView(FilterMixin, generic.TemplateView):
|
|||||||
contenus = list(filter(filtre, observations))
|
contenus = list(filter(filtre, observations))
|
||||||
|
|
||||||
key = datetime.time(h, i * 15)
|
key = datetime.time(h, i * 15)
|
||||||
print("Resultat", h, ":", i*15, len(contenus))
|
|
||||||
data[key] = len(contenus)
|
data[key] = len(contenus)
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|||||||
Reference in New Issue
Block a user