Ezio Melotti <ezio.melo...@gmail.com> added the comment:
New patch that:
* adds "This message/file is linked to issueXXX: [Unlink]" when the msg/file
is linked;
* adds "This message/file has been unlinked from issueXXX: [Restore]" when the
msg/file is unlinked;
* removes the [remove] buttons for messages and files in the issue page.
_______________________________________________________
PSF Meta Tracker <metatrac...@psf.upfronthosting.co.za>
<http://psf.upfronthosting.co.za/roundup/meta/issue267>
_______________________________________________________
Index: extensions/pydevutils.py
===================================================================
--- extensions/pydevutils.py (revision 88865)
+++ extensions/pydevutils.py (working copy)
@@ -14,6 +14,29 @@
db = request.client.db
return 'Coordinator' in db.user.get(user, 'roles')
+
+def issueid_and_action_from_class(cls):
+ """
+ Return the id of the issue where the msg/file is/was linked
+ and if the last "linking action" was 'link' or 'unlink'.
+ """
+ last_action = ''
+ for entry in cls._klass.history(cls._nodeid):
+ if 'unlink' in entry:
+ last_unlink = entry
+ last_action = 'unlink'
+ elif 'link' in entry:
+ last_entry = entry
+ last_action = 'link'
+ if last_action in ('link', 'unlink'):
+ # the msg has been unlinked and not linked back
+ # the link looks like: ('16', <Date 2011-07-22.05:14:12.342>, '4',
+ # 'link', ('issue', '1', 'messages'))
+ return last_entry[4][1], last_action
+ return None, None
+
def init(instance):
instance.registerUtil('is_history_ok', is_history_ok)
instance.registerUtil('is_coordinator', is_coordinator)
+ instance.registerUtil('issueid_and_action_from_class',
+ issueid_and_action_from_class)
Index: html/msg.item.html
===================================================================
--- html/msg.item.html (revision 88842)
+++ html/msg.item.html (working copy)
@@ -124,6 +124,27 @@
</tr>
</table>
+
+<form tal:define="u_hasRole python:request.user.hasRole;
+ issueid_action
python:utils.issueid_and_action_from_class(context);
+ issueid python:'issue%s' % issueid_action[0];
+ action python:issueid_action[1]"
+ tal:condition="python:issueid and context.is_edit_ok()"
+ tal:attributes="action issueid" method="post">
+ <input type="hidden" name="@action" value="edit" />
+ <tal:block tal:condition="python: action == 'link'">
+ <input type="hidden" name="@remove@messages" tal:attributes="value
context/id" />
+ <p>This message is linked to <a tal:attributes="href issueid"
tal:content="issueid" />:
+ <input type="submit" value="Unlink" i18n:attributes="value"/></p>
+ </tal:block>
+ <tal:block tal:condition="python: action == 'unlink'">
+ <input type="hidden" name="@add@messages" tal:attributes="value
context/id" />
+ <p>This message has been unlinked from <a tal:attributes="href
issueid" tal:content="issueid" />:
+ <input type="submit" value="Restore" i18n:attributes="value"/></p>
+ </tal:block>
+</form>
+
+
<tal:block tal:replace="structure context/history" />
</div>
Index: html/file.item.html
===================================================================
--- html/file.item.html (revision 88842)
+++ html/file.item.html (working copy)
@@ -81,6 +81,27 @@
<input type="submit" name="trainham" value="Mark as HAM (not SPAM)"
i18n:attributes="value">
</form>
+
+<form tal:define="u_hasRole python:request.user.hasRole;
+ issueid_action
python:utils.issueid_and_action_from_class(context);
+ issueid python:'issue%s' % issueid_action[0];
+ action python:issueid_action[1]"
+ tal:condition="python:issueid and context.is_edit_ok()"
+ tal:attributes="action issueid" method="post">
+ <input type="hidden" name="@action" value="edit" />
+ <tal:block tal:condition="python: action == 'link'">
+ <input type="hidden" name="@remove@files" tal:attributes="value
context/id" />
+ <p>This file is linked to <a tal:attributes="href issueid"
tal:content="issueid" />:
+ <input type="submit" value="Unlink" i18n:attributes="value"/></p>
+ </tal:block>
+ <tal:block tal:condition="python: action == 'unlink'">
+ <input type="hidden" name="@add@files" tal:attributes="value
context/id" />
+ <p>This file has been unlinked from <a tal:attributes="href issueid"
tal:content="issueid" />:
+ <input type="submit" value="Restore" i18n:attributes="value"/></p>
+ </tal:block>
+</form>
+
+
<tal:block tal:condition="context/id" tal:replace="structure context/history"
/>
</td>
Index: html/issue.item.html
===================================================================
--- html/issue.item.html (revision 88843)
+++ html/issue.item.html (working copy)
@@ -240,7 +240,6 @@
<th i18n:translate="">Uploaded</th>
<th i18n:translate="">Description</th>
<th i18n:translate="">Edit</th>
- <th i18n:translate="">Remove</th>
</tr>
<tr tal:repeat="file python:context.files.sorted('creation')">
<td>
@@ -258,14 +257,6 @@
<a tal:condition="rvlink" tal:attributes="href rvlink">review</a>
</tal:block>
</td>
- <td>
- <form style="padding:0" method="post" tal:condition="file/is_edit_ok"
- tal:attributes="action string:issue${context/id}">
- <input type="hidden" name="@remove@files" tal:attributes="value file/id">
- <input type="hidden" name="@action" value="edit">
- <input type="submit" value="remove" i18n:attributes="value">
- </form>
- </td>
</tr>
</table>
@@ -321,14 +312,6 @@
</th>
<th i18n:translate="">Date: <tal:x
replace="python:msg.date.pretty('%Y-%m-%d %H:%M')"
i18n:name="date" /></th>
- <th>
- <form style="padding:0" method="post" tal:condition="msg/is_edit_ok"
- tal:attributes="action string:issue${context/id}">
- <input type="hidden" name="@remove@messages" tal:attributes="value
msg/id">
- <input type="hidden" name="@action" value="edit">
- <input type="submit" value="remove" i18n:attributes="value">
- </form>
- </th>
</tr>
<tr>
<td colspan="4" class="content">
_______________________________________________
Tracker-discuss mailing list
Tracker-discuss@python.org
http://mail.python.org/mailman/listinfo/tracker-discuss