source: trunk/skins/lemill/portlet_material_actions.pt @ 1345

Revision 1345, 7.7 KB checked in by jukka, 13 years ago (diff)

Fixed #1128, refactored portlets with sane condition-statements.

Line 
1<html xmlns:tal="http://xml.zope.org/namespaces/tal"
2      xmlns:metal="http://xml.zope.org/namespaces/metal"
3      i18n:domain="lemill">
4<body>
5    <div metal:define-macro="portlet" id="portlet-material-actions"
6        tal:define="path_end python:here.REQUEST['URL'].split('/')[-1];
7                    is_History python:path_end=='history_view' or here.REQUEST.get('version',0);
8                    is_Translation python:path_end=='show_translations';
9                    can_moderate here/canIModerate;
10                    is_owner here/amIOwner;">
11
12<tal:visible condition="python:wf_state!='deleted'">
13
14<div class="tb-portlet" metal:define-macro="image_div">
15    <p style="text-align: center;" tal:condition="python: is_History or is_Translation"><a href="" tal:define="myUrl python: context.absolute_url()" tal:attributes="href string: ${myUrl}/view"><img src="images/default_learningresource.png" tal:attributes="src here/getCoverImageURL; alt python:here.meta_type" style="padding: 39px 0px 29px 0px;" /></a></p>
16    <p style="text-align: center;" tal:condition="python: not (is_History or is_Translation)"><img src="images/default_learningresource.png" tal:attributes="src here/getCoverImageURL; alt python:here.meta_type" style="padding: 39px 0px 29px 0px;" /></p>
17    <tal:editable tal:condition="not:is_History">
18    <ul metal:define-slot="image_edit" tal:condition="python:wf_state=='public' and (is_editable or can_moderate)">
19        <li tal:condition="is_editable">
20            <a  href="" tal:attributes="href string:${here_url}/change_coverimage"><tal:block i18n:translate="label_change_cover_image">Change cover image</tal:block>...</a>
21        </li>
22        <li tal:condition="python:is_owner or can_moderate">
23            <a href="" tal:attributes="href string:$here_url/retract"><tal:block i18n:domain="lemill" i18n:translate="Change to draft">Change to draft</tal:block></a>
24        </li>
25    </ul>
26    <ul tal:condition="python:wf_state=='draft' and (is_owner or can_moderate)">
27        <li>
28            <a href="" tal:attributes="href string:$here_url/lemill_ask_publish"><tal:block i18n:domain="plone" i18n:translate="Publish">Publish</tal:block>...</a>
29        </li>
30    </ul>
31    </tal:editable>
32</div>
33
34<tal:history condition="is_History">
35<div class="tb-portlet" metal:define-macro="history_div">
36    <ul tal:condition="python:path_end!='history_view'">
37        <li><a href="" i18n:translate="label_view_history" tal:attributes="href string:${here_url}/history_view">History</a></li>
38    </ul>
39</div>
40</tal:history>
41
42<tal:not_history condition="not:is_History">
43<div class="tb-portlet" metal:define-macro="edit_div">
44    <ul>
45        <li>
46            <a href="" i18n:domain="plone"
47                tal:attributes="href python:test(is_editable, here_url+'/edit',
48                    test(isAnon, 'login_form', here_url+'/join_a_group'))"><tal:block i18n:translate="label_edit">Edit</tal:block>...</a>
49        </li>
50        <li><a href="" i18n:translate="label_view_history" tal:attributes="href string:${here_url}/history_view">History</a></li>
51        <!--li tal:condition="python:(context.amIOwner() or here.canIModerate()) and here.amIMaterial() and not no_edit_links"><a href="TODO"><tal:block i18n:translate="label_transfer_authorship">Transfer authorship</tal:block>...</a></li-->
52        <li metal:define-macro="delete_action" tal:condition="python:is_owner or can_moderate">
53           <a href="" i18n:domain="plone" tal:attributes="href string:${here_url}/delete" class="deleteLinkColor"><tal:block i18n:translate="Delete">Delete</tal:block>...</a>
54        </li>
55    </ul>
56</div>
57
58<div class="tb-portlet" metal:define-macro="collections_div" tal:condition="python:colls or not isAnon" tal:define="colls python:context.community.getCollections(obj_uid=context.UID())">
59    <ul>
60    <tal:macro metal:define-macro="collection_actions">
61        <li tal:condition="not:isAnon"><a href="" tal:attributes="href python:str(here.absolute_url())+'/collection_add'"><tal:block i18n:translate="label_add_to_collection">Add to collection</tal:block>...</a></li>
62        <li tal:condition="colls">
63            <a href=""  i18n:translate="label_view_collections"
64                tal:attributes="href string:${membersfolder/absolute_url}/${member}/collections/redirect?url=${membersfolder/absolute_url}/${member}/collections/collections_list?obj_id=${context/UID}">
65                View collections</a>
66            <span tal:replace="python:'('+str(len(colls))+')'">(1)</span>
67        </li>
68    </tal:macro>
69        <tal:comment replace="nothing"><li><a i18n:translate="label_read_tips" href="TODO">Read Tips for Use</a></li></tal:comment>       
70    </ul>
71</div>
72
73<tal:macro metal:define-macro="translate_actions">
74<tal:translations tal:condition="python:wf_state != 'deleted' and context.meta_type not in ['Piece', 'LeMillReference']">
75<div class="tb-portlet" tal:condition="python:(not isAnon and wf_state=='public') or here.getTranslations()" tal:define="translation_of here/getOriginal">
76    <ul>
77        <li tal:condition="python: not isAnon and wf_state=='public'"><a href="" tal:attributes="href python:'%s/translate_resource' % here_url"><tal:block i18n:translate="label_translate">Translate</tal:block>...</a></li>
78        <li tal:condition="translation_of">
79            <a href="" tal:attributes="href translation_of/absolute_url" i18n:translate="link_original_translated">Original</a>
80            (<span tal:replace="python:here.script_getPrettyLanguage(translation_of.Language())"/>)
81        </li>
82        <li tal:condition="here/getTranslations">
83            <a href="show_translations" tal:attributes="href string:${here/absolute_url}/show_translations">
84                <span i18n:translate="label_translations" tal:omit-tag="">Translations</span></a>
85                (<tal:n replace="python:len(context.getTranslations())"></tal:n>)
86           <tal:notAnons condition="not:isAnon">
87               <ul tal:define="member_folder python: mtool.getHomeFolder(member.getId());
88                               user_langs member_folder/getLanguage_skills"
89                   tal:condition="user_langs">
90                   <tal:trans repeat="rr context/getTranslations">
91                    <tal:defs tal:define="tlang python:rr.Language()">
92                     <li tal:condition="python:tlang in user_langs and tlang!=context.Language()">
93                      <a href="" tal:content="python:here.script_getPrettyLanguage(tlang)" tal:attributes="href rr/absolute_url | nothing"></a>
94                     </li>
95                     <li tal:condition="python:tlang==context.Language()" tal:content="python:here.script_getPrettyLanguage(tlang)" />
96                    </tal:defs>                 
97                   </tal:trans>
98               </ul>
99           </tal:notAnons>
100        </li>
101    </ul>
102</div>
103</tal:translations>
104</tal:macro>
105
106
107<div class="tb-portlet" metal:define-macro="view_div" tal:condition="python: here.amIMaterial()">
108    <ul>
109        <li><a i18n:translate="label_student_view" tal:attributes="href string:${here_url}">Student view</a></li>
110    </ul>
111</div>
112
113
114<tal:comment replace="nothing">
115<div class="tb-portlet" metal:define-macro="owner_div" tal:condition="python:wf_state=='public' and context.lemill_tool.portal_integration and context.meta_type in context.getMaterialTypes()">
116    <ul>       
117    <li>
118    <a href="TODO" i18n:translate="label_publish_in_portal">Publish in portal</a>
119    </li>
120    </ul>
121</div>
122</tal:comment>
123
124</tal:not_history>
125</tal:visible>
126<tal:deleted condition="python:wf_state=='deleted'">
127    <div class="tb-portlet" tal:condition="python:context.amIOwner() or here.canIModerate() and not is_History" metal:define-macro="restore_div">
128        <ul>
129            <li><a i18n:translate="label_restore_or_undelete" href="" tal:attributes="href string:${here_url}/rescue">Restore deleted</a></li>
130        </ul>
131    </div>
132</tal:deleted>
133
134</div>
135</body>
136</html>
137
Note: See TracBrowser for help on using the repository browser.