|
@@ -185,14 +185,24 @@ class User(BaseModel, AbstractBaseUser):
|
|
|
avatar = self.avatar.first()
|
|
|
if avatar:
|
|
|
avatar.delete()
|
|
|
- for outbox in User.outboxes_for_update(self.id):
|
|
|
+ for outbox in self.outboxes_for_update():
|
|
|
outbox.save()
|
|
|
return super().delete()
|
|
|
|
|
|
+ def update(self, *args, **kwds):
|
|
|
+ with transaction.atomic(), in_test_psql_role_override("postgres"):
|
|
|
+ for outbox in self.outboxes_for_update():
|
|
|
+ outbox.save()
|
|
|
+ return super().update(*args, **kwds)
|
|
|
+
|
|
|
def save(self, *args, **kwargs):
|
|
|
- if not self.username:
|
|
|
- self.username = self.email
|
|
|
- return super().save(*args, **kwargs)
|
|
|
+ with transaction.atomic(), in_test_psql_role_override("postgres"):
|
|
|
+ if not self.username:
|
|
|
+ self.username = self.email
|
|
|
+ result = super().save(*args, **kwargs)
|
|
|
+ for outbox in self.outboxes_for_update():
|
|
|
+ outbox.save()
|
|
|
+ return result
|
|
|
|
|
|
def has_perm(self, perm_name):
|
|
|
warnings.warn("User.has_perm is deprecated", DeprecationWarning)
|
|
@@ -278,8 +288,11 @@ class User(BaseModel, AbstractBaseUser):
|
|
|
for email in email_list:
|
|
|
self.send_confirm_email_singular(email, is_new_user)
|
|
|
|
|
|
+ def outboxes_for_update(self) -> List[ControlOutbox]:
|
|
|
+ return User.outboxes_for_user_update(self.id)
|
|
|
+
|
|
|
@staticmethod
|
|
|
- def outboxes_for_update(identifier: int) -> List[ControlOutbox]:
|
|
|
+ def outboxes_for_user_update(identifier: int) -> List[ControlOutbox]:
|
|
|
return [
|
|
|
ControlOutbox(
|
|
|
shard_scope=OutboxScope.USER_SCOPE,
|