Sapan Bhatia | 39c3a70 | 2015-01-23 16:11:51 +0000 | [diff] [blame] | 1 | def handle(image): |
| 2 | from core.models import Controller, ControllerImages, Image |
| 3 | from collections import defaultdict |
| 4 | |
| 5 | controller_images = ControllerImages.objects.filter(image=image) |
| 6 | existing_controllers = [cs.controller for cs in controller_images] |
| 7 | |
| 8 | all_controllers = Controller.objects.all() |
| 9 | for controller in all_controllers: |
| 10 | if controller not in existing_controllers: |
| 11 | sd = ControllerImages(image=image, controller=controller) |
| 12 | sd.save() |
| 13 | |