Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mapping of TimeEntry's Project field is broken #327

Closed
sjvrijn opened this issue Jun 30, 2024 · 0 comments · Fixed by #328
Closed

Mapping of TimeEntry's Project field is broken #327

sjvrijn opened this issue Jun 30, 2024 · 0 comments · Fixed by #328

Comments

@sjvrijn
Copy link
Contributor

sjvrijn commented Jun 30, 2024

Requesting the pid of a retrieved TimeEntry no longer works. After some searching it seems the mapping broke since a time entry no longer seems to report a project_id, but a pid instead..

Reproducible example:

from datetime import datetime
from toggl import api, utils

config = utils.Config.factory(None)
with open('.toggl-api-rc') as f:
    config.api_token = f.read().strip()

# Sample date with some time entries assigned to projects
date = (2024, 6, 27)
start, end = datetime(*date, 0), datetime(*date, 23)
entry = list(api.TimeEntry.objects.all_from_reports(config=config, start=start, stop=end))[0]
>>> entry.pid
[Traceback ...]
AttributeError: 'TimeEntry' object has no attribute 'pid'
>>> entry.project_id
[Traceback ...]
AttributeError: 'TimeEntry' object has no attribute 'project_id'
>>> entry.project
[Traceback ...]
AttributeError: Instance <entry description> (#3506117392) has not set mapping field 'project'/'project_id'

Replacing this in line 845 of api/models.py fixes the problem:

project = fields.MappingField(Project, 'project_id')

# After change
>>> entry.pid
193715611
>>> entry.project.id
193715611
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant