aboutsummaryrefslogtreecommitdiffstats
path: root/servo/models
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mac.com>2021-05-15 15:01:40 +0300
committerFilipp Lepalaan <filipp@mac.com>2021-05-15 15:01:40 +0300
commit08155df685f2d52cee1ec3ef0761e794f36a1bc6 (patch)
tree90713457be7c78a5f76a1a53f785d2866c3556a4 /servo/models
parent3af675351bbc1c2a8a652049d12e7b699744d730 (diff)
downloadServo-08155df685f2d52cee1ec3ef0761e794f36a1bc6.tar.gz
Servo-08155df685f2d52cee1ec3ef0761e794f36a1bc6.tar.bz2
Servo-08155df685f2d52cee1ec3ef0761e794f36a1bc6.zip
Fix adding device tags
Diffstat (limited to 'servo/models')
-rw-r--r--servo/models/device.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/servo/models/device.py b/servo/models/device.py
index 4688423..d994d20 100644
--- a/servo/models/device.py
+++ b/servo/models/device.py
@@ -157,8 +157,9 @@ class Device(models.Model):
parts_and_labor_covered = models.BooleanField(default=False, editable=False)
+ tags = GenericRelation(TaggedItem, null=True, blank=True)
notes = models.TextField(blank=True, default="", verbose_name=_("notes"))
- tags = GenericRelation(TaggedItem)
+
photo = models.ImageField(
null=True,
blank=True,
@@ -208,19 +209,21 @@ class Device(models.Model):
def tag_choices(self):
return TaggedItem.objects.filter(content_type__model="device").distinct("tag")
- def add_tags(self, tags):
+ def add_tags(self, tags: list):
tags = [x for x in tags if x != ''] # Filter out empty tags
if not tags:
return
content_type = ContentType.objects.get_for_model(Device)
-
+
for t in tags:
tag, created = TaggedItem.objects.get_or_create(content_type=content_type,
object_id=self.pk,
tag=t)
+
tag.save()
+
def get_icon(self):
if re.match('iPad', self.description):