ctl: update check_hobos to use force_str to handle strings (#36515)
This commit is contained in:
parent
4aa96b93c5
commit
52df31918f
|
@ -16,6 +16,7 @@ from utilities import create_temporary_pub, clean_temporary_pub
|
|||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
from quixote import cleanup
|
||||
|
||||
from wcs.qommon import force_str
|
||||
from wcs.ctl.check_hobos import CmdCheckHobos
|
||||
from wcs.publisher import WcsPublisher
|
||||
from wcs import fields
|
||||
|
@ -284,7 +285,7 @@ def test_update_profile():
|
|||
hobo_cmd.update_profile(profile, pub)
|
||||
from wcs.admin.settings import UserFieldsFormDef
|
||||
formdef = UserFieldsFormDef(pub)
|
||||
field_labels = [x.get('label').encode('utf-8') for x in profile.get('fields') if not x.get('disabled')]
|
||||
field_labels = [force_str(x.get('label')) for x in profile.get('fields') if not x.get('disabled')]
|
||||
field_ids = [x.get('name') for x in profile.get('fields') if not x.get('disabled')]
|
||||
assert [x.label for x in formdef.fields] == field_labels
|
||||
for field_id in [pub.cfg['users']['field_email']] + pub.cfg['users']['field_name']:
|
||||
|
|
|
@ -29,6 +29,7 @@ from django.utils.six.moves import configparser as ConfigParser
|
|||
from django.utils.six.moves.urllib import parse as urlparse
|
||||
|
||||
from quixote import cleanup
|
||||
from wcs.qommon import force_str
|
||||
from ..qommon import misc
|
||||
from ..qommon.ctl import Command, make_option
|
||||
from ..qommon.storage import atomic_write
|
||||
|
@ -154,8 +155,8 @@ class CmdCheckHobos(Command):
|
|||
def update_configuration(self, service, pub):
|
||||
if not pub.cfg.get('misc'):
|
||||
pub.cfg['misc'] = {'charset': 'utf-8'}
|
||||
pub.cfg['misc']['sitename'] = service.get('title').encode('utf-8')
|
||||
pub.cfg['misc']['frontoffice-url'] = service.get('base_url').encode('utf-8')
|
||||
pub.cfg['misc']['sitename'] = force_str(service.get('title'))
|
||||
pub.cfg['misc']['frontoffice-url'] = force_str(service.get('base_url'))
|
||||
if not pub.cfg.get('language'):
|
||||
pub.cfg['language'] = {'language': 'fr'}
|
||||
|
||||
|
@ -209,9 +210,9 @@ class CmdCheckHobos(Command):
|
|||
component_dir)
|
||||
|
||||
if variables.get('default_from_email'):
|
||||
pub.cfg['emails']['from'] = variables.get('default_from_email').encode('utf-8')
|
||||
pub.cfg['emails']['from'] = force_str(variables.get('default_from_email'))
|
||||
if variables.get('email_signature') is not None:
|
||||
pub.cfg['emails']['footer'] = variables.get('email_signature').encode('utf-8')
|
||||
pub.cfg['emails']['footer'] = force_str(variables.get('email_signature'))
|
||||
|
||||
pub.write_cfg()
|
||||
|
||||
|
@ -243,7 +244,7 @@ class CmdCheckHobos(Command):
|
|||
field_class = EmailField
|
||||
elif attribute['kind'] in ('date', 'birthdate', 'fedict_date'):
|
||||
field_class = DateField
|
||||
new_field = field_class(label=attribute['label'].encode('utf-8'),
|
||||
new_field = field_class(label=force_str(attribute['label']),
|
||||
type=field_class.key,
|
||||
varname=attribute['name'])
|
||||
new_field.id = field_id
|
||||
|
@ -252,8 +253,8 @@ class CmdCheckHobos(Command):
|
|||
# remove it for the moment
|
||||
formdef.fields.remove(profile_fields[field_id])
|
||||
|
||||
profile_fields[field_id].label = attribute['label'].encode('utf-8')
|
||||
profile_fields[field_id].hint = attribute['description'].encode('utf-8')
|
||||
profile_fields[field_id].label = force_str(attribute['label'])
|
||||
profile_fields[field_id].hint = force_str(attribute['description'])
|
||||
profile_fields[field_id].required = attribute['required']
|
||||
|
||||
if attribute['disabled']:
|
||||
|
@ -341,7 +342,7 @@ class CmdCheckHobos(Command):
|
|||
if not admin_attribute:
|
||||
admin_attribute = 'is_superuser=true'
|
||||
else:
|
||||
admin_attribute = force_text(admin_attribute).encode('utf-8')
|
||||
admin_attribute = force_str(admin_attribute)
|
||||
admin_attribute_dict = dict([admin_attribute.split('=')])
|
||||
pub.cfg['idp'][key_provider_id]['admin-attributes'] = admin_attribute_dict
|
||||
pub.cfg['idp'][key_provider_id]['nameidformat'] = 'unspecified'
|
||||
|
@ -432,8 +433,8 @@ class CmdCheckHobos(Command):
|
|||
if not 'variables' in config.sections():
|
||||
config.add_section('variables')
|
||||
for key, value in variables.items():
|
||||
key = force_text(key).encode('utf-8')
|
||||
value = force_text(value).encode('utf-8')
|
||||
key = force_str(key)
|
||||
value = force_str(value)
|
||||
config.set('variables', key, value)
|
||||
|
||||
if not 'api-secrets' in config.sections():
|
||||
|
|
Loading…
Reference in New Issue