From a25b3aaa22b699409567aa6defc0c51c215c7d13 Mon Sep 17 00:00:00 2001 From: jokajak Date: Fri, 27 May 2016 13:01:15 -0400 Subject: [PATCH] flask backend: fix access_date population Enables saving updates to access_date and ensures it is populated --- backend/flask/src/clipperz/api.py | 5 +++++ backend/flask/src/clipperz/models.py | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/backend/flask/src/clipperz/api.py b/backend/flask/src/clipperz/api.py index 4f6a277..6d59c11 100644 --- a/backend/flask/src/clipperz/api.py +++ b/backend/flask/src/clipperz/api.py @@ -438,6 +438,11 @@ class message(HandlerMixin): result['oldestUsedEncryptedVersion'] = oldest_encryption_version result['versions'] = record_versions result['currentVersion'] = record.current_record_version.reference + record.current_record_version.access() + record.access() + db.session.add(record) + db.session.add(record_version) + db.session.commit() return jsonify({'result': result}) @login_required diff --git a/backend/flask/src/clipperz/models.py b/backend/flask/src/clipperz/models.py index 65466b5..6403881 100644 --- a/backend/flask/src/clipperz/models.py +++ b/backend/flask/src/clipperz/models.py @@ -104,8 +104,12 @@ class RecordVersion(db.Model): self.version = self.record.version self.previous_version_key = recordVersionData['previousVersionKey'] self.update_date = datetime.datetime.utcnow() + self.access_date = datetime.datetime.utcnow() self.record.update(someData['record'], self) + + def access(self): + self.access_date = datetime.datetime.now() # ------------------------------------------------------------------------------ @@ -144,9 +148,13 @@ class Record(db.Model): self.data = data['data'] self.api_version = data['version'] self.update_date = datetime.datetime.now() + self.access_date = datetime.datetime.now() self.current_record_version = record_version self.version += 1 + def access(self): + self.access_date = datetime.datetime.now() + # ------------------------------------------------------------------------------