Example #1
0
File: feed.py Project: daasara/riba
 def create_update_product_tags(self, product, tags):
     for tag_info in tags:
         tag_field = slugify(tag_info['value'])
         display_name = tag_info['value']
         tag_type = tag_info['type']
         try:
             tag = Tag.objects.using('default').get(tag = tag_field)
         except Tag.DoesNotExist:
             tag = Tag(display_name = display_name)
             tag.tag = tag_field
             tag.save(using='default')
         try:
             product_tag = ProductTags.objects.using('default').get(product = product, tag = tag, type = tag_type)
         except ProductTags.DoesNotExist:
             product_tag = ProductTags(product = product, tag = tag, type = tag_type)
             product_tag.save(using='default')