cleaned up code for notes module

This commit is contained in:
artus40
2018-03-02 14:50:41 +01:00
parent 85f388aac2
commit 7fdb7e9f31
4 changed files with 16 additions and 15 deletions

View File

@@ -81,7 +81,8 @@ class SujetCreateForm(forms.ModelForm):
class Meta: class Meta:
model = Sujet model = Sujet
fields = ['nom', 'surnom', 'prenom', 'genre', 'premiere_rencontre'] fields = ['nom', 'surnom', 'prenom', 'genre', 'premiere_rencontre']
widgets = {'premiere_rencontre': forms.SelectDateWidget( widgets = {
'premiere_rencontre': forms.SelectDateWidget(
empty_label=("Année", "Mois", "Jour"), empty_label=("Année", "Mois", "Jour"),
years=YEAR_CHOICE, years=YEAR_CHOICE,
), ),

View File

@@ -1,11 +1,10 @@
import logging import logging
from django.utils import timezone from django.utils import timezone
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.shortcuts import reverse from django.shortcuts import reverse
from django.db import models from django.db import models
from . import managers from . import managers
from statistiques.models import FicheStatistique
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
@@ -55,7 +54,6 @@ class Sujet(models.Model):
def save(self, *args, **kwargs): def save(self, *args, **kwargs):
self.clean() self.clean()
if not self.id: if not self.id:
from statistiques.models import FicheStatistique
super().save(*args, **kwargs) super().save(*args, **kwargs)
FicheStatistique.objects.create(sujet=self) FicheStatistique.objects.create(sujet=self)
else: else:

View File

@@ -92,7 +92,6 @@ class MaraudeListView(ListView):
] ]
def info_completed_filter(qs): def info_completed_filter(qs):
completed_ratio = 70 # % of total fields completed completed_ratio = 70 # % of total fields completed
@@ -103,6 +102,7 @@ def info_completed_filter(qs):
return qs.exclude(pk__in=excluded_set) return qs.exclude(pk__in=excluded_set)
def rencontre_dans_le_mois(qs): def rencontre_dans_le_mois(qs):
""" Renvoie les sujets du queryset pour lesquelles une observation a été enregistrée """ Renvoie les sujets du queryset pour lesquelles une observation a été enregistrée
au cours des 30 derniers jours """ au cours des 30 derniers jours """
@@ -116,6 +116,7 @@ def rencontre_dans_le_mois(qs):
included_set.add(sujet.pk) included_set.add(sujet.pk)
return qs.filter(pk__in=included_set) return qs.filter(pk__in=included_set)
def a_revoir_avant_bilan(qs): def a_revoir_avant_bilan(qs):
year_of_bilan = 2017 year_of_bilan = 2017
included_set = set() included_set = set()
@@ -125,6 +126,7 @@ def a_revoir_avant_bilan(qs):
included_set.add(sujet.pk) included_set.add(sujet.pk)
return qs.filter(pk__in=included_set) return qs.filter(pk__in=included_set)
class SujetListView(ListView): class SujetListView(ListView):
# ListView # ListView
model = Sujet model = Sujet
@@ -268,7 +270,7 @@ class SujetCreateView(AjaxTemplateMixin, generic.edit.CreateView):
context = super().get_context_data(**kwargs) context = super().get_context_data(**kwargs)
try: try:
context['next'] = self.request.GET['next'] context['next'] = self.request.GET['next']
except: except KeyError:
context['next'] = None context['next'] = None
return context return context