[Web][Trac-0.12] 5.Trac拡張(ガントチャート)

Create: 2011/10/16
LastUpdate: 2012/10/30

ここでは、XenServer6環境の仮想マシン(CentOS5.7 x86_64)を使用しています。

この章では、Trac-0.12.2.ja1 にプラグインをインストールして機能拡張します。
ここで扱うプラグインは、ガントチャートを表示できるようにする TracGanttCalendarPlugin です。

以下、作業で参考にしたサイトです。

[参考サイト]

 

 

5.1.TracGanttCalendarPlugin のインストール

プラグインのソースをチェックアウトします。

# cd /root
# svn co http://svn.sourceforge.jp/svnroot/shibuya-trac/plugins/ganttcalendarplugin

ソースのディレクトリに移動してビルドします。

# cd /root/ganttcalendarplugin/trunk
# python setup.py bdist_egg
Got l10n_cmdclass

running bdist_egg
running egg_info
creating TracGanttCalendarPlugin.egg-info
writing TracGanttCalendarPlugin.egg-info/PKG-INFO
writing top-level names to TracGanttCalendarPlugin.egg-info/top_level.txt
writing dependency_links to TracGanttCalendarPlugin.egg-info/dependency_links.txt
writing entry points to TracGanttCalendarPlugin.egg-info/entry_points.txt
writing manifest file 'TracGanttCalendarPlugin.egg-info/SOURCES.txt'
writing manifest file 'TracGanttCalendarPlugin.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running compile_catalog
compiling catalog 'ganttcalendar/locale/ko/LC_MESSAGES/ganttcalendar.po' to 'ganttcalendar/locale/ko/LC_MESSAGES/ganttcalendar.mo'
compiling catalog 'ganttcalendar/locale/ja/LC_MESSAGES/ganttcalendar.po' to 'ganttcalendar/locale/ja/LC_MESSAGES/ganttcalendar.mo'
compiling catalog 'ganttcalendar/locale/en/LC_MESSAGES/ganttcalendar.po' to 'ganttcalendar/locale/en/LC_MESSAGES/ganttcalendar.mo'
running build_py
creating build
creating build/lib
creating build/lib/ganttcalendar
copying ganttcalendar/holiday_ko.py -> build/lib/ganttcalendar
copying ganttcalendar/admin.py -> build/lib/ganttcalendar
copying ganttcalendar/ticketcalendar.py -> build/lib/ganttcalendar
copying ganttcalendar/complete_by_close.py -> build/lib/ganttcalendar
copying ganttcalendar/ticketvalidator.py -> build/lib/ganttcalendar
copying ganttcalendar/holiday_ja.py -> build/lib/ganttcalendar
copying ganttcalendar/__init__.py -> build/lib/ganttcalendar
copying ganttcalendar/ticketgantt.py -> build/lib/ganttcalendar
creating build/lib/ganttcalendar/templates
copying ganttcalendar/templates/admin_holiday.html -> build/lib/ganttcalendar/templates
copying ganttcalendar/templates/calendar.html -> build/lib/ganttcalendar/templates
copying ganttcalendar/templates/gantt.html -> build/lib/ganttcalendar/templates
creating build/lib/ganttcalendar/htdocs
creating build/lib/ganttcalendar/htdocs/img
copying ganttcalendar/htdocs/img/arrow_bw.png -> build/lib/ganttcalendar/htdocs/img
copying ganttcalendar/htdocs/img/zoom_out.png -> build/lib/ganttcalendar/htdocs/img
copying ganttcalendar/htdocs/img/arrow_to.png -> build/lib/ganttcalendar/htdocs/img
copying ganttcalendar/htdocs/img/arrow_from.png -> build/lib/ganttcalendar/htdocs/img
copying ganttcalendar/htdocs/img/zoom_out_g.png -> build/lib/ganttcalendar/htdocs/img
copying ganttcalendar/htdocs/img/package.png -> build/lib/ganttcalendar/htdocs/img
copying ganttcalendar/htdocs/img/zoom_in_g.png -> build/lib/ganttcalendar/htdocs/img
copying ganttcalendar/htdocs/img/zoom_in.png -> build/lib/ganttcalendar/htdocs/img
creating build/lib/ganttcalendar/htdocs/js
copying ganttcalendar/htdocs/js/query.js -> build/lib/ganttcalendar/htdocs/js
creating build/lib/ganttcalendar/locale
copying ganttcalendar/locale/messages.pot -> build/lib/ganttcalendar/locale
creating build/lib/ganttcalendar/locale/ko
creating build/lib/ganttcalendar/locale/ko/LC_MESSAGES
copying ganttcalendar/locale/ko/LC_MESSAGES/ganttcalendar.po -> build/lib/ganttcalendar/locale/ko/LC_MESSAGES
copying ganttcalendar/locale/ko/LC_MESSAGES/ganttcalendar.mo -> build/lib/ganttcalendar/locale/ko/LC_MESSAGES
creating build/lib/ganttcalendar/locale/ja
creating build/lib/ganttcalendar/locale/ja/LC_MESSAGES
copying ganttcalendar/locale/ja/LC_MESSAGES/ganttcalendar.po -> build/lib/ganttcalendar/locale/ja/LC_MESSAGES
copying ganttcalendar/locale/ja/LC_MESSAGES/ganttcalendar.mo -> build/lib/ganttcalendar/locale/ja/LC_MESSAGES
creating build/lib/ganttcalendar/locale/en
creating build/lib/ganttcalendar/locale/en/LC_MESSAGES
copying ganttcalendar/locale/en/LC_MESSAGES/ganttcalendar.po -> build/lib/ganttcalendar/locale/en/LC_MESSAGES
copying ganttcalendar/locale/en/LC_MESSAGES/ganttcalendar.mo -> build/lib/ganttcalendar/locale/en/LC_MESSAGES
creating build/bdist.linux-x86_64
creating build/bdist.linux-x86_64/egg
creating build/bdist.linux-x86_64/egg/ganttcalendar
copying build/lib/ganttcalendar/holiday_ko.py -> build/bdist.linux-x86_64/egg/ganttcalendar
creating build/bdist.linux-x86_64/egg/ganttcalendar/templates
copying build/lib/ganttcalendar/templates/admin_holiday.html -> build/bdist.linux-x86_64/egg/ganttcalendar/templates
copying build/lib/ganttcalendar/templates/calendar.html -> build/bdist.linux-x86_64/egg/ganttcalendar/templates
copying build/lib/ganttcalendar/templates/gantt.html -> build/bdist.linux-x86_64/egg/ganttcalendar/templates
copying build/lib/ganttcalendar/admin.py -> build/bdist.linux-x86_64/egg/ganttcalendar
copying build/lib/ganttcalendar/ticketcalendar.py -> build/bdist.linux-x86_64/egg/ganttcalendar
creating build/bdist.linux-x86_64/egg/ganttcalendar/htdocs
creating build/bdist.linux-x86_64/egg/ganttcalendar/htdocs/img
copying build/lib/ganttcalendar/htdocs/img/arrow_bw.png -> build/bdist.linux-x86_64/egg/ganttcalendar/htdocs/img
copying build/lib/ganttcalendar/htdocs/img/zoom_out.png -> build/bdist.linux-x86_64/egg/ganttcalendar/htdocs/img
copying build/lib/ganttcalendar/htdocs/img/arrow_to.png -> build/bdist.linux-x86_64/egg/ganttcalendar/htdocs/img
copying build/lib/ganttcalendar/htdocs/img/arrow_from.png -> build/bdist.linux-x86_64/egg/ganttcalendar/htdocs/img
copying build/lib/ganttcalendar/htdocs/img/zoom_out_g.png -> build/bdist.linux-x86_64/egg/ganttcalendar/htdocs/img
copying build/lib/ganttcalendar/htdocs/img/package.png -> build/bdist.linux-x86_64/egg/ganttcalendar/htdocs/img
copying build/lib/ganttcalendar/htdocs/img/zoom_in_g.png -> build/bdist.linux-x86_64/egg/ganttcalendar/htdocs/img
copying build/lib/ganttcalendar/htdocs/img/zoom_in.png -> build/bdist.linux-x86_64/egg/ganttcalendar/htdocs/img
creating build/bdist.linux-x86_64/egg/ganttcalendar/htdocs/js
copying build/lib/ganttcalendar/htdocs/js/query.js -> build/bdist.linux-x86_64/egg/ganttcalendar/htdocs/js
copying build/lib/ganttcalendar/complete_by_close.py -> build/bdist.linux-x86_64/egg/ganttcalendar
copying build/lib/ganttcalendar/ticketvalidator.py -> build/bdist.linux-x86_64/egg/ganttcalendar
copying build/lib/ganttcalendar/holiday_ja.py -> build/bdist.linux-x86_64/egg/ganttcalendar
creating build/bdist.linux-x86_64/egg/ganttcalendar/locale
copying build/lib/ganttcalendar/locale/messages.pot -> build/bdist.linux-x86_64/egg/ganttcalendar/locale
creating build/bdist.linux-x86_64/egg/ganttcalendar/locale/ko
creating build/bdist.linux-x86_64/egg/ganttcalendar/locale/ko/LC_MESSAGES
copying build/lib/ganttcalendar/locale/ko/LC_MESSAGES/ganttcalendar.po -> build/bdist.linux-x86_64/egg/ganttcalendar/locale/ko/LC_MESSAGES
copying build/lib/ganttcalendar/locale/ko/LC_MESSAGES/ganttcalendar.mo -> build/bdist.linux-x86_64/egg/ganttcalendar/locale/ko/LC_MESSAGES
creating build/bdist.linux-x86_64/egg/ganttcalendar/locale/ja
creating build/bdist.linux-x86_64/egg/ganttcalendar/locale/ja/LC_MESSAGES
copying build/lib/ganttcalendar/locale/ja/LC_MESSAGES/ganttcalendar.po -> build/bdist.linux-x86_64/egg/ganttcalendar/locale/ja/LC_MESSAGES
copying build/lib/ganttcalendar/locale/ja/LC_MESSAGES/ganttcalendar.mo -> build/bdist.linux-x86_64/egg/ganttcalendar/locale/ja/LC_MESSAGES
creating build/bdist.linux-x86_64/egg/ganttcalendar/locale/en
creating build/bdist.linux-x86_64/egg/ganttcalendar/locale/en/LC_MESSAGES
copying build/lib/ganttcalendar/locale/en/LC_MESSAGES/ganttcalendar.po -> build/bdist.linux-x86_64/egg/ganttcalendar/locale/en/LC_MESSAGES
copying build/lib/ganttcalendar/locale/en/LC_MESSAGES/ganttcalendar.mo -> build/bdist.linux-x86_64/egg/ganttcalendar/locale/en/LC_MESSAGES
copying build/lib/ganttcalendar/__init__.py -> build/bdist.linux-x86_64/egg/ganttcalendar
copying build/lib/ganttcalendar/ticketgantt.py -> build/bdist.linux-x86_64/egg/ganttcalendar
byte-compiling build/bdist.linux-x86_64/egg/ganttcalendar/holiday_ko.py to holiday_ko.pyc
byte-compiling build/bdist.linux-x86_64/egg/ganttcalendar/admin.py to admin.pyc
byte-compiling build/bdist.linux-x86_64/egg/ganttcalendar/ticketcalendar.py to ticketcalendar.pyc
byte-compiling build/bdist.linux-x86_64/egg/ganttcalendar/complete_by_close.py to complete_by_close.pyc
byte-compiling build/bdist.linux-x86_64/egg/ganttcalendar/ticketvalidator.py to ticketvalidator.pyc
byte-compiling build/bdist.linux-x86_64/egg/ganttcalendar/holiday_ja.py to holiday_ja.pyc
byte-compiling build/bdist.linux-x86_64/egg/ganttcalendar/__init__.py to __init__.pyc
byte-compiling build/bdist.linux-x86_64/egg/ganttcalendar/ticketgantt.py to ticketgantt.pyc
creating build/bdist.linux-x86_64/egg/EGG-INFO
copying TracGanttCalendarPlugin.egg-info/PKG-INFO -> build/bdist.linux-x86_64/egg/EGG-INFO
copying TracGanttCalendarPlugin.egg-info/SOURCES.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying TracGanttCalendarPlugin.egg-info/dependency_links.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying TracGanttCalendarPlugin.egg-info/entry_points.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
copying TracGanttCalendarPlugin.egg-info/top_level.txt -> build/bdist.linux-x86_64/egg/EGG-INFO
zip_safe flag not set; analyzing archive contents...
ganttcalendar.ticketgantt: module references __file__
ganttcalendar.ticketcalendar: module references __file__
creating dist
creating 'dist/TracGanttCalendarPlugin-0.6.1_r802-py2.4.egg' and adding 'build/bdist.linux-x86_64/egg' to it
removing 'build/bdist.linux-x86_64/egg' (and everything under it)

出来上がった eggファイルを Trac の plugins ディレクトリにコピーします。

# cp dist/TracGanttCalendarPlugin-0.6.1_r802-py2.4.egg /home/trac/project1/plugins/.

※複数プロジェクトで使用したい場合は python setup.py install でインストールしたほうが良いかもしれません。

/home/trac/project1/conf/trac.ini に以下の定義を追加します。

  [ticket-custom]
  due_assign = text
  due_assign.label = 開始日
  due_assign.order = 1

  due_close= text
  due_close.label = 終了日
  due_close.order = 2

  complete= text
  complete.label = 進捗率(%)
  complete.order = 3

ブラウザで Trac を開くと、[カレンダー]と[ガントチャート]が追加されています。
それぞれ、クリックすると下図のように表示されます。

チケットの開始日と終了日を入力して登録すると下図のように表示されます。

管理コンソールには下図のようなカレンダーの祝日を設定するメニューもありますが、私の環境ではエラーが出て設定できませんでした。

[エラーメッセージ]
TypeError: cannot concatenate 'str' and 'NoneType' objects

ダウンロードしたソースを見ると、DBに "holiday"という名前でテーブルを作成して、休日を登録しているようです。試しに、以下のSQLを実行してテーブルを作成し、2011年と2012年の休日を登録してみることにしました。
ちなみに、CREATE UNIQUE INDEX のSQLは、ソースコードのオリジナルだとエラーになるので修正しています。(ASC を除いてる)

CREATE TABLE holiday (date TEXT, description TEXT);
CREATE UNIQUE INDEX idx_holiday ON holiday(date);
insert into holiday values ( '2011-01-01', '元日' );
insert into holiday values ( '2011-01-10', '成人の日' );
insert into holiday values ( '2011-02-11', '建国記念の日' );
insert into holiday values ( '2011-03-21', '春分の日' );
insert into holiday values ( '2011-04-29', '昭和の日' );
insert into holiday values ( '2011-05-03', '憲法記念日' );
insert into holiday values ( '2011-05-04', 'みどりの日' );
insert into holiday values ( '2011-05-05', 'こどもの日' );
insert into holiday values ( '2011-07-18', '海の日' );
insert into holiday values ( '2011-09-19', '敬老の日' );
insert into holiday values ( '2011-09-23', '秋分の日' );
insert into holiday values ( '2011-10-10', '体育の日' );
insert into holiday values ( '2011-11-03', '文化の日' );
insert into holiday values ( '2011-11-23', '勤労感謝の日' );
insert into holiday values ( '2011-12-23', '天皇誕生日' );
insert into holiday values ( '2012-01-01', '元日' );
insert into holiday values ( '2012-01-02', '振替休日' );
insert into holiday values ( '2012-01-09', '成人の日' );
insert into holiday values ( '2012-02-11', '建国記念の日' );
insert into holiday values ( '2012-03-20', '春分の日' );
insert into holiday values ( '2012-04-29', '昭和の日' );
insert into holiday values ( '2012-04-30', '振替休日' );
insert into holiday values ( '2012-05-03', '憲法記念日' );
insert into holiday values ( '2012-05-04', 'みどりの日' );
insert into holiday values ( '2012-05-05', 'こどもの日' );
insert into holiday values ( '2012-07-16', '海の日' );
insert into holiday values ( '2012-09-17', '敬老の日' );
insert into holiday values ( '2012-09-22', '秋分の日' );
insert into holiday values ( '2012-10-08', '体育の日' );
insert into holiday values ( '2012-11-03', '文化の日' );
insert into holiday values ( '2012-11-23', '勤労感謝の日' );
insert into holiday values ( '2012-12-23', '天皇誕生日' );
insert into holiday values ( '2012-12-24', '振替休日' );

上記SQLは、holiday.txt ファイルに保存して、以下のように実行しました。

# psql -U trac_user -W tracdb < ./holiday.sql
Password for user trac_user:
CREATE TABLE
CREATE INDEX
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1
INSERT 0 1

管理コンソールを見ると、下図のように表示されます。画面からも休日を登録できます。

カレンダーを見ると、下図のように、休日はグレーで表示されます。

とりあえず、これで問題なく動きそうなので、しばらく様子見です。