예제 #1
0
def level_editor(request):
    """ Renders the level editor page.

    **Context**

    ``RequestContext``
    ``blocks``
        Blocks that can be chosen to be played with later on. List of :model:`game.Block`.

    **Template:**

    :template:`game/level_editor.html`
    """

    context = RequestContext(
        request, {
            'blocks':
            available_blocks(),
            'decor':
            get_all_decor(),
            'characters':
            get_all_character(),
            'themes':
            get_all_themes(),
            'cow_level_enabled':
            app_settings.COW_FEATURE_ENABLED,
            'night_mode_feature_enabled':
            str(app_settings.NIGHT_MODE_FEATURE_ENABLED).lower(),
        })
    return render(request, 'game/level_editor.html', context_instance=context)
예제 #2
0
def level_editor(request):
    """ Renders the level editor page.

    **Context**

    ``RequestContext``
    ``blocks``
        Blocks that can be chosen to be played with later on.
        List of :model:`game.Block`.

    **Template:**

    :template:`game/level_editor.html`
    """

    context = {
        "blocks": [block.type for block in available_blocks()],
        "decor":
        get_all_decor(),
        "characters":
        get_all_character(),
        "themes":
        get_all_themes(),
        "cow_level_enabled":
        app_settings.COW_FEATURE_ENABLED,
        "night_mode_feature_enabled":
        str(app_settings.NIGHT_MODE_FEATURE_ENABLED).lower(),
    }

    return render(request, "game/level_editor.html", context=context)
예제 #3
0
 def test_list_themes(self):
     url = reverse("theme-list")
     superuser = get_superuser()
     self.client.force_authenticate(user=superuser)
     response = self.client.get(url)
     assert_that(response, has_status_code(status.HTTP_200_OK))
     assert_that(response.data, has_length(len(get_all_themes())))
예제 #4
0
def level_editor(request):
    """ Renders the level editor page.

    **Context**

    ``RequestContext``
    ``blocks``
        Blocks that can be chosen to be played with later on.
        List of :model:`game.Block`.

    **Template:**

    :template:`game/level_editor.html`
    """

    return render(
        request,
        "game/level_editor.html",
        context={
            "blocks": available_blocks(),
            "decor": get_all_decor(),
            "characters": get_all_character(),
            "themes": get_all_themes(),
            "cow_level_enabled": app_settings.COW_FEATURE_ENABLED,
            "night_mode_feature_enabled": str(
                app_settings.NIGHT_MODE_FEATURE_ENABLED
            ).lower(),
        },
    )
예제 #5
0
def get_decor_element(name, theme):
    """ Helper method to get a decor element corresponding to the theme or a default one."""
    try:
        return DECOR_DATA[(name, theme.name)]
    except KeyError:
        for theme_object in get_all_themes():
            try:
                return DECOR_DATA[(name, theme_object.name)]
            except KeyError:
                pass
    raise KeyError
예제 #6
0
def get_decor_element(name, theme):
    """ Helper method to get a decor element corresponding to the theme or a default one."""
    try:
        return DECOR_DATA[(name, theme.name)]
    except KeyError:
        for theme_object in get_all_themes():
            try:
                return DECOR_DATA[(name, theme_object.name)]
            except KeyError:
                pass
    raise KeyError
예제 #7
0
def level_editor(request):
    """ Renders the level editor page.

    **Context**

    ``RequestContext``
    ``blocks``
        Blocks that can be chosen to be played with later on. List of :model:`game.Block`.

    **Template:**

    :template:`game/level_editor.html`
    """

    context = RequestContext(request, {
        'blocks': available_blocks(),
        'decor': get_all_decor(),
        'characters': get_all_character(),
        'themes': get_all_themes(),
        'cow_level_enabled': app_settings.COW_FEATURE_ENABLED,
        'night_mode_feature_enabled': str(app_settings.NIGHT_MODE_FEATURE_ENABLED).lower(),
    })
    return render(request, 'game/level_editor.html', context_instance=context)
예제 #8
0
def theme_choices():
    from game.theme import get_all_themes
    return [(theme.name, theme.name) for theme in get_all_themes()]
예제 #9
0
 def test_list_themes(self):
     url = reverse("theme-list")
     response = self.client.get(url)
     assert_that(response, has_status_code(status.HTTP_200_OK))
     assert_that(response.data, has_length(len(get_all_themes())))
예제 #10
0
def theme_choices():
    from game.theme import get_all_themes
    return [(theme.name, theme.name) for theme in get_all_themes()]
예제 #11
0
def theme_list(request, format=None):
    themes = get_all_themes()
    data = [{get_themes_url(i.pk, request)} for i in themes]
    return Response(data)
예제 #12
0
 def test_list_themes(self):
     url = reverse('theme-list')
     response = self.client.get(url)
     assert_that(response, has_status_code(status.HTTP_200_OK))
     assert_that(response.data, has_length(len(get_all_themes())))
예제 #13
0
def theme_list(request, format=None):
    themes = get_all_themes()
    serializer = ThemeSerializer(themes, many=True, context={'request': request})
    return Response(serializer.data)