summaryrefslogtreecommitdiff
path: root/coip/apps/consumer/models.py
blob: 7386638f8f9f141124349f0228060a1b5355422a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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()], 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)