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)
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)
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())))
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(), }, )
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
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)
def theme_choices(): from game.theme import get_all_themes return [(theme.name, theme.name) for theme in get_all_themes()]
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())))
def theme_list(request, format=None): themes = get_all_themes() data = [{get_themes_url(i.pk, request)} for i in themes] return Response(data)
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())))
def theme_list(request, format=None): themes = get_all_themes() serializer = ThemeSerializer(themes, many=True, context={'request': request}) return Response(serializer.data)