コード例 #1
0
ファイル: settings.py プロジェクト: raveberry/raveberry
 def _decorator(request: WSGIRequest) -> HttpResponse:
     if not user_manager.is_admin(request.user):
         return HttpResponseForbidden()
     response = func(request)
     update_state()
     if response is not None:
         return response
     return HttpResponse()
コード例 #2
0
ファイル: controller.py プロジェクト: raveberry/raveberry
def remove_all(request: WSGIRequest) -> HttpResponse:
    """Empties the queue. Only admin is permitted to do this."""
    if not user_manager.is_admin(request.user):
        return HttpResponseForbidden()
    with playback.mopidy_command() as allowed:
        if allowed:
            with transaction.atomic():
                playback.queue.all().delete()
    return HttpResponse()
コード例 #3
0
def context(request: WSGIRequest) -> Dict[str, Any]:
    """Returns the base context that is needed on every page.
    Increments the visitors counter."""
    from core import urls

    _increment_counter()
    return {
        "base_urls":
        urls.base_paths,
        "interactivity":
        storage.get("interactivity"),
        "interactivities": {
            "fullControl": storage.Interactivity.full_control,
            "fullVoting": storage.Interactivity.full_voting,
            "upvotesOnly": storage.Interactivity.upvotes_only,
            "noControl": storage.Interactivity.no_control,
        },
        "hashtag":
        _get_random_hashtag(),
        "demo":
        conf.DEMO,
        "controls_enabled":
        user_manager.has_controls(request.user)
        or storage.get("interactivity") == storage.Interactivity.full_control,
        "is_admin":
        user_manager.is_admin(request.user),
        "apk_link":
        _get_apk_link(),
        "local_enabled":
        storage.get("local_enabled"),
        "youtube_enabled":
        storage.get("youtube_enabled"),
        "spotify_enabled":
        storage.get("spotify_enabled"),
        "soundcloud_enabled":
        storage.get("soundcloud_enabled"),
        "jamendo_enabled":
        storage.get("jamendo_enabled"),
        "streaming_enabled":
        storage.get("output") == "icecast",
    }
コード例 #4
0
ファイル: controller.py プロジェクト: raveberry/raveberry
def shuffle_all(request: WSGIRequest) -> HttpResponse:
    """Shuffles the queue. Only admin is permitted to do this."""
    if not user_manager.is_admin(request.user):
        return HttpResponseForbidden()
    playback.queue.shuffle()
    return HttpResponse()
コード例 #5
0
def logged_in(request: WSGIRequest) -> HttpResponse:
    """This endpoint is visited after every login.
    Redirect the admin to the settings and everybody else to the musiq page."""
    if user_manager.is_admin(request.user):
        return HttpResponseRedirect(reverse("settings"))
    return HttpResponseRedirect(reverse("musiq"))