comparison doc/customizing.txt @ 3818:e5043875a03d

Improved due_date and timelog customisation docs [SF#1625124]
author Richard Jones <richard@users.sourceforge.net>
date Thu, 15 Feb 2007 03:58:35 +0000
parents aef19fff38dd
children a48c514c465f
comparison
equal deleted inserted replaced
3817:ce2c88d83eb6 3818:e5043875a03d
1 =================== 1 ===================
2 Customising Roundup 2 Customising Roundup
3 =================== 3 ===================
4 4
5 :Version: $Revision: 1.216 $ 5 :Version: $Revision: 1.217 $
6 6
7 .. This document borrows from the ZopeBook section on ZPT. The original is at: 7 .. This document borrows from the ZopeBook section on ZPT. The original is at:
8 http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx 8 http://www.zope.org/Documentation/Books/ZopeBook/current/ZPT.stx
9 9
10 .. contents:: 10 .. contents::
2890 You add new fields by editing the ``schema.py`` file in you tracker's home. 2890 You add new fields by editing the ``schema.py`` file in you tracker's home.
2891 Schema changes are automatically applied to the database on the next 2891 Schema changes are automatically applied to the database on the next
2892 tracker access (note that roundup-server would need to be restarted as it 2892 tracker access (note that roundup-server would need to be restarted as it
2893 caches the schema). 2893 caches the schema).
2894 2894
2895 1. modify the ``schema.py``:: 2895 1. Modify the ``schema.py``::
2896 2896
2897 issue = IssueClass(db, "issue", 2897 issue = IssueClass(db, "issue",
2898 assignedto=Link("user"), topic=Multilink("keyword"), 2898 assignedto=Link("user"), topic=Multilink("keyword"),
2899 priority=Link("priority"), status=Link("status"), 2899 priority=Link("priority"), status=Link("status"),
2900 due_date=Date()) 2900 due_date=Date())
2901 2901
2902 2. add an edit field to the ``issue.item.html`` template:: 2902 2. Add an edit field to the ``issue.item.html`` template::
2903 2903
2904 <tr> 2904 <tr>
2905 <th>Due Date</th> 2905 <th>Due Date</th>
2906 <td tal:content="structure context/due_date/field" /> 2906 <td tal:content="structure context/due_date/field" />
2907 </tr> 2907 </tr>
2908 2908
2909 3. add the property to the ``issue.index.html`` page:: 2909 If you want to show only the date part of due_date then do this instead::
2910
2911 <tr>
2912 <th>Due Date</th>
2913 <td tal:content="structure python:context.due_date.field(format='%Y-%m-%d')" />
2914 </tr>
2915
2916 3. Add the property to the ``issue.index.html`` page::
2910 2917
2911 (in the heading row) 2918 (in the heading row)
2912 <th tal:condition="request/show/due_date">Due Date</th> 2919 <th tal:condition="request/show/due_date">Due Date</th>
2913 (in the data row) 2920 (in the data row)
2914 <td tal:condition="request/show/due_date" tal:content="i/due_date" /> 2921 <td tal:condition="request/show/due_date"
2915 2922 tal:content="i/due_date" />
2916 4. add the property to the ``issue.search.html`` page:: 2923
2924 If you want format control of the display of the due date you can
2925 enter the following in the data row to show only the actual due date::
2926
2927 <td tal:condition="request/show/due_date"
2928 tal:content="python:i.due_date.pretty('%Y-%m-%d')">&nbsp;</td>
2929
2930 4. Add the property to the ``issue.search.html`` page::
2917 2931
2918 <tr tal:define="name string:due_date"> 2932 <tr tal:define="name string:due_date">
2919 <th i18n:translate="">Due Date:</th> 2933 <th i18n:translate="">Due Date:</th>
2920 <td metal:use-macro="search_input"></td> 2934 <td metal:use-macro="search_input"></td>
2921 <td metal:use-macro="column_input"></td> 2935 <td metal:use-macro="column_input"></td>
2922 <td metal:use-macro="sort_input"></td> 2936 <td metal:use-macro="sort_input"></td>
2923 <td metal:use-macro="group_input"></td> 2937 <td metal:use-macro="group_input"></td>
2924 </tr> 2938 </tr>
2925 2939
2926 5. if you wish for the due date to appear in the standard views listed 2940 5. If you wish for the due date to appear in the standard views listed
2927 in the sidebar of the web interface then you'll need to add "due_date" 2941 in the sidebar of the web interface then you'll need to add "due_date"
2928 to the columns and columns_showall lists in your ``page.html``. 2942 to the columns and columns_showall lists in your ``page.html``::
2929 2943
2944 columns string:id,activity,due_date,title,creator,status;
2945 columns_showall string:id,activity,due_date,title,creator,assignedto,status;
2930 2946
2931 Adding a new constrained field to the classic schema 2947 Adding a new constrained field to the classic schema
2932 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 2948 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2933 2949
2934 This example shows how to add a new constrained property (i.e. a 2950 This example shows how to add a new constrained property (i.e. a
3389 field to capture a new timelog item's period:: 3405 field to capture a new timelog item's period::
3390 3406
3391 <tr> 3407 <tr>
3392 <th>Time Log</th> 3408 <th>Time Log</th>
3393 <td colspan=3><input type="text" name="timelog-1@period" /> 3409 <td colspan=3><input type="text" name="timelog-1@period" />
3394 <br />(enter as '3y 1m 4d 2:40:02' or parts thereof) 3410 (enter as '3y 1m 4d 2:40:02' or parts thereof)
3395 </td> 3411 </td>
3396 </tr> 3412 </tr>
3397 3413
3398 and another hidden field that links that new timelog item (new 3414 and another hidden field that links that new timelog item (new
3399 because it's marked as having id "-1") to the issue item. It looks 3415 because it's marked as having id "-1") to the issue item. It looks
3402 <input type="hidden" name="@link@times" value="timelog-1" /> 3418 <input type="hidden" name="@link@times" value="timelog-1" />
3403 3419
3404 On submission, the "-1" timelog item will be created and assigned a 3420 On submission, the "-1" timelog item will be created and assigned a
3405 real item id. The "times" property of the issue will have the new id 3421 real item id. The "times" property of the issue will have the new id
3406 added to it. 3422 added to it.
3423
3424 The full entry will now look like this::
3425
3426 <tr>
3427 <th>Time Log</th>
3428 <td colspan=3><input type="text" name="timelog-1@period" />
3429 (enter as '3y 1m 4d 2:40:02' or parts thereof)
3430 <input type="hidden" name="@link@times" value="timelog-1" />
3431 </td>
3432 </tr>
3433
3407 3434
3408 4. We want to display a total of the timelog times that have been 3435 4. We want to display a total of the timelog times that have been
3409 accumulated for an issue. To do this, we'll need to actually write 3436 accumulated for an issue. To do this, we'll need to actually write
3410 some Python code, since it's beyond the scope of PageTemplates to 3437 some Python code, since it's beyond the scope of PageTemplates to
3411 perform such calculations. We do this by adding a module ``timespent.py`` 3438 perform such calculations. We do this by adding a module ``timespent.py``
3448 use of the ``totalTimeSpent`` method which will total up the times 3475 use of the ``totalTimeSpent`` method which will total up the times
3449 for the issue and return a new Interval. That will be automatically 3476 for the issue and return a new Interval. That will be automatically
3450 displayed in the template as text like "+ 1y 2:40" (1 year, 2 hours 3477 displayed in the template as text like "+ 1y 2:40" (1 year, 2 hours
3451 and 40 minutes). 3478 and 40 minutes).
3452 3479
3453 8. If you're using a persistent web server - ``roundup-server`` or 3480 6. If you're using a persistent web server - ``roundup-server`` or
3454 ``mod_python`` for example - then you'll need to restart that to pick up 3481 ``mod_python`` for example - then you'll need to restart that to pick up
3455 the code changes. When that's done, you'll be able to use the new 3482 the code changes. When that's done, you'll be able to use the new
3456 time logging interface. 3483 time logging interface.
3457 3484
3458 An extension of this modification attaches the timelog entries to any 3485 An extension of this modification attaches the timelog entries to any
3459 change message entered at the time of the timelog entry: 3486 change message entered at the time of the timelog entry:
3460 3487
3461 1. Add a link to the timelog to the msg class: 3488 A. Add a link to the timelog to the msg class in ``schema.py``:
3462 3489
3463 msg = FileClass(db, "msg", 3490 msg = FileClass(db, "msg",
3464 author=Link("user", do_journal='no'), 3491 author=Link("user", do_journal='no'),
3465 recipients=Multilink("user", do_journal='no'), 3492 recipients=Multilink("user", do_journal='no'),
3466 date=Date(), 3493 date=Date(),
3467 summary=String(), 3494 summary=String(),
3468 files=Multilink("file"), 3495 files=Multilink("file"),
3469 messageid=String(), 3496 messageid=String(),
3470 inreplyto=String() 3497 inreplyto=String(),
3471 times=Multilink("timelog")) 3498 times=Multilink("timelog"))
3472 3499
3473 2. Add a new hidden field that links that new timelog item (new 3500 B. Add a new hidden field that links that new timelog item (new
3474 because it's marked as having id "-1") to the new message. 3501 because it's marked as having id "-1") to the new message.
3475 It looks like this:: 3502 The link is placed in ``issue.item.html`` in the same section that
3476 3503 handles the timelog entry.
3477 <input type="hidden" name="msg-1@link@times" value="timelog-1" /> 3504
3505 It looks like this after this addition::
3506
3507 <tr>
3508 <th>Time Log</th>
3509 <td colspan=3><input type="text" name="timelog-1@period" />
3510 (enter as '3y 1m 4d 2:40:02' or parts thereof)
3511 <input type="hidden" name="@link@times" value="timelog-1" />
3512 <input type="hidden" name="msg-1@link@times" value="timelog-1" />
3513 </td>
3514 </tr>
3478 3515
3479 The "times" property of the message will have the new id added to it. 3516 The "times" property of the message will have the new id added to it.
3480 3517
3481 3. Add the timelog listing from step 5. to the ``msg.item.html`` template 3518 C. Add the timelog listing from step 5. to the ``msg.item.html`` template
3482 so that the timelog entry appears on the message view page. 3519 so that the timelog entry appears on the message view page. Note that
3520 the call to totalTimeSpent is not used here since there will only be one
3521 single timelog entry for each message.
3522
3523 I placed it after the Date entry like this::
3524
3525 <tr>
3526 <th i18n:translate="">Date:</th>
3527 <td tal:content="context/date"></td>
3528 </tr>
3529 </table>
3530
3531 <table class="otherinfo" tal:condition="context/times">
3532 <tr><th colspan="3" class="header">Time Log</th></tr>
3533 <tr><th>Date</th><th>Period</th><th>Logged By</th></tr>
3534 <tr tal:repeat="time context/times">
3535 <td tal:content="time/creation"></td>
3536 <td tal:content="time/period"></td>
3537 <td tal:content="time/creator"></td>
3538 </tr>
3539 </table>
3540
3541 <table class="messages">
3483 3542
3484 3543
3485 Tracking different types of issues 3544 Tracking different types of issues
3486 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 3545 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3487 3546

Roundup Issue Tracker: http://roundup-tracker.org/