Example #1
0
 def get(self, request, *args, **kwargs):
     index = []
     for song in Song.items_live():
         index.append({
             "name": song.__str__(),
             "value": song.__str__(),
             "tokens": song.__str__().split(),
             "url": song.get_absolute_url()
         })
     return self.render_to_response({"index": index})
Example #2
0
 def get(self, request, *args, **kwargs):
     index = []
     for song in Song.items_live():
         index.append({
             'name': song.__str__(),
             'value': song.__str__(),
             'tokens': song.__str__().split(),
             'url': song.get_absolute_url()
         })
     return self.render_to_response({'index': index})
Example #3
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     authors = []
     for user in User.objects.filter(is_active=True):
         author = {}
         author['user'] = user
         author['annotations'] = SongNote.items_live().filter(
             author=user).count() + ArtistNote.items_live().filter(
                 author=user).count()
         author['songs'] = Song.items_live().filter(author=user).count()
         author['articles'] = Article.items_live().filter(
             author=user).count()
         author['total'] = (author['annotations'] + author['songs'] +
                            self.ARTICLE_FACTOR * author['articles'])
         if author['total']:
             authors.append(author)
     context['authors'] = sorted(
         authors, key=lambda k: k['total'], reverse=True)
     return context