Projet

Général

Profil

0002-qualif-store-keep-formdata-backoffice-URL-22550.patch

Benjamin Dauvergne, 29 juin 2018 11:57

Télécharger (2,89 ko)

Voir les différences:

Subject: [PATCH 2/4] qualif: store keep formdata backoffice URL (#22550)

 ...008_association_formdata_url_backoffice.py | 19 +++++++++++++++++++
 welco/qualif/models.py                        |  3 ++-
 welco/utils.py                                |  4 +++-
 3 files changed, 24 insertions(+), 2 deletions(-)
 create mode 100644 welco/qualif/migrations/0008_association_formdata_url_backoffice.py
welco/qualif/migrations/0008_association_formdata_url_backoffice.py
1
# -*- coding: utf-8 -*-
2
from __future__ import unicode_literals
3

  
4
from django.db import migrations, models
5

  
6

  
7
class Migration(migrations.Migration):
8

  
9
    dependencies = [
10
        ('qualif', '0007_remove_association_triaged'),
11
    ]
12

  
13
    operations = [
14
        migrations.AddField(
15
            model_name='association',
16
            name='formdata_url_backoffice',
17
            field=models.URLField(null=True),
18
        ),
19
    ]
welco/qualif/models.py
30 30
    comments = models.TextField(blank=True, verbose_name=_('Comments'))
31 31
    formdef_reference = models.CharField(max_length=250, null=True)
32 32
    formdata_id = models.CharField(max_length=250, null=True)
33
    formdata_url_backoffice = models.URLField(null=True)
33 34

  
34 35
    def push(self, request):
35 36
        # push validated request to wcs
......
40 41
                reverse('wcs-summary', kwargs={'source_type': self.source_type_id,
41 42
                                               'source_pk': self.source_pk}))
42 43
        context.update(self.source.get_source_context(request))
43
        self.formdata_id = push_wcs_formdata(request, self.formdef_reference, context)
44
        self.formdata_id, self.formdata_url_backoffice = push_wcs_formdata(request, self.formdef_reference, context)
44 45
        self.save()
45 46

  
46 47
    @property
welco/utils.py
139 139
            headers={'Content-type': 'application/json'})
140 140
    if response.json().get('err') != 0:
141 141
        raise Exception('error %r' % response.content)
142
    return response.json()['data']['id']
142
    data = response.json()['data']
143
    return data['id'], data.get('url_backoffice')
144

  
143 145

  
144 146
def get_wcs_data(endpoint, params=None):
145 147
    wcs_site = get_wcs_services().values()[0]
146
-