This commit is contained in:
j 2011-01-21 21:14:46 +05:30
parent 9300095ffc
commit 686a585b03
3 changed files with 44 additions and 3 deletions

View file

@ -6,6 +6,7 @@ from django.db import models
from django.conf import settings
from ox.utils import json
class Page(models.Model):
created = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)

View file

@ -5,6 +5,8 @@ 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.decorators import login_required_json
from ox.utils import json
import models
@ -33,14 +35,53 @@ def timeline(request):
def getPage(request):
'''
param data {
name: pagename
}
return {
status: ...
data: {
name:
body:
}
}
'''
data = json.loads(request.POST['data'])
name = data['page']
page = get_object_or_404_json(models.Archive, name=name)
name = data['name']
page = get_object_or_404_json(models.Page, name=name)
response = json_response({'name': page.name, 'body': page.body})
return render_to_json_response(response)
actions.register(getPage)
@login_required_json
def editPage(request):
'''
param data {
name: pagename
body: text
}
return {
status: ...
data: {
name:
body:
}
}
'''
if not request.user.is_staff:
response = json_response(status=403, text='permission denied')
return render_to_json_response(response)
data = json.loads(request.POST['data'])
page, created = models.Page.objects.get_or_create(name=data['name'])
page.body = data['body']
page.save()
response = json_response({'name': page.name, 'page': page.body})
return render_to_json_response(response)
actions.register(getPage)
def site_json(request):
'''
return render_to_json_response(siteJson())

View file

@ -789,7 +789,6 @@ class Item(models.Model):
if frame:
icon = self.path('icon.jpg')
self.icon.name = icon
frame = frames[int(len(frames)/2)]
timeline = self.path('timeline.64.png')
timeline = os.path.abspath(os.path.join(settings.MEDIA_ROOT, timeline))
if os.path.exists(timeline):