diff --git a/notes/admin.py b/notes/admin.py index 609932c..34853fa 100644 --- a/notes/admin.py +++ b/notes/admin.py @@ -3,6 +3,7 @@ from django.contrib import admin from .models import * # Register your models here. + @admin.register(Sujet) class SujetAdmin(admin.ModelAdmin): @@ -16,12 +17,11 @@ class SujetAdmin(admin.ModelAdmin): class NoteAdmin(admin.ModelAdmin): fieldsets = [ - ('Contexte', - {'fields': ['created_by', ('created_date', 'created_time')] - } - ), - ('Note', - {'fields': ['sujet', 'text']}) + ('Contexte', { + 'fields': ['created_by', ('created_date', 'created_time')] + }), + ('Note', { + 'fields': ['sujet', 'text']}), ] list_display = ['created_date', 'sujet', 'child_class', 'text'] diff --git a/notes/models.py b/notes/models.py index 8fcbc55..d09e774 100644 --- a/notes/models.py +++ b/notes/models.py @@ -1,7 +1,6 @@ import logging from django.utils import timezone -from django.utils.html import format_html from django.core.exceptions import ValidationError from django.urls import reverse @@ -37,8 +36,6 @@ class Sujet(models.Model): blank=True, null=True ) - # referent = models.ForeignKey("utilisateurs.Professionnel", related_name="suivis") - def __str__(self): string = '%s ' % self.genre if self.nom: string += '%s ' % self.nom @@ -56,7 +53,7 @@ class Sujet(models.Model): if not self.id: from statistiques.models import FicheStatistique super().save(*args, **kwargs) - fiche = FicheStatistique.objects.create(sujet=self) + FicheStatistique.objects.create(sujet=self) else: return super().save(*args, **kwargs) @@ -65,8 +62,7 @@ class Sujet(models.Model): ordering = ('surnom', 'nom', 'prenom') 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): @@ -108,7 +104,7 @@ class Note(models.Model): return super().save(*args, **kwargs) def __str__(self): - return "<%s: %s>" % (self.child_class.__qualname__, self.sujet) + return "<%s: %s>" % (self.child_class, self.sujet) @classmethod def __str__(cls): @@ -143,7 +139,7 @@ class Note(models.Model): """ self._child_instance = self self._child_class = self.__class__ - if self._meta.get_parent_list(): # If self is actually child instance + if self._meta.get_parent_list(): # If self is actually child instance return for f in self._meta.get_fields(): if f.is_relation and f.one_to_one: diff --git a/statistiques/models.py b/statistiques/models.py index 1866658..2729766 100644 --- a/statistiques/models.py +++ b/statistiques/models.py @@ -13,7 +13,7 @@ PARCOURS_DE_VIE_CHOICES = ( (PARCOURS_INSTITUTIONNEL, "Parcours institutionnel"), ) -#Item: Type d'habitation +# Item: Type d'habitation HABITATION_SANS = "Sans Abri" HABITATION_LOGEMENT = "Logement" HABITATION_TIERS = "Hébergement" @@ -26,7 +26,7 @@ HABITATION_CHOICES = ( (HABITATION_MAL_LOGEMENT, "Mal logé"), ) -#Item: Ressources +# Item: Ressources RESSOURCES_RSA = "RSA" RESSOURCES_AAH = "AAH" RESSOURCES_POLE_EMPLOI = "Pôle Emploi" @@ -42,15 +42,14 @@ RESSOURCES_CHOICES = ( ) - class FicheStatistique(models.Model): sujet = models.OneToOneField('notes.Sujet', - on_delete=models.CASCADE, - primary_key=True, - related_name="statistiques") + on_delete=models.CASCADE, + primary_key=True, + related_name="statistiques") -# Logement + # Logement habitation = models.CharField("Type d'habitat", max_length=64, choices=HABITATION_CHOICES, default=NSP) @@ -81,8 +80,7 @@ class FicheStatistique(models.Model): '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: + if getattr(self, f) not in (None, NSP): completed += 1 - return int(completed / len(observed) * 100) + percentage = int(completed / len(observed) * 100) + return percentage diff --git a/statistiques/views.py b/statistiques/views.py index 0ec6ead..27404ac 100644 --- a/statistiques/views.py +++ b/statistiques/views.py @@ -232,7 +232,6 @@ class FrequentationStatsView(FilterMixin, generic.TemplateView): contenus = list(filter(filtre, observations)) key = datetime.time(h, i * 15) - print("Resultat", h, ":", i*15, len(contenus)) data[key] = len(contenus) return data