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()], max_length=255) lastupdated = models.DateTimeField(auto_now=True) timecreated = models.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)