0001-management-add-link-to-form-carddef-page-in-sidebar-.patch
tests/admin_pages/test_workflow.py | ||
---|---|---|
3144 | 3144 |
app.get('/backoffice/workflows/categories/', status=403) |
3145 | 3145 |
app.get('/backoffice/workflows/data-sources/', status=403) |
3146 | 3146 |
app.get('/backoffice/workflows/mail-templates/', status=403) |
3147 |
app.get('/backoffice/workflows/%s/' % workflow.id, status=403) |
|
3147 | 3148 | |
3148 | 3149 |
# no import into other category |
3149 | 3150 |
workflow_xml = ET.tostring(workflow.export_to_xml(include_id=True)) |
tests/backoffice_pages/test_all.py | ||
---|---|---|
331 | 331 |
assert resp.pyquery.find('body.section-management') |
332 | 332 | |
333 | 333 | |
334 |
def test_admin_form_page(pub): |
|
335 |
create_superuser(pub) |
|
336 |
FormDef.wipe() |
|
337 |
formdef = FormDef() |
|
338 |
formdef.name = 'form title' |
|
339 |
formdef.fields = [] |
|
340 |
formdef.store() |
|
341 | ||
342 |
app = login(get_app(pub)) |
|
343 |
resp = app.get('/backoffice/management/form-title/') |
|
344 |
assert 'backoffice/forms/1/' in resp |
|
345 |
assert 'backoffice/workflows/_default/' in resp |
|
346 | ||
347 | ||
334 | 348 |
def test_backoffice_listing(pub): |
335 | 349 |
create_superuser(pub) |
336 | 350 |
create_environment(pub) |
... | ... | |
5374 | 5388 |
resp = app.get(create_formdata['source_formdef'].get_url(backoffice=True)) |
5375 | 5389 | |
5376 | 5390 |
# click on first available formdata |
5377 |
resp = resp.click(href='%s/' % formdata.id)
|
|
5391 |
resp = resp.click('%s-%s' % (create_formdata['source_formdef'].id, formdata.id))
|
|
5378 | 5392 |
target_data_class = create_formdata['target_formdef'].data_class() |
5379 | 5393 |
assert target_data_class.count() == 0 |
5380 | 5394 |
# resubmit it through backoffice submission |
... | ... | |
5492 | 5506 |
resp = app.get(create_formdata['source_formdef'].get_url(backoffice=True)) |
5493 | 5507 | |
5494 | 5508 |
# click on first available formdata |
5495 |
resp = resp.click(href='%s/' % formdata.id)
|
|
5509 |
resp = resp.click('%s-%s' % (create_formdata['source_formdef'].id, formdata.id))
|
|
5496 | 5510 |
target_data_class = create_formdata['target_formdef'].data_class() |
5497 | 5511 |
assert target_data_class.count() == 0 |
5498 | 5512 |
# resubmit it through backoffice submission |
tests/backoffice_pages/test_carddata.py | ||
---|---|---|
15 | 15 |
from wcs.workflows import ChoiceWorkflowStatusItem, Workflow |
16 | 16 | |
17 | 17 |
from ..utilities import clean_temporary_pub, create_temporary_pub, get_app, login |
18 |
from .test_all import create_user |
|
18 |
from .test_all import create_superuser, create_user
|
|
19 | 19 | |
20 | 20 | |
21 | 21 |
def pytest_generate_tests(metafunc): |
... | ... | |
47 | 47 |
clean_temporary_pub() |
48 | 48 | |
49 | 49 | |
50 |
def test_admin_card_page(pub): |
|
51 |
create_superuser(pub) |
|
52 |
CardDef.wipe() |
|
53 |
carddef = CardDef() |
|
54 |
carddef.name = 'foo' |
|
55 |
carddef.fields = [] |
|
56 |
carddef.store() |
|
57 | ||
58 |
app = login(get_app(pub)) |
|
59 |
resp = app.get('/backoffice/data/foo/') |
|
60 |
assert 'backoffice/cards/1/' in resp |
|
61 |
print(resp) |
|
62 |
assert 'backoffice/workflows/_carddef_default/' in resp |
|
63 | ||
64 | ||
50 | 65 |
def test_carddata_management(pub): |
51 | 66 |
CardDef.wipe() |
52 | 67 |
user = create_user(pub) |
wcs/admin/workflows.py | ||
---|---|---|
2044 | 2044 | |
2045 | 2045 |
def _q_lookup(self, component): |
2046 | 2046 |
directory = WorkflowPage(component) |
2047 |
global_access = is_global_accessible() |
|
2048 |
if directory.workflow.id not in ('_default', '_carddef_default') and not global_access: |
|
2049 |
user_roles = set(get_request().user.get_roles()) |
|
2050 |
management_roles = set() |
|
2051 |
if directory.workflow.category: |
|
2052 |
management_roles = { |
|
2053 |
x.id for x in getattr(directory.workflow.category, 'management_roles') or [] |
|
2054 |
} |
|
2055 |
if not management_roles.intersection(user_roles): |
|
2056 |
raise errors.AccessForbiddenError() |
|
2047 |
if not directory.workflow.has_user_access(): |
|
2048 |
raise errors.AccessForbiddenError() |
|
2057 | 2049 |
return directory |
2058 | 2050 | |
2059 | 2051 |
def p_import(self): |
wcs/backoffice/data_management.py | ||
---|---|---|
103 | 103 |
admin_permission = 'cards' |
104 | 104 |
formdef_class = CardDef |
105 | 105 |
search_label = _('Search in card content') |
106 |
formdef_view_label = _('View Card') |
|
106 | 107 | |
107 | 108 |
@property |
108 | 109 |
def add(self): |
wcs/backoffice/management.py | ||
---|---|---|
791 | 791 |
admin_permission = 'forms' |
792 | 792 |
formdef_class = FormDef |
793 | 793 |
search_label = _('Search in form content') |
794 |
formdef_view_label = _('View Form') |
|
794 | 795 |
WCS_SYNC_EXPORT_LIMIT = 100 # Arbitrary threshold |
795 | 796 | |
796 | 797 |
def __init__(self, component=None, formdef=None, view=None, update_breadcrumbs=True): |
... | ... | |
874 | 875 |
or self.formdef.category.has_permission('statistics', get_request().user) |
875 | 876 |
): |
876 | 877 |
r += htmltext(' <li class="stats"><a href="stats">%s</a></li>') % _('Statistics') |
878 | ||
879 |
if get_publisher().get_backoffice_root().is_global_accessible(self.formdef.backoffice_section): |
|
880 |
r += htmltext(' <li><a href="%s">%s</a></li>') % ( |
|
881 |
self.formdef.get_admin_url(), |
|
882 |
self.formdef_view_label, |
|
883 |
) |
|
884 |
if self.formdef.workflow.has_user_access(): |
|
885 |
r += htmltext(' <li><a href="%s">%s</a></li>') % ( |
|
886 |
self.formdef.workflow.get_admin_url(), |
|
887 |
_('View Workflow'), |
|
888 |
) |
|
877 | 889 |
return r.getvalue() |
878 | 890 | |
879 | 891 |
def get_formdata_sidebar(self, qs=''): |
wcs/workflows.py | ||
---|---|---|
1103 | 1103 |
criterias = [Contains('slug', slugs)] |
1104 | 1104 |
return list(MailTemplate.select(criterias, order_by='name')) |
1105 | 1105 | |
1106 |
def has_user_access(self): |
|
1107 |
global_access = get_publisher().get_backoffice_root().is_global_accessible('workflows') |
|
1108 |
if global_access: |
|
1109 |
return True |
|
1110 |
if self.id in ('_default', '_carddef_default'): |
|
1111 |
return True |
|
1112 |
user_roles = set(get_request().user.get_roles()) |
|
1113 |
management_roles = set() |
|
1114 |
if self.category: |
|
1115 |
management_roles = {x.id for x in getattr(self.category, 'management_roles') or []} |
|
1116 |
if management_roles.intersection(user_roles): |
|
1117 |
return True |
|
1118 |
return False |
|
1119 | ||
1106 | 1120 | |
1107 | 1121 |
class XmlSerialisable: |
1108 | 1122 |
node_name = None |
1109 |
- |