2 from django.db import models
3 from core.models import PlCoreBase
4 from core.models import Service
5 from django.contrib.contenttypes.models import ContentType
6 from django.contrib.contenttypes import generic
8 # Create your models here.
10 class Tag(PlCoreBase):
12 service = models.ForeignKey(Service, related_name='tags', help_text="The Service this Tag is associated with")
14 name = models.SlugField(help_text="The name of this tag", max_length=128)
15 value = models.CharField(help_text="The value of this tag", max_length=1024)
17 # The required fields to do a ObjectType lookup, and object_id assignment
18 content_type = models.ForeignKey(ContentType)
19 object_id = models.PositiveIntegerField()
20 content_object = generic.GenericForeignKey('content_type', 'object_id')
22 def __unicode__(self):
26 def can_update(self, user):
32 def select_by_user(user):
33 return Tag.objects.all()