Example #1
0
def _rewrite_lyrics(match):
    template_name = "songs/lyrics_example.html"
    input_lyrics = '\n'.join(line.strip() for line in
                             str(match.group(1)).split('\n'))
    output_lyrics = render_lyrics(input_lyrics)
    return loader.get_template(template_name).render(
        Context({"input_lyrics": input_lyrics,
                 "output_lyrics": output_lyrics}))
Example #2
0
 def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     if 'transposition' in self.kwargs:
         context['json'] = True
         transposition = int(self.kwargs['transposition'])
         context['transposition'] = transposition
     else:
         transposition = 0
     context['lyrics'] = render_lyrics(self.object.lyrics, transposition)
     context['notes'] = SongNote.items_visible_to(self.request.user).filter(
         song=self.object)
     context['mentions'] = SongMention.objects.filter(song=self.object)
     return context