Skip to content

Commit

Permalink
sponsors: implement better handling of benefit feature configuration …
Browse files Browse the repository at this point in the history
…naming (#2523)

When cloning benefits year-to-year, search/replace the year if it is part of the name. Otherwise continue to suffix... this stops the internal_id_2022_2023_2024_2025 nonsense.
  • Loading branch information
ewdurbin authored Sep 5, 2024
1 parent 2a45f8c commit 5cc25a0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sponsors/models/benefits.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,10 @@ def create_benefit_feature(self, sponsor_benefit, **kwargs):

def get_clone_kwargs(self, new_benefit):
kwargs = super().get_clone_kwargs(new_benefit)
kwargs["internal_name"] = f"{self.internal_name}_{new_benefit.year}"
if str(self.benefit.year) in self.internal_name:
kwargs["internal_name"] = self.internal_name.replace(str(self.benefit.year), str(new_benefit.year))
else:
kwargs["internal_name"] = f"{self.internal_name}_{new_benefit.year}"
due_date = kwargs.get("due_date")
if due_date:
kwargs["due_date"] = due_date.replace(year=new_benefit.year)
Expand Down

0 comments on commit 5cc25a0

Please sign in to comment.