diff options
author | Filipp Lepalaan <f@230.to> | 2013-11-08 09:31:01 +0200 |
---|---|---|
committer | Filipp Lepalaan <f@230.to> | 2013-11-08 09:31:01 +0200 |
commit | f077badf3163fc36c111dc45fe8d7d6f57d8712a (patch) | |
tree | f2b83bdc836f8a8035badb0d401ee0ea86eafa55 /apps/core/models.py | |
parent | b9fc1060406a433473faa70c236ba3e177640d26 (diff) | |
download | motor.old-f077badf3163fc36c111dc45fe8d7d6f57d8712a.tar.gz motor.old-f077badf3163fc36c111dc45fe8d7d6f57d8712a.tar.bz2 motor.old-f077badf3163fc36c111dc45fe8d7d6f57d8712a.zip |
Merged motor and checkin
Diffstat (limited to 'apps/core/models.py')
-rw-r--r-- | apps/core/models.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/apps/core/models.py b/apps/core/models.py new file mode 100644 index 0000000..04d7582 --- /dev/null +++ b/apps/core/models.py @@ -0,0 +1,59 @@ +import uuid +from django.db import models +from django.contrib.contenttypes import generic +from django.contrib.auth.models import AbstractUser +from django.contrib.contenttypes.models import ContentType + +from django.template.defaultfilters import slugify + + +class ServiceProvider(models.Model): + uuid = models.CharField( + unique=True, + max_length=36, + default=lambda: str(uuid.uuid4()) + ) + BACKEND_CHOICES = ( + ('http', 'HTTP'), + ('smtp', 'SMTP'), + ('servo', 'Servo') + ) + backend_type = models.CharField( + max_length=6, + default='servo', + choices=BACKEND_CHOICES + ) + name = models.CharField( + max_length=128, + default='Apple Service Provider' + ) + http_url = models.URLField(null=True, blank=True) + http_username = models.CharField(max_length=128, null=True, blank=True) + http_password = models.CharField(max_length=128, null=True, blank=True) + smtp_address = models.EmailField(null=True, blank=True) + servo_url = models.URLField(null=True, blank=True) + + +class User(AbstractUser): + sp = models.ForeignKey(ServiceProvider, null=True) + + +class TaggedItem(models.Model): + "A generic tagged item" + tag = models.CharField(max_length=128) + slug = models.SlugField() + kind = models.CharField(max_length=64, default='') + + object_id = models.PositiveIntegerField() + content_type = models.ForeignKey(ContentType) + content_object = generic.GenericForeignKey("content_type", "object_id") + + def save(self, *args, **kwargs): + self.slug = slugify(self.tag) + super(TaggedItem, self).save(*args, **kwargs) + + def __unicode__(self): + return self.tag + + class Meta: + unique_together = ("content_type", "object_id", "tag",) |