Fix state role not always updated due to lazy properties

This commit is contained in:
ErikKalkoken
2020-07-02 21:26:40 +02:00
parent 3bab349d7b
commit 4d546f948d
7 changed files with 57 additions and 23 deletions

View File

@@ -73,11 +73,17 @@ class UserProfile(models.Model):
if commit:
logger.info('Updating {} state to {}'.format(self.user, self.state))
self.save(update_fields=['state'])
notify(self.user, _('State Changed'),
_('Your user state has been changed to %(state)s') % ({'state': state}),
'info')
notify(
self.user,
_('State Changed'),
_('Your user state has been changed to %(state)s')
% ({'state': state}),
'info'
)
from allianceauth.authentication.signals import state_changed
state_changed.send(sender=self.__class__, user=self.user, state=self.state)
state_changed.send(
sender=self.__class__, user=self.user, state=self.state
)
def __str__(self):
return str(self.user)