blob: 3c17ffd5953b849c14de2082dd195e8e8be5660f [file] [log] [blame]
Scott Baker52649d62014-11-06 17:38:38 -08001from django.db import models
2from core.models import User, Service, SingletonModel, PlCoreBase, DiffModelMixIn
3import os
4from django.db import models
5from django.forms.models import model_to_dict
6
7class CompositionService(SingletonModel,Service):
8 class Meta:
9 app_label = "servcomp"
10 verbose_name = "Service Composition Service"
11
12class 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 Baker5d0fc7f2014-11-06 23:41:32 -080019 def __unicode__(self):
20 return self.name
21
Scott Baker52649d62014-11-06 17:38:38 -080022class CompositionServiceThrough(PlCoreBase):
23 class Meta:
24 app_label = "servcomp"
Scott Baker5d0fc7f2014-11-06 23:41:32 -080025 ordering = ("order", )
Scott Baker52649d62014-11-06 17:38:38 -080026
Scott Baker5d0fc7f2014-11-06 23:41:32 -080027 composition = models.ForeignKey(Composition)
28 service = models.ForeignKey(Service, related_name="compositions")
Scott Baker52649d62014-11-06 17:38:38 -080029 order = models.IntegerField(default=0)
30
31class 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 Baker5d0fc7f2014-11-06 23:41:32 -080041 def __unicode__(self):
42 return self.email
43