Scott Baker | c97b56d | 2014-11-06 17:38:38 -0800 | [diff] [blame] | 1 | from django.db import models |
| 2 | from core.models import User, Service, SingletonModel, PlCoreBase, DiffModelMixIn |
| 3 | import os |
| 4 | from django.db import models |
| 5 | from django.forms.models import model_to_dict |
| 6 | |
| 7 | class CompositionService(SingletonModel,Service): |
| 8 | class Meta: |
| 9 | app_label = "servcomp" |
| 10 | verbose_name = "Service Composition Service" |
| 11 | |
| 12 | class Composition(PlCoreBase): |
| 13 | class Meta: |
| 14 | app_label = "servcomp" |
| 15 | |
| 16 | name = models.CharField(max_length=255); |
| 17 | services = models.ManyToManyField(Service, through='CompositionServiceThrough', blank=True); |
| 18 | |
Scott Baker | 90adeca | 2014-11-06 23:41:32 -0800 | [diff] [blame] | 19 | def __unicode__(self): |
| 20 | return self.name |
| 21 | |
Scott Baker | c97b56d | 2014-11-06 17:38:38 -0800 | [diff] [blame] | 22 | class CompositionServiceThrough(PlCoreBase): |
| 23 | class Meta: |
| 24 | app_label = "servcomp" |
Scott Baker | 90adeca | 2014-11-06 23:41:32 -0800 | [diff] [blame] | 25 | ordering = ("order", ) |
Scott Baker | c97b56d | 2014-11-06 17:38:38 -0800 | [diff] [blame] | 26 | |
Scott Baker | 90adeca | 2014-11-06 23:41:32 -0800 | [diff] [blame] | 27 | composition = models.ForeignKey(Composition) |
| 28 | service = models.ForeignKey(Service, related_name="compositions") |
Scott Baker | c97b56d | 2014-11-06 17:38:38 -0800 | [diff] [blame] | 29 | order = models.IntegerField(default=0) |
| 30 | |
| 31 | class EndUser(PlCoreBase): |
| 32 | class Meta: |
| 33 | app_label = "servcomp" |
| 34 | |
| 35 | email = models.CharField(max_length=255) |
| 36 | firstName = models.CharField(max_length=80) |
| 37 | lastName = models.CharField(max_length=80) |
| 38 | macAddress = models.CharField(max_length=80) |
| 39 | composition = models.ForeignKey(Composition, related_name="endUsers", blank=True, null=True) |
| 40 | |
Scott Baker | 90adeca | 2014-11-06 23:41:32 -0800 | [diff] [blame] | 41 | def __unicode__(self): |
| 42 | return self.email |
| 43 | |