Modify

Opened 10 years ago

Last modified 9 months ago

#2880 new enhancement

[Patch] Record time spent to a custom field (not only for TimingAndEstimationPlugin)

Reported by: Octavian Ciubotaru Owned by:
Priority: normal Component: WorkLogPlugin
Severity: normal Keywords:
Cc: Trac Release: 0.11

Description

It would be nice when you clock off to write time to custom field, as in case of TimingAndEstimationPlugin.

Having this custom fields in trac.ini:

[ticket-custom]
estimatedwork = text
estimatedwork.label = Estimated Work
estimatedwork.order = 1
estimatedwork.value = 0
workdone = text
workdone.label = Work done
workdone.order = 2
workdone.value = 0

To be able to add:

[worklog]
update_field = workdone

Attachments (1)

custom_ticket.diff (1.6 KB) - added by Octavian Ciubotaru 10 years ago.
Updated patch for custom fields update

Download all attachments as: .zip

Change History (13)

comment:1 Changed 10 years ago by Colin Guthrie

Sorry, I'm not really sure what you mean here. Worklog does this already.

It integrates with TimingAndEstimationPlugin to do exactly what you say. You have to enable this in the Admin page first tho'.

Or you mean it would be nice to have it log time without TimingAndEstimationPlugin installed?

comment:2 Changed 10 years ago by Octavian Ciubotaru

Yes, you're right! I want it to update custom field specified in config, without TimingAndEstimationPlugin installed.

comment:3 Changed 10 years ago by Colin Guthrie

OK, that's clearer then :)

I actually use the system inside TimingAndEstimationPlugin to do the cumulative totalling of hours so I'll have to duplicate this same system to achieve this goal.

It's not a bad idea tho', but I've got a couple other fish to fry first, so it wont happen immediately :D

comment:4 Changed 10 years ago by Octavian Ciubotaru

Here you can see my modification to allow writing to custom fields. I don't know python, if something is wrong tell me, I'll try to improve me :)

Unfortunately now I can't test it because of this issue:

Traceback (most recent call last):
  File "c:\python25\lib\site-packages\trac-0.11b2-py2.5.egg\trac\web\api.py", line 339, in send_error
    'text/html')
  File "c:\python25\lib\site-packages\trac-0.11b2-py2.5.egg\trac\web\chrome.py", line 672, in render_template
    template = self.load_template(filename, method=method)
  File "c:\python25\lib\site-packages\trac-0.11b2-py2.5.egg\trac\web\chrome.py", line 648, in load_template
    self.templates = TemplateLoader(self.get_all_templates_dirs(),
  File "c:\python25\lib\site-packages\trac-0.11b2-py2.5.egg\trac\web\chrome.py", line 402, in get_all_templates_dirs
    dirs += provider.get_templates_dirs()
  File "build\bdist.win32\egg\worklog\webui.py", line 183, in get_templates_dirs
    from pkg_resources import resource_filename
SystemError: Parent module 'worklog' not loaded

comment:5 in reply to:  4 ; Changed 10 years ago by Colin Guthrie

Replying to octavian:

Here you can see my modification to allow writing to custom fields. I don't know python, if something is wrong tell me, I'll try to improve me :)

Yeah, unfortunately the "hours" field in TimingAndEstimationPlugin is actually not a real field that is stored. It is intercepted by a ticket change listener in the TimingAndEstimationPlugin and the value in it is combined with the cumulative value (e.g. they are added together) to create a running total.

Your patch will continually update a single field. e.g. if you work for 2 hours and the ticket, stop for a while then go back later and work for 1 hour, the value you want to store is 3 hours but what will actually be stored is 1 hour (e.g. the last value). So there is a litte more work needed :)

Unfortunately now I can't test it because of this issue:

I thought I had fixed that yesterday... are you using the latest svn?

comment:6 in reply to:  5 Changed 10 years ago by Octavian Ciubotaru

Replying to coling:

Replying to octavian:

Here you can see my modification to allow writing to custom fields. I don't know python, if something is wrong tell me, I'll try to improve me :)

Yeah, unfortunately the "hours" field in TimingAndEstimationPlugin is actually not a real field that is stored. It is intercepted by a ticket change listener in the TimingAndEstimationPlugin and the value in it is combined with the cumulative value (e.g. they are added together) to create a running total.

Your patch will continually update a single field. e.g. if you work for 2 hours and the ticket, stop for a while then go back later and work for 1 hour, the value you want to store is 3 hours but what will actually be stored is 1 hour (e.g. the last value). So there is a litte more work needed :)

Thanks, I'll take into account this.

Unfortunately now I can't test it because of this issue:

I thought I had fixed that yesterday... are you using the latest svn?

Yes, rev 3490.

comment:7 Changed 10 years ago by Octavian Ciubotaru

I observed strange behavior of trac-admin /project/path upgrade. It does not make any upgrade, just printed Database is up to date, no upgrade necessary..

Maybe WorkLogPlugin does not support sqlite?

comment:8 Changed 10 years ago by Colin Guthrie

I test on SQLite so it does support it. No upgrade necessary is the expected behaviour if it's all up-to-date :)

If you inspect a debug log from trac, it should tell you why it can't load worklog. It could be you are not using trac 0.11 trunk. The changes I did yesterday updated things to work with latest trac trunk... I can't remember the exact change but it was one that renamed e.g. TicketAdminPage to TicketAdminPanel (and other similar ones). So you may have to update your Trac. :)

comment:9 in reply to:  8 Changed 10 years ago by Octavian Ciubotaru

Replying to coling:

I test on SQLite so it does support it. No upgrade necessary is the expected behaviour if it's all up-to-date :)

If you inspect a debug log from trac, it should tell you why it can't load worklog. It could be you are not using trac 0.11 trunk. The changes I did yesterday updated things to work with latest trac trunk... I can't remember the exact change but it was one that renamed e.g. TicketAdminPage to TicketAdminPanel (and other similar ones). So you may have to update your Trac. :)

Latest trac solved the problem, upgrade did the job and no more stack traces! Thanks.

Now I can concentrate on the right thing!

Changed 10 years ago by Octavian Ciubotaru

Attachment: custom_ticket.diff added

Updated patch for custom fields update

comment:10 Changed 10 years ago by Octavian Ciubotaru

Please see this patch. It works fine for me. I'm not that well at python, so I duplicated some lines of code. Maybe you should confider a little refactoring.

Thanks for the plugin. It is very useful!

comment:11 Changed 8 years ago by anonymous

Summary: Record time spent to a custom field (not only for TimingAndEstimationPlugin)[Patch] Record time spent to a custom field (not only for TimingAndEstimationPlugin)

comment:12 Changed 9 months ago by Ryan J Ollos

Owner: Colin Guthrie deleted

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The ticket will remain with no owner.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.