fix typo in data/signals.py
[mygpo.git] / mygpo / data / signals.py
blob37c86b6da7e312671bcac98c350287f48f8bc650
1 from django.db.models.signals import post_save, pre_delete
2 from mygpo.data.models import DirectoryEntry
3 from mygpo.data.directory import get_source_weights, get_weighted_tags, get_weighted_group_tags
6 def update_podcast_tag_entry(sender, instance=False, **kwargs):
8 if not instance:
9 return
11 source_weights = get_source_weights()
13 if not instance.podcast.group:
14 DirectoryEntry.objects.filter(podcast=instance.podcast).delete()
16 for tag, weight in get_weighted_tags(instance.podcast, source_weights).iteritems():
17 if weight == 0:
18 continue
20 DirectoryEntry.objects.create(podcast=instance.podcast, tag=tag, ranking=weight)
22 else:
23 DirectoryEntry.objects.filter(podcast_group=instance.podcast.group).delete()
25 for tag, weight in get_weighted_group_tags(instance.podcast.group, source_weights).iteritems():
26 if weight == 0:
27 continue
29 DirectoryEntry.objects.create(podcast_group=instance.podcast.group, tag=tag, ranking=weight)