Remaster (#38)
* setup new 'statistiques' module * added 'graphos' package and created first test graph * put graphos in requirements, deleted local folder * added "load_csv" management command ! * added update of premiere_rencontre field in 'load_csv' management command * added missing urls.py file * added 'merge' action and view * added 'info_completed' ratio * linked sujets:merge views inside suivi:details * added link to maraudes:details in notes table headers, if any * Major reorganisation, moved 'suivi' and 'sujets' to 'notes', cleanup in 'maraudes', dropping 'website' mixins (mostly useless) * small cleanup * worked on Maraude and Sujet lists * corrected missing line in notes.__init__ * restored 'details' view for maraudes and sujets insie 'notes' module * worked on 'notes': added navigation between maraude's compte-rendu, right content in details, header to list tables * changed queryset for CompteRenduDetailsView to all notes of same date, minor layout changes * added right content to 'details-sujet', created 'statistiques' view and update templates * restored 'statistiques' ajax view in 'details-sujet', fixed 'merge_two' util function * added auto-creation of FicheStatistique (plus some tests), pagination for notes in 'details-sujet' * added error-prone cases in paginator * fixed non-working modals, added titles * added UpdateStatistiques capacity in CompteRenduCreate view * fixed missing AjaxTemplateMixin for CreateSujetView, worked on compte-rendu creation scripts * fixed MaraudeManager.all_of() for common Maraudeurs, added color hints in planning * re-instated statistiques module link and first test page * added FinalizeView to send a mail before finalizing compte-rendu * Added PieChart view for FicheStatistique fields * small style updates, added 'age' and 'genre' fields from sujets in statistiques.PieChartView * worked on statistiques, fixed small issues in 'notes' list views * small theme change * removed some dead code * fixed notes.tests, fixed statistiques.info_completed display, added filter in SujetLisView * added some tests * added customised admin templates * added authenticate in CustomAuthenticatationBackend, more verbose login thanks to messages * added django-nose for test coverage * Corrected raising exception on first migration On first migration, qs.exists() would previously be called and raising an Exception, sot he migrations would fail. * Better try block * cleaned up custom settings.py, added some overrides of django base_settings * corrected bad dictionnary key
This commit is contained in:
88
statistiques/models.py
Normal file
88
statistiques/models.py
Normal file
@@ -0,0 +1,88 @@
|
||||
from django.db import models
|
||||
from django.shortcuts import reverse
|
||||
# Create your models here.
|
||||
|
||||
NSP = "Ne sait pas"
|
||||
|
||||
# Item: Parcours institutionnel
|
||||
PARCOURS_INSTITUTIONNEL = "Institutionnel"
|
||||
PARCOURS_FAMILIAL = "Familial"
|
||||
PARCOURS_DE_VIE_CHOICES = (
|
||||
(NSP, "Ne sait pas"),
|
||||
(PARCOURS_FAMILIAL, "Parcours familial"),
|
||||
(PARCOURS_INSTITUTIONNEL, "Parcours institutionnel"),
|
||||
)
|
||||
|
||||
#Item: Type d'habitation
|
||||
HABITATION_SANS = "Sans Abri"
|
||||
HABITATION_LOGEMENT = "Logement"
|
||||
HABITATION_TIERS = "Hébergement"
|
||||
HABITATION_MAL_LOGEMENT = "Mal logé"
|
||||
HABITATION_CHOICES = (
|
||||
(NSP, "Ne sait pas"),
|
||||
(HABITATION_SANS, "Sans abri"),
|
||||
(HABITATION_TIERS, "Hébergé"),
|
||||
(HABITATION_LOGEMENT, "Logé"),
|
||||
(HABITATION_MAL_LOGEMENT, "Mal logé"),
|
||||
)
|
||||
|
||||
#Item: Ressources
|
||||
RESSOURCES_RSA = "RSA"
|
||||
RESSOURCES_AAH = "AAH"
|
||||
RESSOURCES_POLE_EMPLOI = "Pôle Emploi"
|
||||
RESSOURCES_AUTRES = "Autres"
|
||||
RESSOURCES_SANS = "Pas de ressources"
|
||||
RESSOURCES_CHOICES = (
|
||||
(NSP, "Ne sait pas"),
|
||||
(RESSOURCES_AAH, "AAH"),
|
||||
(RESSOURCES_RSA, "RSA"),
|
||||
(RESSOURCES_SANS, "Aucune"),
|
||||
(RESSOURCES_POLE_EMPLOI, "Pôle emploi"),
|
||||
(RESSOURCES_AUTRES, "Autres ressources"),
|
||||
)
|
||||
|
||||
|
||||
|
||||
class FicheStatistique(models.Model):
|
||||
|
||||
sujet = models.OneToOneField('notes.Sujet',
|
||||
on_delete=models.CASCADE,
|
||||
primary_key=True,
|
||||
related_name="statistiques")
|
||||
|
||||
# Logement
|
||||
habitation = models.CharField("Type d'habitat", max_length=64,
|
||||
choices=HABITATION_CHOICES,
|
||||
default=NSP)
|
||||
ressources = models.CharField("Ressources", max_length=64,
|
||||
choices=RESSOURCES_CHOICES,
|
||||
default=NSP)
|
||||
connu_siao = models.NullBooleanField("Connu du SIAO ?")
|
||||
|
||||
# Problématiques
|
||||
prob_psychiatrie = models.NullBooleanField("Psychiatrie")
|
||||
prob_administratif = models.NullBooleanField("Administratif")
|
||||
prob_addiction = models.NullBooleanField("Addiction")
|
||||
prob_somatique = models.NullBooleanField("Somatique")
|
||||
|
||||
lien_familial = models.NullBooleanField("Lien Familial")
|
||||
parcours_de_vie = models.CharField("Parcours de vie",
|
||||
max_length=64,
|
||||
choices=PARCOURS_DE_VIE_CHOICES,
|
||||
default=NSP)
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse('notes:details-sujet', kwargs={'pk': self.sujet.pk})
|
||||
|
||||
@property
|
||||
def info_completed(self):
|
||||
observed = ('prob_psychiatrie', 'prob_addiction',
|
||||
'prob_administratif', 'prob_somatique', 'habitation', 'ressources',
|
||||
'connu_siao', 'lien_familial', 'parcours_de_vie')
|
||||
completed = 0
|
||||
for f in observed:
|
||||
if getattr(self, f) == None or getattr(self, f) == NSP:
|
||||
continue
|
||||
else:
|
||||
completed += 1
|
||||
return int(completed / len(observed) * 100)
|
||||
Reference in New Issue
Block a user