diff options
Diffstat (limited to 'coip/apps/consumer/models.py')
-rw-r--r-- | coip/apps/consumer/models.py | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/coip/apps/consumer/models.py b/coip/apps/consumer/models.py new file mode 100644 index 0000000..3585776 --- /dev/null +++ b/coip/apps/consumer/models.py @@ -0,0 +1,25 @@ +from django.contrib.auth.models import User +from django.db import models +from django.db.models import fields, ForeignKey, BooleanField +from tastypie.fields import DateTimeField +from coip.apps.name.models import Name +from coip.apps.consumer import consumer_providers, consumer_provider + +__author__ = 'leifj' + +class Consumer(models.Model): + name = ForeignKey(Name) + user = ForeignKey(User) + inherit = BooleanField(default=False) + consumer_name = fields.CharField(choices=[c.name for c in consumer_providers()]) + lastupdated = DateTimeField(auto_now=True) + timecreated = DateTimeField(auto_now_add=True) + + def __unicode_(self): + return "%s connected to %s" % (self.name,self.consumer_name) + + def _consumer_provider(self): + return consumer_provider(self.name) + + consumer_provider = property(_consumer_provider) + |