Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
[plstackapi.git] / planetstack / servcomp / models.py
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
19     def __unicode__(self):
20         return self.name
21
22 class CompositionServiceThrough(PlCoreBase):
23     class Meta:
24         app_label = "servcomp"
25         ordering = ("order", )
26
27     composition = models.ForeignKey(Composition)
28     service = models.ForeignKey(Service, related_name="compositions")
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
41     def __unicode__(self):
42         return self.email
43