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

@@ -23,9 +23,7 @@ def trigger_state_check(state):
check_states = State.objects.filter(priority__lt=state.priority)
for profile in UserProfile.objects.filter(state__in=check_states):
if state.available_to_user(profile.user):
profile.state = state
profile.save(update_fields=['state'])
state_changed.send(sender=state.__class__, user=profile.user, state=state)
profile.assign_state(state)
@receiver(m2m_changed, sender=State.member_characters.through)