Matteo Scandolo | c48a0fc | 2018-01-31 11:38:11 -0800 | [diff] [blame^] | 1 | from xos.exceptions import XOSValidationError |
| 2 | |
| 3 | from models_decl import MCordSubscriberService_decl |
| 4 | from models_decl import MCordSubscriberInstance_decl |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | class MCordSubscriberService(MCordSubscriberService_decl): |
| 10 | class Meta: |
| 11 | proxy = True |
| 12 | |
| 13 | |
| 14 | class MCordSubscriberInstance(MCordSubscriberInstance_decl): |
| 15 | class Meta: |
| 16 | proxy = True |
| 17 | |
| 18 | def save(self, *args, **kwargs): |
| 19 | # NOTE someone is setting owner_id, so just override it for now |
| 20 | try: |
| 21 | mcord_service = MCordSubscriberService.objects.all()[0] |
| 22 | self.owner_id = mcord_service.id |
| 23 | except IndexError: |
| 24 | raise XOSValidationError("Service MCORD cannot be found, please make sure that the model exists.") |
| 25 | |
| 26 | super(MCordSubscriberInstance, self).save(*args, **kwargs) |