Hatena::ブログ(Diary)

almost nearly dead このページをアンテナに追加 RSSフィード Twitter

2008-07-14

TicketDeleteプラグインのパッチ

| 21:22 | TicketDeleteプラグインのパッチを含むブックマーク

サクっとは出来ませんでした(涙)

基本的には0.10版のTicketDeleteと同じ挙動をするはずです。*1

以下はオリジナルのTicketDeleteに対してのパッチです。

(7月15日一部訂正 以前のパッチだと動かないので注意!)*2

Index: ticketdelete/web_ui.py
===================================================================
--- ticketdelete/web_ui.py (revision 4008)
+++ ticketdelete/web_ui.py (working copy)
@@ -1,2 +1,3 @@
+# -*- coding: utf-8 -*-
 # Ticket deleting plugins
 
@@ -28,15 +29,19 @@
         return handler
 
-    def post_process_request(self, req, template, content_type):
+    def post_process_request(self, req, template, data, content_type):
         if template == 'ticket.html' and 'TICKET_ADMIN' in req.perm:
             add_script(req, 'ticketdelete/ticketdelete.js')
             add_stylesheet(req, 'ticketdelete/ticketdelete.css')
-        return template, content_type
+        return (template, data, content_type)
+
+
+
+
  
     # IAdminPanelProvider methods
     def get_admin_panels(self, req):
         if 'TICKET_ADMIN' in req.perm:
-            yield ('ticket', 'Ticket System', 'delete', 'Delete')
-            yield ('ticket', 'Ticket System', 'comments', 'Delete Changes')
+            yield ('ticket', 'Ticket System', 'delete', 'チケットの削除')
+            yield ('ticket', 'Ticket System', 'comments', 'コメントの削除')
             
     def render_admin_panel(self, req, cat, page, path_info):
@@ -103,5 +108,5 @@
                         # FIXME: The datetime handling is not working - enable
                         # for traceback
-                        c_data['prettytime'] = strftime('%a, %d %b %Y %H:%M:%S',time.timetuple())
+                        c_data['prettytime'] = strftime('%Y/%b/%d  %H:%M:%S',time.timetuple())
                     
                     # Check the boxes next to change number `selected`
Index: ticketdelete/htdocs/ticketdelete.js
===================================================================
--- ticketdelete/htdocs/ticketdelete.js (revision 4008)
+++ ticketdelete/htdocs/ticketdelete.js (revision 213)
@@ -1,5 +1,5 @@
 $(document).ready(function() {
     var ticket = /\/ticket\/(\d+)/.exec(document.location)[1];
-    var delete_link = '<a href="../admin/ticket/delete/'+ticket+'">Delete</a>';
+    var delete_link = '<a href="../admin/ticket/delete/'+ticket+'"title="チケットを削除">削除</a>';
     var ticket_buttons = $('#ticket .inlinebuttons')[0];
     if (ticket_buttons) {
@@ -8,9 +8,9 @@
         $('#ticket table.properties').after('<div class="description"><h3><span class="inlinebuttons">'+delete_link+'</span>&nbsp;</h3></div>');
     }
-    $('#changelog h3').each(function() {
-        var comment = $('input[@name=replyto]', this)[0];
+    $('#changelog .printableform').each(function() {
+        var comment = $('.inlinebuttons input[@name=replyto]', this)[0];
         if (comment) {
-            comment = comment.value;
-            $('.inlinebuttons', this).append('<a href="../admin/ticket/comments/'+ticket+'?cnum='+comment+'">Delete</a>');
+
+            $('.inlinebuttons', this).append('<a href="../admin/ticket/comments/'+ticket+'?cnum='+comment.value+'" title="コメント '+comment.value+' を削除">削除</a>');
         }
     });
Index: ticketdelete/templates/ticketdelete_admin.html
===================================================================
--- ticketdelete/templates/ticketdelete_admin.html (revision 4008)
+++ ticketdelete/templates/ticketdelete_admin.html (revision 213)
@@ -47,5 +47,5 @@
               <py:for each="change in ticketdelete.changes">
                 <tr>
-                  <td><input type="checkbox" name="dontcare" value="dontcare" id="checkbox_${change}" checked="${change.checked or None}" /></td>
+                  <td><input type="checkbox" name="dontcare" value="dontcare" id="checkbox_${change}" checked="${ticketdelete.changes[change].checked}" /></td>
                   <td colspan="3"><b>Change at ${ticketdelete.changes[change].prettytime} by ${ticketdelete.changes[change].author}</b></td>
                   <td><input type="submit" name="delete_${change}" value="Delete change" /></td>
@@ -53,8 +53,9 @@
                     <py:for each="field in ticketdelete.changes[change].fields">
                       <tr>
-                        <td><input type="checkbox" id="checkbox${field}_${change}" name="mdelete" value="${field}_${change}" checked="${ticketdelete.changes[change].checked or None}" /></td>
+                        <td><input type="checkbox" id="checkbox${field}_${change}" name="mdelete" value="${field}_${change}" checked="${ticketdelete.changes[change].checked}" /></td>
                         <td>${field}</td>
-                        <td>${ticketdelete.changes[change].fields[field].old}</td>
-                        <td>${ticketdelete.changes[change].fields[field].new}</td>
+                        <td py:if="field == 'comment'" colspan="2">${ticketdelete.changes[change].fields[field].new}</td>
+                        <td py:if="field != 'comment'" >${ticketdelete.changes[change].fields[field].old}</td>
+                        <td py:if="field != 'comment'">${ticketdelete.changes[change].fields[field].new}</td>
                         <td><input type="submit" name="delete${field}_${change}" value="Delete field" /></td>
                       </tr>
@@ -67,5 +68,5 @@
         
         <script type="text/javascript">
-        <!--
+
             function toggleboxen(me, boxen) 
             {
@@ -80,11 +81,11 @@
             <py:for each="change in ticketdelete.changes">
             addEvent(document.getElementById("checkbox_${change}"), "change", function() {
-                var boxen = Array(${py:for each="field in change.fields"${field}",</py:for>"");
+                var boxen = Array(<py:for each="field in ticketdelete.changes[change].fields">"${field}",</py:for>"");
                 toggleboxen("${change}", boxen); //Array(<py:for each="field in change.fields">"${field}",</py:for>));
             });
-            <py:for each="field in change.fields">
+            <py:for each="field in ticketdelete.changes[change].fields">
               addEvent(document.getElementById("checkbox${field}_${change}"),"change", function() {
                   if(!document.getElementById("checkbox${field}_${change}").checked) {
-                  document.getElementById("checkbox${change}").checked = 0;
+                  document.getElementById("checkbox_${change}").checked = 0;
                 }
             });
@@ -93,5 +94,5 @@
 
 
-        //-->
+
         </script>

*1:同じ不具合もあります。

*2Oかもとさん指摘有り難うございます

kaorun55kaorun55 2008/07/14 13:34 がんばってください!
今のところプラグインには手出しできないので、かぬさんたちが頼りです^^;

kanu-orzkanu-orz 2008/07/14 14:46 取りあえずチケット画面に削除ボタンを出すのまでは出来ました。
しかしテンプレート(Genshi)の処理に問題があるようで、管理画面で
チェックがつくべき所につかない状態です。
会社にはpyDevの環境も無いので家に帰ってからになりそうです。

トラックバック - http://d.hatena.ne.jp/kanu-orz/20080714/1216038169
Connection: close