Matteo Scandolo | f5e1033 | 2017-08-08 13:05:25 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Andy Bavier | 89a9542 | 2016-11-02 14:38:39 -0400 | [diff] [blame] | 17 | def handle(controller_user): |
| 18 | from core.models import ControllerUser, User |
| 19 | |
| 20 | try: |
| 21 | my_status_code = int(controller_user.backend_status[0]) |
| 22 | try: |
| 23 | his_status_code = int(controller_user.user.backend_status[0]) |
| 24 | except: |
| 25 | his_status_code = 0 |
| 26 | |
| 27 | if (my_status_code not in [0,his_status_code]): |
| 28 | controller_user.user.backend_status = controller_user.backend_status |
| 29 | controller_user.user.save(update_fields = ['backend_status']) |
| 30 | except Exception,e: |
| 31 | print str(e) |
| 32 | pass |