Project

General

Profile

0001-cartads_cs-add-overridable-method-to-download-CERFA-.patch

Frédéric Péters, 11 Sep 2019 08:11 AM

Download (1.83 KB)

View differences:

Subject: [PATCH] cartads_cs: add overridable method to download CERFA
 documents (#36015)

 passerelle/apps/cartads_cs/models.py | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
passerelle/apps/cartads_cs/models.py
161 161
        'description': _('Token for upload file'),
162 162
    }
163 163

  
164
    def fix_pdf_url(self, url):
164
    def get_cerfa_pdf(self, url):
165 165
        # method subclasses can override if the URL returned for PDF documents
166 166
        # by Cart@DS do not match reverse proxies, API managers, and stuff.
167
        return url
167
        return self.requests.get(url)
168 168

  
169 169
    def update_data_cache(self):
170 170
        client = self.soap_client()
......
229 229
                data_cache.data_values = {'data': [
230 230
                    {'id': x['Identifiant'],
231 231
                     'text': format_cerfa_label(x),
232
                     'url': self.fix_pdf_url(x['UrlTelechargement']),
232
                     'url': x['UrlTelechargement'],
233 233
                    } for x in resp or []]}
234 234

  
235 235
                for value in data_cache.data_values['data']:
236 236
                    filepath = os.path.join(default_storage.path(self.pdf_path(value)))
237
                    resp = self.requests.get(value['url'])
237
                    resp = self.get_cerfa_pdf(value['url'])
238 238
                    if resp.ok:
239 239
                        with open(filepath, 'wb') as fd:
240 240
                            fd.write(resp.content)
241
-