+ @staticmethod
+ def tags_from_info(info):
+ from slughifi import slughifi
+ from sortify import sortify
+ meta_tags = []
+ categories = (('kinds', 'kind'), ('genres', 'genre'), ('authors', 'author'), ('epochs', 'epoch'))
+ for field_name, category in categories:
+ try:
+ tag_names = getattr(info, field_name)
+ except:
+ tag_names = [getattr(info, category)]
+ for tag_name in tag_names:
+ tag_sort_key = tag_name
+ if category == 'author':
+ tag_sort_key = tag_name.last_name
+ tag_name = ' '.join(tag_name.first_names) + ' ' + tag_name.last_name
+ tag, created = Tag.objects.get_or_create(slug=slughifi(tag_name), category=category)
+ if created:
+ tag.name = tag_name
+ tag.sort_key = sortify(tag_sort_key.lower())
+ tag.save()
+ meta_tags.append(tag)
+ return meta_tags
+
+