Project

General

Profile

« Previous | Next » 

Revision 748e8d64

Added by Serghei Mihai almost 10 years ago

dossiers: quotations table refactored

Closes #5013

View differences:

calebasse/dossiers/views.py
843 843
            deficiencies = [getattr(patient_record, field) \
844 844
                            for field in self.deficience_fields]
845 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])
847
            next_rdv = get_next_rdv(patient_record)
848
            last_rdv = get_last_rdv(patient_record)
849

  
850
            if next_rdv:
851
                next_rdv_datetime = next_rdv.start_datetime
852
            else:
853
                next_rdv_datetime = None
854
            if last_rdv:
855
                last_rdv_datetime = last_rdv['start_datetime']
856
            else:
857
                last_rdv_datetime = None
846 858
            patient_records.append(
847 859
                    {
848 860
                        'object': patient_record,
849 861
                        'state': state,
850 862
                        'state_class': state_class,
851
                        'anap': anap
863
                        'anap': anap,
864
                        'mises': mises,
865
                        'next_rdv_date': next_rdv_datetime,
866
                        'last_rdv_date': last_rdv_datetime
852 867
                        }
853 868
                    )
854 869
        return patient_records
......
856 871
    def get_queryset(self):
857 872
        form = forms.QuotationsForm(data=self.request.GET or None)
858 873
        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_')]
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_')]
860 877

  
861 878
        without_quotations = self.request.GET.get('without_quotations')
862 879
        without_anap_quotations = self.request.GET.get('without_anap_quotations')
863 880
        if without_quotations:
864
            qs = qs.filter(mises_1__isnull=True).filter(mises_2__isnull=True).filter(mises_3__isnull=True)
881
            for field in self.mises_fields:
882
                mise_field = {'%s__isnull' % field: True}
883
                qs = qs.filter(**mise_field)
865 884

  
866 885
        if without_anap_quotations:
867 886
            for field in self.deficience_fields:

Also available in: Unified diff