Projet

Général

Profil

« Précédent | Suivant » 

Révision feffc421

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

dossiers: display anap quotations and filter by them

Closes #5011

Voir les différences:

calebasse/dossiers/views.py
840 840
            current_state = patient_record.get_current_state() or patient_record.get_state()
841 841
            state = current_state.status.name
842 842
            state_class = current_state.status.type.lower()
843
            deficiencies = [getattr(patient_record, field) \
844
                            for field in self.deficience_fields]
845
            anap = reduce(lambda f1, f2: f1 or f2, deficiencies)
843 846
            patient_records.append(
844 847
                    {
845 848
                        'object': patient_record,
846 849
                        'state': state,
847
                        'state_class': state_class
850
                        'state_class': state_class,
851
                        'anap': anap
848 852
                        }
849 853
                    )
850 854
        return patient_records
......
852 856
    def get_queryset(self):
853 857
        form = forms.QuotationsForm(data=self.request.GET or None)
854 858
        qs = super(PatientRecordsQuotationsView, self).get_queryset()
859
        self.deficience_fields = [field for field in self.model._meta.get_all_field_names() if field.startswith('deficiency_')]
860

  
855 861
        without_quotations = self.request.GET.get('without_quotations')
862
        without_anap_quotations = self.request.GET.get('without_anap_quotations')
856 863
        if without_quotations:
857
            qs = qs.filter(mises_1=None).filter(mises_2=None).filter(mises_3=None)
864
            qs = qs.filter(mises_1__isnull=True).filter(mises_2__isnull=True).filter(mises_3__isnull=True)
865

  
866
        if without_anap_quotations:
867
            for field in self.deficience_fields:
868
                anap_field = {field: 0}
869
                qs = qs.filter(**anap_field)
870

  
858 871
        states = self.request.GET.getlist('states')
859 872
        qs = qs.filter(last_state__status__id__in=states)
860 873

  

Formats disponibles : Unified diff