- add update external data api

- add /url= redirect gateway
This commit is contained in:
rolux 2011-09-29 15:16:48 +00:00
parent 64e7a534a7
commit d6e27be0cd
3 changed files with 29 additions and 8 deletions

View file

@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
# vi:si:et:sw=4:sts=4:ts=4
from django.shortcuts import render_to_response
from django.shortcuts import render_to_response, redirect
from django.template import RequestContext
from django.conf import settings
from ox.django.shortcuts import json_response, render_to_json_response, get_object_or_404_json
from ox.django.shortcuts import json_response, render_to_json_response
from ox.django.decorators import login_required_json
from ox.utils import json
@ -29,11 +29,6 @@ def embed(request):
return render_to_response('embed.html', context)
def timeline(request):
context = RequestContext(request, {'settings': settings})
return render_to_response('timeline.html', context)
def getPage(request):
'''
param data {
@ -87,3 +82,7 @@ def editPage(request):
return render_to_json_response(response)
actions.register(getPage)
def redirect_url(request, url):
if request.META['QUERY_STRING']:
url += "?" + request.META['QUERY_STRING']
return redirect(url, permanent=True)

View file

@ -493,6 +493,28 @@ def setPoster(request): #parse path and return info
return render_to_json_response(response)
actions.register(setPoster, cache=False)
def updateExternalData(request):
'''
param data {
id: itemId,
}
return {
status: {'code': int, 'text': string},
data: {
poster: {url,width,height}
}
}
'''
data = json.loads(request.POST['data'])
item = get_object_or_404_json(models.Item, itemId=data['id'])
response = json_response()
if item.editable(request.user):
item.update_external()
else:
response = json_response(status=403, text='permission denied')
return render_to_json_response(response)
actions.register(updateExternalData, cache=False)
def lookup(request):
'''
param data {

View file

@ -24,7 +24,7 @@ urlpatterns = patterns('',
(r'^admin/', include(admin.site.urls)),
(r'^ajax_filtered_fields/', include('ajax_filtered_fields.urls')),
(r'^api/upload/$', 'archive.views.firefogg_upload'),
(r'^timeline$', 'app.views.timeline'),
(r'^url=(?P<url>.*)$', 'app.views.redirect_url'),
(r'^file/(?P<oshash>.*)$', 'archive.views.lookup_file'),
(r'^api/$', include('api.urls')),
(r'', include('item.urls')),