Beispiel #1
0
def current(request):
    playing = Music.currently_playing()
    data = {}
    if playing:
        data['artist'] = playing.artist
        data['title'] = playing.title
        if playing.associated_request is not None:
            data['requested_by'] = playing.associated_request.requester.username
        else:
            data['requested_by'] = "Random Play"

    return HttpResponse(json.dumps(data), content_type='application/json')
def settings_for_view(context):
    return {'SITE_NAME': get_setting('site_name'),
            'SITE_TITLE': get_setting('site_title'),
            'ENABLE_MUSIC': get_setting('enable_music'),
            'ENABLE_BENCHMARKS': get_setting('enable_benchmarks'),
            'ENABLE_GALLERY': get_setting('enable_gallery'),
            'ENABLE_TOURNAMENTS': get_setting('enable_tournaments'),
            'ENABLE_SERVERS': get_setting('enable_servers'),
            'ENABLE_NOMS': get_setting('enable_noms'),
            'THUMB_X': settings.THUMBNAIL_SIZE[0],
            'THUMB_Y': settings.THUMBNAIL_SIZE[1],
            'MUSIC_PLAYING': Music.currently_playing()
    }
Beispiel #3
0
def get_notices(request):
    notices = []
    # upcoming tournament notices
    if get_setting('enable_tournaments') == '1':
        upcoming = Tournament.objects.filter(starts__lte=(datetime.now() + timedelta(hours=1)))
        if upcoming.count() == 1:
            notices.append("The tournament %s is starting within the hour" % upcoming[0].name)
        elif upcoming.count() > 1:
            notices.append("%d tournaments are starting within the hour" % upcoming.count())
    # get admin notices
    if request.user.is_admin:
        # servers needing approval
        servers_unapproved = Server.objects.filter(mod_approved=False)
        if servers_unapproved.count() is not 0:
            notices.append("%d servers require admin approval." % servers_unapproved.count())
        # jukebox is not running
        if get_setting('enable_music') == '1' and Music.currently_playing() is None:
            notices.append("No music is currently playing!")
    # and return the lot of them
    return HttpResponse(json.dumps(notices), content_type='application/json')
Beispiel #4
0
def stream(request):
    if Music.currently_playing() is not None:
        warning(request, "Only one Shoutcast stream may be active at any time")
        return HttpResponseRedirect("/")
    response = HttpResponse(ShoutCastStream(request))
    return response