diff --git a/minecraftcodex/herobrine/urls.py b/minecraftcodex/herobrine/urls.py index 334449f..4137312 100644 --- a/minecraftcodex/herobrine/urls.py +++ b/minecraftcodex/herobrine/urls.py @@ -50,6 +50,7 @@ urlpatterns = patterns('', 'blog.views.blog_item', name='blog_item'), # Admin only + url(r'^studio/textures/$', 'studio.views.textures', name='studio_textures'), url(r'^studio/', 'studio.views.main', name='studio_main'), # Robots diff --git a/minecraftcodex/studio/views.py b/minecraftcodex/studio/views.py index 2dfedc8..0794145 100644 --- a/minecraftcodex/studio/views.py +++ b/minecraftcodex/studio/views.py @@ -1,6 +1,9 @@ from django.shortcuts import render_to_response from django.template import RequestContext +from django.http import HttpResponse from database.models import Texture +from django.utils import simplejson as json +from django.core import serializers def main(request): @@ -12,3 +15,10 @@ def main(request): context = RequestContext(request, data) return render_to_response('studio/main.html', context_instance=context) + + +def textures(request): + textures = Texture.objects.all() + data = serializers.serialize('json', textures, fields=('name', 'type', 'image',)) + response = HttpResponse(data, 'application/json') + return response