body/text in page api
This commit is contained in:
parent
b533593f99
commit
74b4ff34fb
2 changed files with 10 additions and 10 deletions
|
@ -10,7 +10,7 @@ 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)
|
||||||
name = models.CharField(max_length=1024, unique=True)
|
name = models.CharField(max_length=1024, unique=True)
|
||||||
body = models.TextField(blank=True)
|
text = models.TextField(blank=True)
|
||||||
|
|
||||||
def __unicode__(self):
|
def __unicode__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -19,6 +19,6 @@ class Page(models.Model):
|
||||||
c = Changelog(type='page')
|
c = Changelog(type='page')
|
||||||
c.value = {
|
c.value = {
|
||||||
'name': self.name,
|
'name': self.name,
|
||||||
'body': self.body,
|
'text': self.text,
|
||||||
}
|
}
|
||||||
c.save()
|
c.save()
|
||||||
|
|
|
@ -35,7 +35,7 @@ def index(request):
|
||||||
if p['id'] == page:
|
if p['id'] == page:
|
||||||
title += ' - ' + p['title']
|
title += ' - ' + p['title']
|
||||||
text, created = models.Page.objects.get_or_create(name=page)
|
text, created = models.Page.objects.get_or_create(name=page)
|
||||||
text = text.body
|
text = text.text
|
||||||
context = RequestContext(request, {
|
context = RequestContext(request, {
|
||||||
'base_url': request.build_absolute_uri('/'),
|
'base_url': request.build_absolute_uri('/'),
|
||||||
'settings': settings,
|
'settings': settings,
|
||||||
|
@ -101,7 +101,7 @@ def getPage(request):
|
||||||
status: ...
|
status: ...
|
||||||
data: {
|
data: {
|
||||||
name:
|
name:
|
||||||
body:
|
text:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
@ -112,9 +112,9 @@ def getPage(request):
|
||||||
name = data['name']
|
name = data['name']
|
||||||
page, created = models.Page.objects.get_or_create(name=name)
|
page, created = models.Page.objects.get_or_create(name=name)
|
||||||
if created:
|
if created:
|
||||||
page.body = 'Insert text here'
|
page.text= 'Insert text here'
|
||||||
page.save()
|
page.save()
|
||||||
response = json_response({'name': page.name, 'body': page.body})
|
response = json_response({'name': page.name, 'text': page.text})
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
actions.register(getPage)
|
actions.register(getPage)
|
||||||
|
|
||||||
|
@ -124,13 +124,13 @@ def editPage(request):
|
||||||
'''
|
'''
|
||||||
param data {
|
param data {
|
||||||
name: pagename
|
name: pagename
|
||||||
body: text
|
text: text
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
status: ...
|
status: ...
|
||||||
data: {
|
data: {
|
||||||
name:
|
name:
|
||||||
body:
|
text:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
@ -139,9 +139,9 @@ def editPage(request):
|
||||||
page, created = models.Page.objects.get_or_create(name=data['name'])
|
page, created = models.Page.objects.get_or_create(name=data['name'])
|
||||||
if not created:
|
if not created:
|
||||||
page.log()
|
page.log()
|
||||||
page.body = data['body']
|
page.text = data['text']
|
||||||
page.save()
|
page.save()
|
||||||
response = json_response({'name': page.name, 'page': page.body})
|
response = json_response({'name': page.name, 'text': page.text})
|
||||||
else:
|
else:
|
||||||
response = json_response(status=403, text='permission denied')
|
response = json_response(status=403, text='permission denied')
|
||||||
return render_to_json_response(response)
|
return render_to_json_response(response)
|
||||||
|
|
Loading…
Reference in a new issue