:::: MENU ::::

Trac0.10にGanttCalendarPluginを入れる

インストール方法

trunk のデータだと 0.10 に対応していないので、branches のものを使う。
shibuya-trac - Revision 818: /plugins/ganttcalendarplugin/branches/0.10

# cd /usr/local/src/tracplugins
# mkdir ganttcalendarplugin-0.10
# svn co http://svn.sourceforge.jp/svnroot/shibuya-trac/plugins/ganttcalendarplugin/branches/0.10/ ./ganttcalendarplugin-0.10
# cd ganttcalendarplugin-0.10

ちょこっとガントチャートの見栄えを変える
# vi ganttcalendar/ticketgantt.py
# vi ganttcalendar/templates/gantt.cs

# python setup.py bdist_egg

ガントチャートの見栄えをよくする

通常ならここで egg にしてしまうのだが、ガントチャートの見栄えよくしておく。

# svn diff
Index: ganttcalendar/ticketgantt.py
===================================================================
- ganttcalendar/ticketgantt.py        (リビジョン 682)
+++ ganttcalendar/ticketgantt.py        (作業コピー)
@@ -52,7 +52,7 @@
show_closed_ticket = req.args.get('show_closed_ticket')
sorted_field = req.args.get('sorted_field')
if sorted_field == None:
-           sorted_field = 'component'
+           sorted_field = 'milestone'

if baseday != None:
r = re.match(r'^(\d+)/(\d+)/(\d+)$', baseday)
@@ -112,22 +112,26 @@
tickets=[]
for id, type, summary, owner, description, status, due_assign, due_close, complete, item in cursor:
due_assign_date = None
+           due_assign_date_short = None #assign date without year
due_close_date = None
+           due_close_date_short = None #close date without year
try:
t = time.strptime(due_assign,"%Y/%m/%d")
due_assign_date = date(t[0],t[1],t[2])
+              due_assign_date_short = date(t[0],t[1],t[2]).strftime('%m/%d')
except ValueError, TypeError:
continue
try:
t = time.strptime(due_close,"%Y/%m/%d")
due_close_date = date(t[0],t[1],t[2])
+              due_close_date_short = date(t[0],t[1],t[2]).strftime('%m/%d')
except ValueError, TypeError:
continue
if item == None or item == "":
item = "*"
if complete != None and len(complete)>1 and complete[len(complete)-1]=='%':
complete = complete[0:len(complete)-1]
-           ticket = {'id':id, 'type':type, 'summary':summary, 'owner':owner, 'description': description, 'status':status, 'due_assign':due_assign_date, 'due_close':due_close_date, 'complete': complete, sorted_field: item}
+           ticket = {'id':id, 'type':type, 'summary':summary, 'owner':owner, 'description': description, 'status':status, 'due_assign':due_assign_date, 'due_close':due_close_date, 'complete': complete, sorted_field: item, 'due_assign_short':due_assign_date_short, 'due_close_short':due_close_date_short}
self.log.debug(ticket)
tickets.append(ticket)

@@ -233,6 +237,8 @@
'url':url, 'short_summary':t['summary'][0:10],
'assign':assign, 'todow':todow, 'latew':latew, 'complete':complete
})
+            # add for sort by assign date.
+            ts.sort(lambda x, y: cmp(x['assign'], y['assign']))

req.hdf['gan'] = {
'weekdays':[u"月", u"火", u"水", u"木", u"金", u"土", u"日"],
Index: ganttcalendar/templates/gantt.cs
===================================================================
- ganttcalendar/templates/gantt.cs    (リビジョン 682)
+++ ganttcalendar/templates/gantt.cs    (作業コピー)
@@ -66,9 +66,9 @@
}


-.ticket_late { background:pink url(../images/ticket_late.png); border: 1px solid red; }
-.ticket_done { background:lightgreen url(../images/ticket_done.png); border: 1px solid green; }
-.ticket_todo { background:lightgrey url(../images/ticket_todo.png); border: 1px solid gray; }
+.ticket_late { background:pink; border: 1px solid red; }
+.ticket_done { background:lightgreen; border: 1px solid green; }
+.ticket_todo { background:lightskyblue; border: 1px solid blue; }

.ticket {
position: absolute;
@@ -119,7 +119,7 @@
}
</style>

-<form>
+<form class="printableform">
<table class="list">
<tr>
<td>
@@ -325,6 +325,19 @@
<div style="top: <?cs var:offset * ti + 60 ?>px; left: <?cs var:t.assign * dw ?>px; width: <?cs var:t.complete ?>px;" class="ticket ticket_done"></div>
<?cs /if ?>

+        <!-- add for showing ticket title on gantt bar -->
+        <div class="ticket" style="position:absolute; height:8px; top: <?cs var:offset * ti + 48 ?>px; left: <?cs if:t.assign * dw < 0 ?>3<?cs else ?><?cs var:t.assign * dw ?><?cs /if ?>px; width: 100%; font-size:10px; color:black">
+            <span class="tip">
+              <pre><span class="type"><?cs var:t.ticket['type'] ?></span>#<?cs var:t.ticket['id'] ?>: <?cs var:t.ticket['summary'] ?></pre>
+              <strong>担当者</strong>: <?cs var:t.ticket['owner'] ?><br />
+              <strong>開始日</strong>: <?cs var:t.ticket['due_assign'] ?><br />
+              <strong>終了日</strong>: <?cs var:t.ticket['due_close'] ?><br />
+              <strong>達成率</strong>: <?cs var:t.ticket['complete'] ?>%<br />
+              <strong>詳細</strong>: <pre><?cs var:t.ticket['description'] ?></pre>
+            </span>
+            <a href="<?cs var:t.url ?>" target="_blank">#<?cs var:t.ticket['id'] ?>:<?cs var:t.ticket['summary'] ?> (<?cs var:t.ticket['due_assign_short'] ?> - <?cs var:t.ticket['due_close_short'] ?>)</a>
+        </div>
+
<?cs set:offset = offset + 1 ?>

</span>

trac.ini の設定

# vi conf/trac.ini
[components]
ganttcalendar.ticketcalendar.* = enabled
ganttcalendar.ticketcalendar.ticketcalendarplugin = enabled
ganttcalendar.ticketgantt.* = enabled
ganttcalendar.ticketgantt.ticketganttchartplugin = enabled

[ticket-custom]
complete = text
complete.label = 進捗率(%)
complete.order = 1
due_assign = text
due_assign.label = 開始予定日
due_assign.order = 2
due_assign.value = YYYY/MM/DD
due_close = text
due_close.label = 終了予定日
due_close.order = 3