From a62a992ad2087336b2f7536381ec4ecf98723fbb Mon Sep 17 00:00:00 2001 From: j <0x006A@0x2620.org> Date: Tue, 31 Jan 2012 22:42:03 +0530 Subject: [PATCH] log page changes too --- pandora/app/models.py | 8 ++++++++ pandora/app/views.py | 2 ++ 2 files changed, 10 insertions(+) diff --git a/pandora/app/models.py b/pandora/app/models.py index a60ab14c..317e7852 100644 --- a/pandora/app/models.py +++ b/pandora/app/models.py @@ -4,6 +4,7 @@ from __future__ import division, with_statement from django.db import models +from changelog.models import Changelog class Page(models.Model): created = models.DateTimeField(auto_now_add=True) @@ -14,3 +15,10 @@ class Page(models.Model): def __unicode__(self): return self.name + def log(self): + c = Changelog(type='page') + c.value = { + 'name': self.name, + 'body': self.body, + } + c.save() diff --git a/pandora/app/views.py b/pandora/app/views.py index b2995623..b2aacd73 100644 --- a/pandora/app/views.py +++ b/pandora/app/views.py @@ -137,6 +137,8 @@ def editPage(request): if request.user.get_profile().capability('canEditSitePages'): data = json.loads(request.POST['data']) page, created = models.Page.objects.get_or_create(name=data['name']) + if not created: + page.log() page.body = data['body'] page.save() response = json_response({'name': page.name, 'page': page.body})