Skip to content

Commit

Permalink
feat: map parent_id to iCal's RELATED-TO (#15)
Browse files Browse the repository at this point in the history
* feat: map parent_id to ical's releated-to property

* docs: update property 'Parent ID' status to done
  • Loading branch information
eoleedi authored Apr 7, 2024
1 parent b4bef56 commit 6780cbe
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ Currently, TimeTree data can only be downloaded manually through a web browser.
- [x] **Recurrences**
- [ ] **Recurring UUID**
- [x] **Alerts**
- [ ] **Parent ID**
- [x] **Parent ID**
- [ ] **Link Object ID**
- [ ] **Link Object ID String**
- [ ] **Row Order**
Expand Down
3 changes: 3 additions & 0 deletions timetree_exporter/event.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __init__(
location_lat: str,
location_lon: str,
location: str,
parent_id: str,
):
# pylint: disable=too-many-arguments
# pylint: disable=too-many-locals
Expand All @@ -43,6 +44,7 @@ def __init__(
self.all_day = all_day
self.alerts = alerts
self.recurrences = recurrences
self.parent_id = parent_id

@classmethod
def from_dict(cls, event_data: dict):
Expand All @@ -64,6 +66,7 @@ def from_dict(cls, event_data: dict):
all_day=event_data.get("all_day"),
alerts=event_data.get("alerts"),
recurrences=event_data.get("recurrences"),
parent_id=event_data.get("parent_id"),
)

def __str__(self):
Expand Down
7 changes: 7 additions & 0 deletions timetree_exporter/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ def url(self):
"""Return the URL of the event."""
return self.time_tree_event.url if self.time_tree_event.url != "" else None

@property
def related_to(self):
"""Return the parent ID of the event."""
return self.time_tree_event.parent_id

def get_datetime(self, is_start_time):
"""Return the start or end time of the event."""
if is_start_time:
Expand Down Expand Up @@ -155,6 +160,8 @@ def to_ical(self) -> Event:
event.add("url", self.url)
if self.description:
event.add("description", self.description)
if self.related_to:
event.add("related-to", self.related_to)

for alert in self.alerts:
event.add_component(alert)
Expand Down

0 comments on commit 6780cbe

Please sign in to comment.