blob: 190fb6e6b3fe021cf2ab66a50c56935edfcc6aba [file] [log] [blame]
Scott Bakeraf599eb2017-03-21 12:43:26 -07001from synchronizers.new_base.modelaccessor import *
Scott Baker46a3ee92017-05-30 16:44:56 -07002from synchronizers.new_base.policy import Policy
Scott Bakeraf599eb2017-03-21 12:43:26 -07003
Scott Baker46a3ee92017-05-30 16:44:56 -07004class ControllerUserPolicy(Policy):
5 model_name = "ControllerUser"
6
7 def handle_create(self, controller_user):
8 return self.handle_update(controller_user)
9
10 def handle_update(self, controller_user):
Scott Bakerb63ea792016-08-11 10:24:48 -070011 my_status_code = int(controller_user.backend_status[0])
12 try:
13 his_status_code = int(controller_user.user.backend_status[0])
14 except:
15 his_status_code = 0
16
17 if (my_status_code not in [0,his_status_code]):
18 controller_user.user.backend_status = controller_user.backend_status
19 controller_user.user.save(update_fields = ['backend_status'])