diff --git a/welco/qualif/migrations/0008_association_formdata_url_backoffice.py b/welco/qualif/migrations/0008_association_formdata_url_backoffice.py new file mode 100644 index 0000000..91ddc18 --- /dev/null +++ b/welco/qualif/migrations/0008_association_formdata_url_backoffice.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('qualif', '0007_remove_association_triaged'), + ] + + operations = [ + migrations.AddField( + model_name='association', + name='formdata_url_backoffice', + field=models.URLField(null=True), + ), + ] diff --git a/welco/qualif/models.py b/welco/qualif/models.py index 0ed0fe7..8c563f1 100644 --- a/welco/qualif/models.py +++ b/welco/qualif/models.py @@ -30,6 +30,7 @@ class Association(models.Model): comments = models.TextField(blank=True, verbose_name=_('Comments')) formdef_reference = models.CharField(max_length=250, null=True) formdata_id = models.CharField(max_length=250, null=True) + formdata_url_backoffice = models.URLField(null=True) def push(self, request): # push validated request to wcs @@ -40,7 +41,7 @@ class Association(models.Model): reverse('wcs-summary', kwargs={'source_type': self.source_type_id, 'source_pk': self.source_pk})) context.update(self.source.get_source_context(request)) - self.formdata_id = push_wcs_formdata(request, self.formdef_reference, context) + self.formdata_id, self.formdata_url_backoffice = push_wcs_formdata(request, self.formdef_reference, context) self.save() @property diff --git a/welco/utils.py b/welco/utils.py index 5b755a6..dc103e5 100644 --- a/welco/utils.py +++ b/welco/utils.py @@ -142,7 +142,9 @@ def push_wcs_formdata(request, formdef_reference, context=None): headers={'Content-type': 'application/json'}) if response.json().get('err') != 0: raise Exception('error %r' % response.content) - return response.json()['data']['id'] + data = response.json()['data'] + return data['id'], data.get('backoffice_url') + def get_wcs_data(endpoint, params=None): wcs_site = get_wcs_services().values()[0]