1
0
mirror of http://git.whoc.org.uk/git/password-manager.git synced 2024-11-14 07:59:02 +01:00

flask backend: fix access_date population

Enables saving updates to access_date and ensures it is populated
This commit is contained in:
jokajak 2016-05-27 13:01:15 -04:00
parent c55bb5eff2
commit a25b3aaa22
2 changed files with 13 additions and 0 deletions

View File

@ -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

View File

@ -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()
# ------------------------------------------------------------------------------