Projet

Général

Profil

0001-backoffice-allow-submission-channel-column-in-listin.patch

Frédéric Péters, 11 mars 2016 11:51

Télécharger (3,53 ko)

Voir les différences:

Subject: [PATCH] backoffice: allow "submission channel" column in listings
 (#8434)

 tests/test_backoffice_pages.py | 22 ++++++++++++++++++++++
 wcs/backoffice/management.py   |  2 ++
 wcs/forms/backoffice.py        |  2 ++
 3 files changed, 26 insertions(+)
tests/test_backoffice_pages.py
43 43
    pub.cfg['identification'] = {'methods': ['password']}
44 44
    pub.cfg['language'] = {'language': 'en'}
45 45
    pub.write_cfg()
46
    fd = open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w')
47
    fd.close()
46 48

  
47 49
    return pub
48 50

  
......
256 258
    resp = app.get('/backoffice/management/form-title/')
257 259
    assert resp.body.count('</th>') == 6 # five columns
258 260
    resp.forms[0]['1'].checked = False
261
    assert not 'submission_channel' in resp.forms[0].fields
259 262
    resp = resp.forms[0].submit()
260 263
    assert resp.body.count('</th>') == 5 # four columns
261 264
    assert resp.body.count('data-link') == 17 # 17 rows
262 265
    assert resp.body.count('FOO BAR') == 0 # no field 1 column
263 266

  
267
def test_backoffice_channel_column(pub):
268
    if not pub.site_options.has_section('variables'):
269
        pub.site_options.add_section('variables')
270
    pub.site_options.set('variables', 'welco_url', 'xxx')
271
    fd = open(os.path.join(pub.app_dir, 'site-options.cfg'), 'w')
272
    pub.site_options.write(fd)
273
    fd.close()
274

  
275
    create_superuser(pub)
276
    create_environment(pub)
277
    app = login(get_app(pub))
278
    resp = app.get('/backoffice/management/form-title/')
279
    assert resp.body.count('</th>') == 6 # five columns
280
    resp.forms[0]['submission_channel'].checked = True
281
    resp = resp.forms[0].submit()
282
    assert resp.body.count('</th>') == 7 # six columns
283
    assert resp.body.count('data-link') == 17 # 17 rows
284
    assert resp.body.count('<td>Web</td>') == 17
285

  
264 286
def test_backoffice_filter(pub):
265 287
    create_superuser(pub)
266 288
    create_environment(pub)
wcs/backoffice/management.py
1002 1002
    def get_formdef_fields(self):
1003 1003
        fields = []
1004 1004
        fields.append(FakeField('id', 'id', _('Identifier')))
1005
        if get_publisher().get_site_option('welco_url', 'variables'):
1006
            fields.append(FakeField('submission_channel', 'submission_channel', _('Channel')))
1005 1007
        fields.append(FakeField('time', 'time', _('Time')))
1006 1008
        fields.append(FakeField('user-label', 'user-label', _('User Label')))
1007 1009
        fields.extend(self.formdef.fields)
wcs/forms/backoffice.py
266 266
                    else:
267 267
                        anonymised = _('No')
268 268
                    r += htmltext('<td class="cell-anonymised">%s</td>') % anonymised
269
                elif f.type == 'submission_channel':
270
                    r += htmltext('<td>%s</td>') % filled.get_submission_channel_label()
269 271
                else:
270 272
                    r += htmltext('<td>')
271 273
                    value = filled.data.get('%s_display' % f.id, filled.data.get(f.id))
272
-