Skip to content

Commit

Permalink
Merge pull request #101 from tylerneu/new_object
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerneu authored Aug 4, 2023
2 parents a221fc8 + 79b889b commit addd3af
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions ambition_utils/docs/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
Release Notes
=============

3.1.9
-----
* next_occurernce is only offset on save() if the object is new.
* clone_with_day_offset no longer calls clone() to ensure the clone is not saved with an id before day_offset is set.

3.1.8
-----
* Added RRule.day_offset to support true offset support. clone_with_day_offset method now sets day_offset.
Expand Down
8 changes: 5 additions & 3 deletions ambition_utils/rrule/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -364,8 +364,8 @@ def set_date_objects(self):
# Convert back to utc before saving
self.next_occurrence = self.convert_to_utc(self.next_occurrence)

# Offset, if applicable, for old and new.
self.next_occurrence = self.offset(self.next_occurrence)
# Offset, if applicable, for new objects.
self.next_occurrence = self.offset(self.next_occurrence)

def set_date_objects_for_params(self, params, is_new=False):
"""
Expand Down Expand Up @@ -468,9 +468,11 @@ def clone(self) -> RRule:
def clone_with_day_offset(self, day_offset: int) -> RRule:
"""
Creates a clone of a passed RRule object with day_offset set.
clone() is not called to ensure .id is not set before .save() so offset is applied.
:param day_offset: The number of days to offset the clone's start date. Can be negative.
"""
clone = self.clone()
clone = copy.deepcopy(self)
clone.id = None
clone.day_offset = day_offset
clone.save()
return clone
Expand Down
2 changes: 1 addition & 1 deletion ambition_utils/version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '3.1.8'
__version__ = '3.1.9'

0 comments on commit addd3af

Please sign in to comment.