def _get_festival_names(self): """ return list of (short_name, name) tuples of associated festivals """ from film20.festivals.models import Festival festivals = dict((f.tag, (f.short_name or f.name, f.name)) for f in Festival.get_open_festivals()) tags = set(t.name for t in Tag.objects.get_for_object(self)) tags.intersection_update(festivals.keys()) return [ festivals[t] for t in tags ]
def get_hashtags(self, film): if not film: return '' loc = film.get_localized_object() from film20.festivals.models import Festival festival_tags = dict( (f.tag.lower(), f.hashtag) for f in Festival.get_open_festivals() ) film_tags = [t.strip() for t in (film.get_tags() or '').split(',') if t.strip()] hash_tags = [festival_tags.get(t.lower()) for t in film_tags] return ' '.join('#'+t for t in hash_tags if t)