Projet

Général

Profil

0001-admin-warn-about-missing-roles-in-site-import-41252.patch

Frédéric Péters, 06 mai 2020 18:41

Télécharger (2,55 ko)

Voir les différences:

Subject: [PATCH] admin: warn about missing roles in site import (#41252)

 tests/test_admin_pages.py | 10 ++++++++++
 wcs/admin/settings.py     |  8 ++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)
tests/test_admin_pages.py
4577 4577
    filelist = zipf.namelist()
4578 4578
    assert len([x for x in filelist if 'roles/' in x]) == 0
4579 4579

  
4580
    # check an error is displayed if such an import is then used and roles are
4581
    # missing.
4582
    FormDef.wipe()
4583
    Workflow.wipe()
4584
    Role.wipe()
4585
    resp = app.get('/backoffice/settings/import')
4586
    resp.form['file'] = Upload('export.wcs', zip_content.getvalue())
4587
    resp = resp.form.submit('submit')
4588
    assert 'Unknown referenced role (qux)' in resp
4589

  
4580 4590

  
4581 4591
def test_settings_themes(pub):
4582 4592
    create_superuser(pub)
wcs/admin/settings.py
54 54

  
55 55
from wcs.formdef import FormDef
56 56
from wcs.carddef import CardDef
57
from wcs.workflows import Workflow
57
from wcs.workflows import Workflow, WorkflowImportError
58 58
from wcs.roles import Role
59 59

  
60 60
from wcs.backoffice.studio import StudioDirectory
......
998 998
                results = self.import_submit(form)
999 999
            except zipfile.BadZipfile:
1000 1000
                results = None
1001
                reason = _('Not a valid export file')
1002
            except WorkflowImportError as e:
1003
                results = None
1004
                reason = _(e) % e.msg_args
1001 1005
            html_top('settings', title = _('Import'))
1002 1006
            r = TemplateIO(html=True)
1003 1007
            r += htmltext('<h2>%s</h2>') % _('Import')
......
1024 1028
                    r += htmltext('<li>%d %s</li>') % (results['wscalls'], _('webservice calls'))
1025 1029
                r += htmltext('</ul>')
1026 1030
            else:
1027
                r += htmltext('<p>%s</p>') % _('Error: Not a valid export file')
1031
                r += htmltext('<p>%s %s</p>') % (_('Error:'), reason)
1028 1032
            r += htmltext('<a href=".">%s</a>') % _('Back')
1029 1033
            return r.getvalue()
1030 1034

  
1031
-