Modify

Opened 6 years ago

Last modified 5 years ago

#2880 new enhancement

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

Reported by: octavian Owned by: coling
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 6 years ago.
Updated patch for custom fields update

Download all attachments as: .zip

Change History (12)

comment:1 Changed 6 years ago by coling

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 6 years ago by octavian

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

comment:3 Changed 6 years ago by coling

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 follow-up: Changed 6 years ago by 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 :)

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 ; follow-up: Changed 6 years ago by 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 :)

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 6 years ago by octavian

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 6 years ago by octavian

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 follow-up: Changed 6 years ago by 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. :)

comment:9 in reply to: ↑ 8 Changed 6 years ago by octavian

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 6 years ago by octavian

Updated patch for custom fields update

comment:10 Changed 6 years ago by octavian

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 5 years ago by anonymous

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

Add Comment

Modify Ticket

Action
as new .
Author


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

 
Note: See TracTickets for help on using tickets.