cleaned up code for notes module
This commit is contained in:
@@ -81,7 +81,8 @@ class SujetCreateForm(forms.ModelForm):
|
||||
class Meta:
|
||||
model = Sujet
|
||||
fields = ['nom', 'surnom', 'prenom', 'genre', 'premiere_rencontre']
|
||||
widgets = {'premiere_rencontre': forms.SelectDateWidget(
|
||||
widgets = {
|
||||
'premiere_rencontre': forms.SelectDateWidget(
|
||||
empty_label=("Année", "Mois", "Jour"),
|
||||
years=YEAR_CHOICE,
|
||||
),
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
import logging
|
||||
|
||||
from django.utils import timezone
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.shortcuts import reverse
|
||||
|
||||
from django.db import models
|
||||
from . import managers
|
||||
from statistiques.models import FicheStatistique
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -55,7 +54,6 @@ class Sujet(models.Model):
|
||||
def save(self, *args, **kwargs):
|
||||
self.clean()
|
||||
if not self.id:
|
||||
from statistiques.models import FicheStatistique
|
||||
super().save(*args, **kwargs)
|
||||
FicheStatistique.objects.create(sujet=self)
|
||||
else:
|
||||
|
||||
@@ -92,7 +92,6 @@ class MaraudeListView(ListView):
|
||||
]
|
||||
|
||||
|
||||
|
||||
def info_completed_filter(qs):
|
||||
completed_ratio = 70 # % of total fields completed
|
||||
|
||||
@@ -103,6 +102,7 @@ def info_completed_filter(qs):
|
||||
|
||||
return qs.exclude(pk__in=excluded_set)
|
||||
|
||||
|
||||
def rencontre_dans_le_mois(qs):
|
||||
""" Renvoie les sujets du queryset pour lesquelles une observation a été enregistrée
|
||||
au cours des 30 derniers jours """
|
||||
@@ -116,6 +116,7 @@ def rencontre_dans_le_mois(qs):
|
||||
included_set.add(sujet.pk)
|
||||
return qs.filter(pk__in=included_set)
|
||||
|
||||
|
||||
def a_revoir_avant_bilan(qs):
|
||||
year_of_bilan = 2017
|
||||
included_set = set()
|
||||
@@ -125,6 +126,7 @@ def a_revoir_avant_bilan(qs):
|
||||
included_set.add(sujet.pk)
|
||||
return qs.filter(pk__in=included_set)
|
||||
|
||||
|
||||
class SujetListView(ListView):
|
||||
# ListView
|
||||
model = Sujet
|
||||
@@ -268,7 +270,7 @@ class SujetCreateView(AjaxTemplateMixin, generic.edit.CreateView):
|
||||
context = super().get_context_data(**kwargs)
|
||||
try:
|
||||
context['next'] = self.request.GET['next']
|
||||
except:
|
||||
except KeyError:
|
||||
context['next'] = None
|
||||
return context
|
||||
|
||||
|
||||
Reference in New Issue
Block a user