Project

General

Profile

0001-formdata-handle-form_tracking_code-of-unsaved-data-i.patch

Frédéric Péters, 11 Feb 2019 05:07 PM

Download (2.04 KB)

View differences:

Subject: [PATCH] formdata: handle form_tracking_code of unsaved data in lazy
 mode (#30536)

 tests/test_formdata.py | 18 ++++++++++++++++++
 wcs/variables.py       |  2 ++
 2 files changed, 20 insertions(+)
tests/test_formdata.py
715 715
    assert lazy_formdata.var.filefield.raw.base_filename == 'test.txt'
716 716
    assert lazy_formdata.var.filefield.raw.content_type == 'text/plain'
717 717

  
718
    formdata = FormDef.select()[0].data_class()
719
    lazy_formdata = LazyFormData(formdata)
720
    assert lazy_formdata.tracking_code is None
721
    formdata.data = {'future_tracking_code': 'CDCBGWQX'}
722
    assert lazy_formdata.tracking_code == 'CDCBGWQX'
723

  
724
    formdata = FormDef.select()[0].data_class().select()[0]
725
    lazy_formdata = LazyFormData(formdata)
726
    assert lazy_formdata.tracking_code is None
727

  
728
    tracking_code = pub.tracking_code_class()
729
    tracking_code.formdata = formdata
730
    tracking_code.store()
731
    formdata = FormDef.select()[0].data_class().get(formdata.id)
732
    lazy_formdata = LazyFormData(formdata)
733
    assert lazy_formdata.tracking_code == tracking_code.id
734

  
735

  
718 736
def test_lazy_variables(pub, variable_test_data):
719 737
    formdata = FormDef.select()[0].data_class().select()[0]
720 738
    for mode in (None, 'lazy'):
wcs/variables.py
144 144

  
145 145
    @property
146 146
    def tracking_code(self):
147
        if not self.formdata.status and self.formdata.data and 'future_tracking_code' in self.formdata.data:
148
            return self.formdata.data['future_tracking_code']
147 149
        return self.formdata.tracking_code
148 150

  
149 151
    @property
150
-