Skip to content

Commit

Permalink
Merge f90380e into 4b83de7
Browse files Browse the repository at this point in the history
  • Loading branch information
boulch committed Mar 22, 2023
2 parents 4b83de7 + f90380e commit b1c7988
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ Changelog
1.1.10 (unreleased)
-------------------

- Nothing changed yet.
- WEB-3902 : Sort events by start_date after expanded event occurences
[boulch]


1.1.9 (2023-03-17)
Expand Down
8 changes: 6 additions & 2 deletions src/imio/smartweb/core/contents/rest/events/endpoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
import dateutil


def get_start_date(event):
return datetime.fromisoformat(event["start"])


def expand_occurences(events):
expanded_events = []

Expand Down Expand Up @@ -50,8 +54,8 @@ def expand_occurences(events):
new_event["start"] = json_compatible(occurence_start)
new_event["end"] = json_compatible(occurence_start + duration)
expanded_events.append(new_event)

return expanded_events
expanded_events_sorted = sorted(expanded_events, key=get_start_date)
return expanded_events_sorted


class BaseEventsEndpoint(BaseEndpoint):
Expand Down

0 comments on commit b1c7988

Please sign in to comment.