display APIException errors properly
[plstackapi.git] / planetstack / core / models / tag.py
index 786b036..7818c32 100644 (file)
@@ -1,6 +1,7 @@
 import os
 from django.db import models
 from core.models import PlCoreBase
+from core.models import Service
 from django.contrib.contenttypes.models import ContentType
 from django.contrib.contenttypes import generic
 
@@ -8,6 +9,8 @@ from django.contrib.contenttypes import generic
 
 class Tag(PlCoreBase):
 
+    service = models.ForeignKey(Service, related_name='tags', help_text="The Service this Tag is associated with")
+
     name = models.SlugField(help_text="The name of this tag", max_length=128)
     value = models.CharField(help_text="The value of this tag", max_length=1024)
 
@@ -19,3 +22,12 @@ class Tag(PlCoreBase):
     def __unicode__(self):
         return self.name
 
+
+    def can_update(self, user):
+        if user.is_admin:
+            return True
+        return False
+
+    @staticmethod
+    def select_by_user(user):
+        return Tag.objects.all()