Jump to content

Tracking time out of project period


laura.c

Recommended Posts

Hi Carl,

 

Thanks for your answer.

 

I am thinking of another solution: I try to define an action on 'update' event, so, every time when the user tries to track time out of the project period, the input value will be switched to 0.

 

But I can't find a way to update the 'hours' field in a timeReports object and refresh the web ui . Any suggestions?

 

Thanks!

Laura

Link to comment
Share on other sites

Hi Laura,

 

Are you running version 2 of ftrack?

 

You should be able to listen on the update event and set the value to 0 if out of the project dates. Refreshing the web interface from the API is currently not possible.

 

Here is an quick example resetting time reports if the date is not within the project start and end.

import ftrackftrack.setup()def validate_time_report(topic, **kw):    '''Event callback to validate time reports.'''    entities = kw.get('entities', [])    for entity in entities:        if entity['entityType'] == 'taskworkedhours':            parent = ftrack.Task(entity['parents'][1]['entityId'])            project = parent.getProject()            reports = parent.getTimereports()            for report in reports:                if (                    report.get('date') < project.get('startdate') or                    report.get('date') > project.get('enddate')                ):                    report.set('hours', 0)# Subscribe to the update topic.ftrack.TOPICS.subscribe('update', validate_time_report)ftrack.TOPICS.wait()

Note that in ftrack 3 the API interface for handling timereports has changed.

 

Cheers,

Carl

Link to comment
Share on other sites

Hi Carl,

 

 

Thanks for the code. Very helpful!!!

 

Yes, we are using ftrack 2.

 

Refreshing web interface from API would be very helpful since we would like to implement actions when tasks/shots/asset builds are created/renamed for validating the names. Is it possible in ftrack 3?

 

 

 

Cheers,

Laura

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...