diff options
Diffstat (limited to 'servo/models')
-rw-r--r-- | servo/models/device.py | 9 |
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): |