blob: 192554aa82a11ad47ac68bfa7238749e4bd364a0 [file] [log] [blame]
Scott Bakerc97b56d2014-11-06 17:38:38 -08001from django.db import models
Scott Baker12113342015-02-10 15:44:30 -08002from core.models import User, Service, SingletonModel, PlCoreBase
Scott Bakerc97b56d2014-11-06 17:38:38 -08003import 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 Baker90adeca2014-11-06 23:41:32 -080019 def __unicode__(self):
20 return self.name
21
Scott Bakerc97b56d2014-11-06 17:38:38 -080022class CompositionServiceThrough(PlCoreBase):
23 class Meta:
24 app_label = "servcomp"
Scott Baker90adeca2014-11-06 23:41:32 -080025 ordering = ("order", )
Scott Bakerc97b56d2014-11-06 17:38:38 -080026
Scott Baker90adeca2014-11-06 23:41:32 -080027 composition = models.ForeignKey(Composition)
28 service = models.ForeignKey(Service, related_name="compositions")
Scott Bakerc97b56d2014-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 Baker90adeca2014-11-06 23:41:32 -080041 def __unicode__(self):
42 return self.email
43