backoffice: don't show deprecated variables in inspect (#18789)
This commit is contained in:
parent
64515ddef3
commit
ea628f2684
|
@ -3282,8 +3282,17 @@ class IHateUnicode(object):
|
|||
def __repr__(self):
|
||||
return 'ok'
|
||||
|
||||
@pytest.fixture
|
||||
def local_user():
|
||||
get_publisher().user_class.wipe()
|
||||
user = get_publisher().user_class()
|
||||
user.name = 'Jean Darmette'
|
||||
user.email = 'jean.darmette@triffouilis.fr'
|
||||
user.name_identifiers = ['0123456789']
|
||||
user.store()
|
||||
return user
|
||||
|
||||
def test_inspect_page(pub):
|
||||
def test_inspect_page(pub, local_user):
|
||||
create_user(pub)
|
||||
create_environment(pub)
|
||||
|
||||
|
@ -3297,8 +3306,18 @@ def test_inspect_page(pub):
|
|||
'non_unicode_convertible': IHateUnicode(),
|
||||
'very_long_string': '0' * 100000,
|
||||
}
|
||||
formdata.user_id = local_user.id
|
||||
formdata.store()
|
||||
|
||||
from wcs.admin.settings import UserFieldsFormDef
|
||||
user_formdef = UserFieldsFormDef(pub)
|
||||
user_formdef.fields.append(fields.StringField(id='_first_name', label='name', type='string'))
|
||||
user_formdef.fields.append(fields.StringField(id='3', label='test', type='string'))
|
||||
user_formdef.store()
|
||||
local_user.form_data = {'_first_name': 'toto', '3': 'nono'}
|
||||
local_user.set_attributes_from_formdata(local_user.form_data)
|
||||
local_user.store()
|
||||
|
||||
resp = login(get_app(pub)).get('%sinspect' % formdata.get_url(backoffice=True), status=403)
|
||||
|
||||
create_user(pub, is_admin=True)
|
||||
|
@ -3316,6 +3335,13 @@ def test_inspect_page(pub):
|
|||
.parents('li').children('div.value span')
|
||||
.text() == '\'\\xed\\xa0\\x00\'')
|
||||
|
||||
# don't show «unusable» variables
|
||||
assert 'form_f1' not in resp.body
|
||||
assert 'form_field_' not in resp.body
|
||||
assert 'form_user_field_' not in resp.body
|
||||
assert 'form_user_f3' not in resp.body
|
||||
assert 'form_user_f_' not in resp.body
|
||||
|
||||
def test_workflow_jump_previous(pub):
|
||||
user = create_user(pub)
|
||||
create_environment(pub)
|
||||
|
|
|
@ -18,6 +18,7 @@ import csv
|
|||
import cStringIO
|
||||
import datetime
|
||||
import json
|
||||
import re
|
||||
import time
|
||||
import urllib
|
||||
import vobject
|
||||
|
@ -2137,9 +2138,11 @@ class FormBackOfficeStatusPage(FormStatusPage):
|
|||
v = repr(v)
|
||||
return v
|
||||
|
||||
backward_compatibility_varnames = ['attachments']
|
||||
backward_compatibility_varnames = re.compile('^(attachments|form_field_.*|'
|
||||
'form_f[0-9]+|form_fbo[0-9]+|form_user_f[0-9]+|'
|
||||
'form_user_field_.*|form_user_f_.*)$')
|
||||
for k, v in sorted(substvars.items()):
|
||||
if k in backward_compatibility_varnames:
|
||||
if backward_compatibility_varnames.search(k):
|
||||
continue
|
||||
|
||||
k = safe(k)
|
||||
|
|
Loading…
Reference in New Issue