summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2020-07-01 14:42:24 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2020-07-01 14:42:24 (GMT)
commitc3e91b09b50cdb58f1d2ebd4619a3361b4086bf9 (patch)
treed7244c557f1c19c56cf4386d6f06026ffc89e529
parent3addd2746dfa24a9eb54c456747b862d2970645c (diff)
downloadpasserelle-grandlyon-cartads-cs-master.zip
passerelle-grandlyon-cartads-cs-master.tar.gz
passerelle-grandlyon-cartads-cs-master.tar.bz2
add option to configure URL transpositions (#44363)HEADv1.4master
-rw-r--r--grandlyon_cartads_cs/migrations/0004_glcartadscs_cerfa_pdf_url_substitutions.py20
-rw-r--r--grandlyon_cartads_cs/models.py8
2 files changed, 28 insertions, 0 deletions
diff --git a/grandlyon_cartads_cs/migrations/0004_glcartadscs_cerfa_pdf_url_substitutions.py b/grandlyon_cartads_cs/migrations/0004_glcartadscs_cerfa_pdf_url_substitutions.py
new file mode 100644
index 0000000..a19d63d
--- /dev/null
+++ b/grandlyon_cartads_cs/migrations/0004_glcartadscs_cerfa_pdf_url_substitutions.py
@@ -0,0 +1,20 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.11.17 on 2020-07-01 14:41
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('grandlyon_cartads_cs', '0003_auto_20190919_1211'),
+ ]
+
+ operations = [
+ migrations.AddField(
+ model_name='glcartadscs',
+ name='cerfa_pdf_url_substitutions',
+ field=models.TextField(blank=True, help_text='On each line, published URL prefix;actual URL prefix', verbose_name='URL substitutions for CERFA downloads'),
+ ),
+ ]
diff --git a/grandlyon_cartads_cs/models.py b/grandlyon_cartads_cs/models.py
index fad7834..9764008 100644
--- a/grandlyon_cartads_cs/models.py
+++ b/grandlyon_cartads_cs/models.py
@@ -53,6 +53,10 @@ class GLCartaDSCS(AbstractCartaDSCS):
max_length=256, blank=True)
verify_cert = models.BooleanField(default=True,
verbose_name=_('Check HTTPS Certificate validity'))
+ cerfa_pdf_url_substitutions = models.TextField(
+ _('URL substitutions for CERFA downloads'),
+ help_text=_('On each line, published URL prefix;actual URL prefix'),
+ blank=True)
class Meta:
verbose_name = 'Cart@DS CS (@ Grand Lyon)'
@@ -66,6 +70,10 @@ class GLCartaDSCS(AbstractCartaDSCS):
url = url.replace('http://ads-rec.grandlyon.fr/', 'https://api-rec.grandlyon.com/ads-rec/')
url = url.replace('https://ads-rec.grandlyon.fr/', 'https://api-rec.grandlyon.com/ads-rec/')
url = url.replace('https://ads.grandlyon.fr/', 'https://api.grandlyon.com/ads-pro/')
+ if self.cerfa_pdf_url_substitutions:
+ for line in self.cerfa_pdf_url_substitutions.splitlines():
+ old_prefix, new_prefix = line.strip().split(';')
+ url = url.replace(old_prefix, new_prefix)
return self.requests.get(url, auth=HttpBearerAuth(self.get_api_manager_token()))
def get_api_manager_token(self, renew=False):