Scott Baker | af599eb | 2017-03-21 12:43:26 -0700 | [diff] [blame] | 1 | from synchronizers.new_base.modelaccessor import * |
Scott Baker | 46a3ee9 | 2017-05-30 16:44:56 -0700 | [diff] [blame] | 2 | from synchronizers.new_base.policy import Policy |
Scott Baker | af599eb | 2017-03-21 12:43:26 -0700 | [diff] [blame] | 3 | |
Scott Baker | 46a3ee9 | 2017-05-30 16:44:56 -0700 | [diff] [blame] | 4 | class 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 Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 11 | 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']) |