Projet

Général

Profil

« Précédent | Suivant » 

Révision 3fa5579e

Ajouté par Serghei Mihai il y a plus de 9 ans

dossiers: quotations view improvements

Voir les différences:

calebasse/dossiers/models.py
1028 1028
    patient.policyholder = patient.patientcontact
1029 1029
    patient.save()
1030 1030
    return patient
1031

  
1032
PatientRecord.DEFICIENCY_FIELDS = [field for field in PatientRecord._meta.get_all_field_names() if field.startswith('deficiency_')]
1033
PatientRecord.MISES_FIELDS = [field for field in PatientRecord._meta.get_all_field_names() if field.startswith('mises_')]
1034

  
calebasse/dossiers/views.py
841 841
            state = current_state.status.name
842 842
            state_class = current_state.status.type.lower()
843 843
            deficiencies = [getattr(patient_record, field) \
844
                            for field in self.deficience_fields]
845
            anap = reduce(lambda f1, f2: f1 or f2, deficiencies)
846
            mises = reduce(lambda m1, m2: m1+m2, [list(getattr(patient_record, field).all()) for field in self.mises_fields])
844
                            for field in self.model.DEFICIENCY_FIELDS]
845
            anap = any(deficiencies)
846
            mises = reduce(lambda m1, m2: m1+m2, [list(getattr(patient_record, field).all()) for field in self.model.MISES_FIELDS])
847 847
            next_rdv = get_next_rdv(patient_record)
848 848
            last_rdv = get_last_rdv(patient_record)
849 849

  
......
871 871
    def get_queryset(self):
872 872
        form = forms.QuotationsForm(data=self.request.GET or None)
873 873
        qs = super(PatientRecordsQuotationsView, self).get_queryset()
874
        all_field_names = self.model._meta.get_all_field_names()
875
        self.deficience_fields = [field for field in all_field_names if field.startswith('deficiency_')]
876
        self.mises_fields = [field for field in all_field_names if field.startswith('mises_')]
877

  
878 874
        without_quotations = self.request.GET.get('without_quotations')
879 875
        without_anap_quotations = self.request.GET.get('without_anap_quotations')
880 876
        if without_quotations:
881
            for field in self.mises_fields:
877
            for field in self.model.MISES_FIELDS:
882 878
                mise_field = {'%s__isnull' % field: True}
883 879
                qs = qs.filter(**mise_field)
884 880

  
885 881
        if without_anap_quotations:
886
            for field in self.deficience_fields:
882
            for field in self.model.DEFICIENCY_FIELDS:
887 883
                anap_field = {field: 0}
888 884
                qs = qs.filter(**anap_field)
889 885

  

Formats disponibles : Unified diff