page
This commit is contained in:
parent
9300095ffc
commit
686a585b03
3 changed files with 44 additions and 3 deletions
|
@ -6,6 +6,7 @@ from django.db import models
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from ox.utils import json
|
from ox.utils import json
|
||||||
|
|
||||||
|
|
||||||
class Page(models.Model):
|
class Page(models.Model):
|
||||||
created = models.DateTimeField(auto_now_add=True)
|
created = models.DateTimeField(auto_now_add=True)
|
||||||
modified = models.DateTimeField(auto_now=True)
|
modified = models.DateTimeField(auto_now=True)
|
||||||
|
|
|
@ -5,6 +5,8 @@ from django.template import RequestContext
|
||||||
from django.conf import settings
|
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, get_object_or_404_json
|
||||||
|
from ox.django.decorators import login_required_json
|
||||||
|
|
||||||
from ox.utils import json
|
from ox.utils import json
|
||||||
|
|
||||||
import models
|
import models
|
||||||
|
@ -33,14 +35,53 @@ def timeline(request):
|
||||||
|
|
||||||
|
|
||||||
def getPage(request):
|
def getPage(request):
|
||||||
|
'''
|
||||||
|
param data {
|
||||||
|
name: pagename
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
status: ...
|
||||||
|
data: {
|
||||||
|
name:
|
||||||
|
body:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'''
|
||||||
data = json.loads(request.POST['data'])
|
data = json.loads(request.POST['data'])
|
||||||
name = data['page']
|
name = data['name']
|
||||||
page = get_object_or_404_json(models.Archive, name=name)
|
page = get_object_or_404_json(models.Page, name=name)
|
||||||
response = json_response({'name': page.name, 'body': page.body})
|
response = json_response({'name': page.name, 'body': page.body})
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(getPage)
|
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):
|
def site_json(request):
|
||||||
'''
|
'''
|
||||||
return render_to_json_response(siteJson())
|
return render_to_json_response(siteJson())
|
||||||
|
|
|
@ -789,7 +789,6 @@ class Item(models.Model):
|
||||||
if frame:
|
if frame:
|
||||||
icon = self.path('icon.jpg')
|
icon = self.path('icon.jpg')
|
||||||
self.icon.name = icon
|
self.icon.name = icon
|
||||||
frame = frames[int(len(frames)/2)]
|
|
||||||
timeline = self.path('timeline.64.png')
|
timeline = self.path('timeline.64.png')
|
||||||
timeline = os.path.abspath(os.path.join(settings.MEDIA_ROOT, timeline))
|
timeline = os.path.abspath(os.path.join(settings.MEDIA_ROOT, timeline))
|
||||||
if os.path.exists(timeline):
|
if os.path.exists(timeline):
|
||||||
|
|
Loading…
Reference in a new issue