Ezio Melotti <ezio.melo...@gmail.com> added the comment:
The attached patch adds
"This message has been unlinked from issueXXX: [Restore]"
to the msg page when a message has been unlinked and not relinked yet.
When the [Restore] button is pressed the message is added back where it was and
the user is sent back to the issue page.
Something like:
"This message is linked to issueXXX: [Remove]"
could be added as well and the [Remove] buttons could be removed from the issue
pages.
_______________________________________________________
PSF Meta Tracker <metatrac...@psf.upfronthosting.co.za>
<http://psf.upfronthosting.co.za/roundup/meta/issue267>
_______________________________________________________
Index: html/msg.item.html
===================================================================
--- html/msg.item.html (revision 88842)
+++ html/msg.item.html (working copy)
@@ -124,6 +124,18 @@
</tr>
</table>
+
+<form tal:define="u_hasRole python:request.user.hasRole;
+ issueid python:utils.issueid_from_unlinked_msg(context)"
+ tal:condition="python:issueid and context.is_edit_ok()"
+ tal:attributes="action python:('issue%s' % issueid)" method="post">
+ <input type="hidden" name="@action" value="edit" />
+ <input type="hidden" name="@add@messages" tal:attributes="value
context/id" />
+ <p>This message has been unlinked from issue<tal:block
tal:replace="issueid" />:
+ <input type="submit" value="Restore" i18n:attributes="value"/></p>
+</form>
+
+
<tal:block tal:replace="structure context/history" />
</div>
Index: extensions/pydevutils.py
===================================================================
--- extensions/pydevutils.py (revision 88865)
+++ extensions/pydevutils.py (working copy)
@@ -14,6 +14,26 @@
db = request.client.db
return 'Coordinator' in db.user.get(user, 'roles')
+
+def issueid_from_unlinked_msg(msg):
+ """
+ If a message has been unlinked from an issue and it's still unlinked,
+ return the issues id, otherwise return None.
+ """
+ last_action = ''
+ for entry in msg._klass.history(msg._nodeid):
+ if 'unlink' in entry:
+ last_unlink = entry
+ last_action = 'unlink'
+ elif 'link' in entry:
+ last_action = 'link'
+ if last_action == 'unlink':
+ # the msg has been unlinked and not linked back
+ # the unlink looks like: ('16', <Date 2011-07-22.05:58:32.300>, '4',
+ # 'unlink', ('issue', '1', 'messages'))
+ return last_unlink[4][1]
+
def init(instance):
instance.registerUtil('is_history_ok', is_history_ok)
instance.registerUtil('is_coordinator', is_coordinator)
+ instance.registerUtil('issueid_from_unlinked_msg',
issueid_from_unlinked_msg)
_______________________________________________
Tracker-discuss mailing list
Tracker-discuss@python.org
http://mail.python.org/mailman/listinfo/tracker-discuss