make sure to reset delete timer when enabling

This commit is contained in:
codl 2017-08-31 20:47:29 +02:00
parent e6ddf2f120
commit cd13094bad
No known key found for this signature in database
GPG Key ID: 6CD7C8891ED1233A
3 changed files with 13 additions and 6 deletions

View File

@ -130,7 +130,11 @@ export default {
methods: { methods: {
toggle(policy_enabled){ toggle(policy_enabled){
policy_enabled = !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); this.fire('toggle', policy_enabled);
} }
}, },

View File

@ -135,6 +135,14 @@ class Account(TimestampMixin, RemoteIDMixin):
return 0 return 0
return value 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: tokens
# backref: twitter_archives # backref: twitter_archives
# backref: posts # backref: posts

View File

@ -211,11 +211,6 @@ def enable():
miss them. 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 g.viewer.account.policy_enabled = True
db.session.commit() db.session.commit()