From cd13094bad9289b1982cda138e36fc1c6d7dff3f Mon Sep 17 00:00:00 2001 From: codl Date: Thu, 31 Aug 2017 20:47:29 +0200 Subject: [PATCH] make sure to reset delete timer when enabling --- components/Banner.html | 6 +++++- model.py | 8 ++++++++ routes.py | 5 ----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/components/Banner.html b/components/Banner.html index 7154e15..9b4866b 100644 --- a/components/Banner.html +++ b/components/Banner.html @@ -130,7 +130,11 @@ export default { methods: { toggle(policy_enabled){ policy_enabled = !policy_enabled; - this.set({policy_enabled}); + let obj = {policy_enabled} + if(policy_enabled){ + obj.next_delete = null; + } + this.set(obj); this.fire('toggle', policy_enabled); } }, diff --git a/model.py b/model.py index bc1e0d2..de10b5c 100644 --- a/model.py +++ b/model.py @@ -135,6 +135,14 @@ class Account(TimestampMixin, RemoteIDMixin): return 0 return value + @db.validates('policy_enabled') + def reset_next_delete(self, key, enable): + if not self.policy_enabled and enable: + self.next_delete = ( + datetime.now(timezone.utc) + self.policy_delete_every) + return enable + + # backref: tokens # backref: twitter_archives # backref: posts diff --git a/routes.py b/routes.py index b5867aa..cb480bd 100644 --- a/routes.py +++ b/routes.py @@ -211,11 +211,6 @@ def enable(): miss them. """) - if not g.viewer.account.policy_enabled: - g.viewer.account.next_delete = ( - datetime.now(timezone.utc) - + g.viewer.account.policy_delete_every) - g.viewer.account.policy_enabled = True db.session.commit()