fix: Do not set update_fields when saving new instance

This commit is contained in:
Jennifer Richards 2023-05-19 14:36:08 -03:00
parent be25fb954b
commit 93e9f8e850
No known key found for this signature in database
GPG key ID: 9B2BF5C5ADDA6A6E
2 changed files with 4 additions and 5 deletions

View file

@ -573,7 +573,7 @@ class ResurrectTests(DraftFileMixin, TestCase):
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
q = PyQuery(r.content)
self.assertEqual(len(q('form [type=submit]')), 1)
self.assertEqual(len(q('#content form [type=submit]')), 1)
# request resurrect
@ -609,7 +609,7 @@ class ResurrectTests(DraftFileMixin, TestCase):
r = self.client.get(url)
self.assertEqual(r.status_code, 200)
q = PyQuery(r.content)
self.assertEqual(len(q('form [type=submit]')), 1)
self.assertEqual(len(q('#content form [type=submit]')), 1)
# complete resurrect
events_before = draft.docevent_set.count()

View file

@ -187,11 +187,10 @@ class NomineePosition(models.Model):
ordering = ['nominee']
def save(self, **kwargs):
update_fields = kwargs.pop("update_fields", None)
if not self.pk and not self.state_id:
# Don't need to set update_fields because the self.pk test means this is a new instance
self.state = NomineePositionStateName.objects.get(slug='pending')
update_fields = {"slug"}.union(update_fields or set())
super().save(update_fields=update_fields, **kwargs)
super().save(**kwargs)
def __str__(self):
return "%s - %s - %s" % (self.nominee, self.state, self.position)