[go: up one dir, main page]

Skip to content

Commit

Permalink
Do not create link to event if taken from linked calendar
Browse files Browse the repository at this point in the history
  • Loading branch information
keul committed Apr 10, 2024
1 parent d172530 commit 86cbf37
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ History
0.7.1 (unreleased)
------------------

- report event selection: if user is in invited list, add the event only if she/he accepted or not answered
- read event selection: if user is in invited list, add the event only if she/he accepted or not answered
- read events: do not put event id (I action flag) when event cames from a linked calendar


0.7.0 (2024-04-09)
Expand Down
9 changes: 5 additions & 4 deletions haunts/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,15 @@ def extract_events(config_dir, sheet, day):
all_events.extend(new_events)

# Get calendar configurations
calendar_names = get_calendars_names(sheet_service)
calendar_names = get_calendars_names(sheet_service, flat=False)

# Main operation loop
for event in all_events:
event_summary = event.get("summary", "No summary")
start = event["start"].get("dateTime", event["start"].get("date"))
end = event["end"].get("dateTime", event["end"].get("date"))
project = calendar_names[event["calendar_id"]]
project = calendar_names[event["calendar_id"]]["alias"]
is_linked = calendar_names[event["calendar_id"]]["is_linked"]

start_date = datetime.fromisoformat(start).date()
start_time = datetime.fromisoformat(start).time()
Expand All @@ -111,7 +112,7 @@ def extract_events(config_dir, sheet, day):
project_col=project,
activity_col=event_summary,
details_col=event.get("description", ""),
event_id_col=event["id"],
event_id_col=event["id"] if not is_linked else "",
link_col=event.get("htmlLink", ""),
action_col="I",
action_col="I" if not is_linked else "",
)
8 changes: 5 additions & 3 deletions haunts/spreadsheet.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,10 +263,10 @@ def get_calendars(sheet, ignore_alias=False, use_read_col=False):
return configured_calendars


def get_calendars_names(sheet):
def get_calendars_names(sheet, flat=True):
"""Get all calendars names, giving precedence to alias defined in column "linked_calendar".
If aliases are found, the first one will be used
If multiple aliases are found, the first one will be used
"""
RANGE = f"{get('CONTROLLER_SHEET_NAME', 'config')}!A2:C"
calendars = (
Expand All @@ -285,7 +285,9 @@ def get_calendars_names(sheet):
linked_id = None
if names.get(linked_id) or (names.get(id) and not linked_id):
continue
names[linked_id or id] = alias
names[linked_id or id] = (
alias if flat else {"alias": alias, "is_linked": bool(linked_id)}
)
return names


Expand Down

0 comments on commit 86cbf37

Please sign in to comment.