def get_queue(create_new=False): key = "nqueue" logger.debug("Getting cache for queue") R = cache.get(key) if not R or create_new: logger.info("No existing cache for queue, making new one") queue = models.Queue.objects.select_related(depth=2).filter(played=False).order_by('id') R = j2shim.r2s("webview/js/queue.html", { 'queue' : queue }) cache.set(key, R, 300) logger.debug("Cache generated") return R
def get_roneliner(create_new=False): key = "rnoneliner" logger.debug("Getting reverse oneliner cache") R = cache.get(key) if not R or create_new: logger.info("No existing cache for reverse oneliner, making new one") oneliner = models.Oneliner.objects.select_related(depth=2).order_by('id')[:15] R = j2shim.r2s('webview/js/roneliner.html', { 'oneliner' : oneliner }) cache.set(key, R, 600) logger.debug("Cache generated") return R
def get_queue(create_new=False): key = "nqueue" logger.debug("Getting cache for queue") R = cache.get(key) if not R or create_new: logger.debug("No existing cache for queue, making new one") queue = models.Queue.objects.select_related(depth=2).filter( played=False).order_by('id') R = j2shim.r2s("webview/js/queue.html", {'queue': queue}) cache.set(key, R, 300) logger.debug("Cache generated") return R
def get_roneliner(create_new=False): key = "rnoneliner" logger.debug("Getting reverse oneliner cache") R = cache.get(key) if not R or create_new: logger.debug("No existing cache for reverse oneliner, making new one") oneliner = models.Oneliner.objects.select_related( depth=2).order_by('id')[:15] R = j2shim.r2s('webview/js/roneliner.html', {'oneliner': oneliner}) cache.set(key, R, 600) logger.debug("Cache generated") return R
def get_oneliner(create_new=False): key = "noneliner" logger.debug("Getting oneliner cache") R = cache.get(key) if not R or create_new: logger.info("No existing cache for oneliner, making new one") lines = getattr(settings, 'ONELINER', 10) oneliner = models.Oneliner.objects.select_related(depth=2).order_by('-id')[:lines] R = j2shim.r2s('webview/js/oneliner.html', { 'oneliner' : oneliner }) cache.set(key, R, 600) logger.debug("Cache generated") return R
def get_oneliner(create_new=False): key = "noneliner" logger.debug("Getting oneliner cache") R = cache.get(key) if not R or create_new: logger.debug("No existing cache for oneliner, making new one") lines = getattr(settings, 'ONELINER', 10) oneliner = models.Oneliner.objects.select_related( depth=2).order_by('-id')[:lines] R = j2shim.r2s('webview/js/oneliner.html', {'oneliner': oneliner}) cache.set(key, R, 600) logger.debug("Cache generated") return R
def get_history(create_new=False): key = "nhistory" logger.debug("Getting history cache") R = cache.get(key) if not R or create_new: nowplaying = get_now_playing_song() limit = nowplaying and (nowplaying.id - 50) or 0 logger.info("No existing cache for history, making new one") history = models.Queue.objects.select_related(depth=3).filter(played=True).filter(id__gt=limit).order_by('-time_played')[1:21] R = j2shim.r2s('webview/js/history.html', { 'history' : history }) cache.set(key, R, 300) logger.debug("Cache generated") return R
def get_history(create_new=False): key = "nhistory" logger.debug("Getting history cache") R = cache.get(key) if not R or create_new: nowplaying = get_now_playing_song() limit = nowplaying and (nowplaying.id - 50) or 0 logger.debug("No existing cache for history, making new one") history = models.Queue.objects.select_related(depth=3).filter( played=True).filter(id__gt=limit).order_by('-time_played')[1:21] R = j2shim.r2s('webview/js/history.html', {'history': history}) cache.set(key, R, 300) logger.debug("Cache generated") return R
def get_now_playing(create_new=False): logger.debug("Getting now playing") key = "nnowplaying" try: songtype = get_now_playing_song(create_new) song = songtype.song except: return "" R = cache.get(key) if not R or create_new: comps = models.Compilation.objects.filter(songs__id = song.id) R = j2shim.r2s('webview/t/now_playing_song.html', { 'now_playing' : songtype, 'comps' : comps }) cache.set(key, R, 300) logger.debug("Now playing generated") R = R.replace("((%timeleft%))", str(songtype.timeleft())) return R
def get_now_playing(create_new=False): logger.debug("Getting now playing") key = "nnowplaying" try: songtype = get_now_playing_song(create_new) song = songtype.song except: return "" R = cache.get(key) if not R or create_new: comps = models.Compilation.objects.filter(songs__id=song.id) R = j2shim.r2s('webview/t/now_playing_song.html', { 'now_playing': songtype, 'comps': comps }) cache.set(key, R, 300) logger.debug("Now playing generated") R = R.replace("((%timeleft%))", str(songtype.timeleft())) return R