Skip to content

Commit af17877

Browse files
committed
workflow transitions
1 parent f964dab commit af17877

File tree

3 files changed

+35
-73
lines changed

3 files changed

+35
-73
lines changed

src/cs_dynamicpages/views/dynamic_page_row_featured_view.pt

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,8 @@
1515
<metal:content-core fill-slot="content-core">
1616
<metal:block define-macro="content-core">
1717

18-
<tal:define tal:define="
19-
isAnon context/@@plone_portal_state/anonymous;
20-
">
21-
<tal:condition tal:condition="isAnon">
22-
<tal:replace tal:replace="python:context.REQUEST.RESPONSE.redirect(context.aq_parent.absolute_url(),301)">
23-
</tal:replace>
24-
</tal:condition>
25-
<tal:conditionisanon tal:condition="not:isAnon">
26-
<a class="btn btn-primary btn-lg" href="${context/aq_parent/absolute_url}">View dynamic page row</a>
27-
</tal:conditionisanon>
28-
</tal:define>
18+
<tal:replace tal:replace="python:context.REQUEST.RESPONSE.redirect(context.aq_parent.absolute_url(),301)">
19+
</tal:replace>
2920

3021
</metal:block>
3122
</metal:content-core>
Lines changed: 18 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,26 @@
1-
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:i18n="http://xml.zope.org/namespaces/i18n"
2-
xmlns:metal="http://xml.zope.org/namespaces/metal" xmlns:tal="http://xml.zope.org/namespaces/tal"
3-
metal:use-macro="context/main_template/macros/master" i18n:domain="cs_dynamicpages">
1+
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:metal="http://xml.zope.org/namespaces/metal"
2+
xmlns:tal="http://xml.zope.org/namespaces/tal" xmlns:i18n="http://xml.zope.org/namespaces/i18n"
3+
i18n:domain="cs_dynamicpages" metal:use-macro="context/main_template/macros/master">
44

55
<body>
6-
<metal:content-main fill-slot="main">
7-
<main id="content">
8-
<tal:define tal:define="
9-
isAnon context/@@plone_portal_state/anonymous;
10-
">
11-
<tal:conditionisanon tal:condition="isAnon">
12-
<tal:replace
13-
tal:replace="python:context.REQUEST.RESPONSE.redirect(context.aq_parent.aq_parent.absolute_url(),301)">
14-
</tal:replace>
15-
</tal:conditionisanon>
16-
<tal:conditionisanon tal:condition="not:isAnon">
17-
<section class="dynamic-row state-${context/review_state}">
18-
<div class="edit-buttons d-flex gap-2" tal:condition="context/can_edit">
19-
<small
20-
class="d-inline-flex mb-3 px-2 py-1 fw-semibold text-warning-emphasis bg-warning-subtle border border-warning-subtle rounded-2 position-relative">
21-
Template: ${context/row_template}
22-
</small>
23-
<a class="btn btn-outline-primary btn-sm align-self-start" href="${context/absolute_url}/edit">Edit</a>
24-
<div class="ms-auto d-flex gap-2 align-items-start">
25-
<a class="btn btn-outline-primary btn-sm align-self-start"
26-
href="${context/aq_parent/aq_parent/absolute_url}">Go
27-
to top</a>
28-
<small
29-
class="d-inline-flex mb-3 px-2 py-1 fw-semibold text-warning-emphasis bg-warning-subtle border border-warning-subtle rounded-2 position-relative">
30-
Review state: ${context/review_state}
31-
<span
32-
tal:attributes="class python:context.review_state() == 'published' and 'position-absolute top-0 start-100 translate-middle p-2 bg-success border border-light rounded-circle' or 'position-absolute top-0 start-100 translate-middle p-2 bg-danger border border-light rounded-circle'">
33-
</span>
34-
</small>
35-
</div>
366

37-
</div>
38-
<tal:condition tal:condition="context/can_edit">
39-
<div class="features-list d-flex gap-2 align-items-start mb-3"
40-
tal:define="features_list context/featured_list">
41-
<tal:featured repeat="featured_brain features_list">
42-
<div tal:define="featured_obj featured_brain/getObject;">
43-
<a tal:attributes="class python:featured_obj.review_state() == 'published' and 'btn btn-outline-success btn-sm bg-success-subtle' or 'btn btn-outline-danger btn-sm bg-danger-subtle'"
44-
href="${featured_obj/absolute_url}">${featured_obj/Title}</a>
45-
</div>
46-
</tal:featured>
47-
<tal:featured_add_button tal:condition="python:context.show_featured_add_button(request)">
48-
<a class="btn btn-outline-primary btn-sm align-self-start"
49-
href="${context/absolute_url}/++add++DynamicPageRowFeatured">Add new featured</a>
50-
</tal:featured_add_button>
51-
</div>
7+
<metal:custom_title fill-slot="content-title">
8+
<h1 tal:replace="structure context/@@title" />
9+
</metal:custom_title>
5210

53-
</tal:condition>
11+
<metal:custom_description fill-slot="content-description">
12+
<p tal:replace="structure context/@@description" />
13+
</metal:custom_description>
5414

55-
<div class="content">
56-
<replace tal:replace="structure python:context.render(request)"></replace>
57-
</div>
58-
</section>
59-
</tal:conditionisanon>
60-
</tal:define>
61-
</main>
62-
</metal:content-main>
15+
<metal:content-core fill-slot="content-core">
16+
<metal:block define-macro="content-core">
17+
18+
<tal:replace
19+
tal:replace="python:context.REQUEST.RESPONSE.redirect(context.aq_parent.aq_parent.absolute_url(),301)">
20+
</tal:replace>
21+
22+
</metal:block>
23+
</metal:content-core>
6324
</body>
6425

6526
</html>

src/cs_dynamicpages/views/dynamic_view.pt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@
4242
tal:attributes="class python:row.review_state() == 'published' and 'position-absolute top-0 start-100 translate-middle p-2 bg-success border border-light rounded-circle' or 'position-absolute top-0 start-100 translate-middle p-2 bg-danger border border-light rounded-circle'">
4343
</span>
4444
</a>
45-
<ul class="dropdown-menu">
46-
<li><a class="dropdown-item" href="#">Send back</a></li>
47-
<li><a class="dropdown-item" href="#">Publish</a></li>
45+
<ul class="dropdown-menu"
46+
tal:define="transitions python:context.portal_workflow.getTransitionsFor(row)">
47+
<tal:transitions repeat="transition transitions">
48+
<li><a class="dropdown-item"
49+
href="${transition/url}&_authenticator=${context/@@authenticator/token}">${transition/name}</a>
50+
</li>
51+
</tal:transitions>
4852
</ul>
4953
</div>
5054
</div>
@@ -74,8 +78,14 @@
7478
<li>
7579
<h5 class="dropdown-header">State</h5>
7680
</li>
77-
<li><a class="dropdown-item" href="#">Published</a></li>
78-
<li><a class="dropdown-item" href="#">Draft</a></li>
81+
<tal:define
82+
tal:define="featured_transitions python:context.portal_workflow.getTransitionsFor(featured_obj)">
83+
<tal:featured_transitions repeat="featured_transition featured_transitions">
84+
<li><a class="dropdown-item"
85+
href="${featured_transition/url}&_authenticator=${context/@@authenticator/token}">${featured_transition/name}</a>
86+
</li>
87+
</tal:featured_transitions>
88+
</tal:define>
7989
<li>
8090
<h5 class="dropdown-header">Move actions</h5>
8191
</li>

0 commit comments

Comments
 (0)