def get_context_data(self, **kwargs): context = super(SongDisoveryView, self).get_context_data(**kwargs) event_type_pks = set( item['event__event'] for item in Service.objects.values('event__event') ) events = RegularEvent.objects.filter( pk__in=list(event_type_pks) ) all_songs_past_year = most_popular_songs() missing = {} for event in events: missing[event] = [] this_event = most_popular_songs( service_filter=event ).filter(usage__gte=1) this_event = [song.pk for song in this_event] for song in all_songs_past_year: if song.pk not in this_event: missing[event].append(song) context['missing'] = missing return context
def get_context_data(self, **kwargs): context = super(ServiceIndexView, self).get_context_data(**kwargs) context["showing_all"] = self.kwargs["show_all"] context["top_five_songs"] = most_popular_songs()[:5] context["bands"] = Band.objects.all() musician_services = self.request.user.service_musicians.all() leader_services = self.request.user.service_set.all() all_service_pks = set([s.pk for s in musician_services] + [s.pk for s in leader_services]) for service in context["service_list"]: service.user_is_involved = service.pk in all_service_pks active = [s.user_is_involved for s in context["service_list"]] context["active_in_some_services"] = any(active) return context
def get_context_data(self, **kwargs): context = super(ServiceIndexView, self).get_context_data(**kwargs) context['showing_all'] = self.kwargs['show_all'] context['top_five_songs'] = most_popular_songs()[:5] context['bands'] = Band.objects.all() musician_services = self.request.user.service_musicians.all() leader_services = self.request.user.service_set.all() all_service_pks = set( [s.pk for s in musician_services] + [s.pk for s in leader_services] ) for service in context['service_list']: service.user_is_involved = service.pk in all_service_pks active = [s.user_is_involved for s in context['service_list']] context['active_in_some_services'] = any(active) return context