Skip to content

Commit ee0641c

Browse files
update the unapply method and add delete method to update generated title field to blank when a title pattern is deleted
1 parent 6ea0df5 commit ee0641c

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

sde_collections/models/pattern.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,15 @@ def apply(self) -> None:
196196
TitlePatternCandidateURL.objects.bulk_create(pattern_url_associations, ignore_conflicts=True)
197197

198198
def unapply(self) -> None:
199-
self.candidate_urls.update(generated_title="")
199+
candidate_urls = self.candidate_urls.all()
200+
for candidate_url in candidate_urls:
201+
candidate_url.generated_title = ""
202+
candidate_url.save()
203+
self.candidate_urls.clear()
204+
205+
def delete(self, *args, **kwargs):
206+
self.unapply()
207+
super().delete(*args, **kwargs)
200208

201209
class Meta:
202210
"""Meta definition for TitlePattern."""

0 commit comments

Comments
 (0)