blob: a46608347c913e6c31579b456dbcdd58f53ab91b [file] [log] [blame]
Matteo Scandolof5e10332017-08-08 13:05:25 -07001
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 Bavier89a95422016-11-02 14:38:39 -040017def handle(user):
18 from core.models import Controller, ControllerSite, ControllerUser, User
19 from collections import defaultdict
20
21 # user = User.get(user_id)
22
23 controller_users = ControllerUser.objects.filter(user=user)
24 existing_controllers = [cu.controller for cu in controller_users]
25 all_controllers = Controller.objects.all()
26 for controller in all_controllers:
27 if controller not in existing_controllers:
28 ctrl_user = ControllerUser(controller=controller, user=user)
29 ctrl_user.save()
30