def upgrade(self, settings): for i in settings: if i in self: param = Settings.query.get(i) if param is None: param = Settings() param.init(i, self[i].data) db.session.add(param) db.session.commit() else: param.value = self[i].data Settings.update(param) else: param = Settings() param.init(i, self[i].data) db.session.add(param) db.session.commit() if not self['key'].data: param = Settings.query.get('key') param.value = 0 Settings.update(param) if not self['emoney'].data: param = Settings.query.get('emoney') param.value = 0 Settings.update(param) if not self['pdel'].data: param = Settings.query.get('pdel') param.value = 0 Settings.update(param) return True
def upgrade(self, settings): for i in settings: if i in self: param = Settings.query.get(i) if param is None: param = Settings() param.init(i,self[i].data) db.session.add(param) db.session.commit() else: param.value = self[i].data Settings.update(param) else: param = Settings() param.init(i,self[i].data) db.session.add(param) db.session.commit() if not self['key'].data: param = Settings.query.get('key') param.value = 0 Settings.update(param) if not self['emoney'].data: param = Settings.query.get('emoney') param.value = 0 Settings.update(param) if not self['pdel'].data: param = Settings.query.get('pdel') param.value = 0 Settings.update(param) return True
def reset_api_key(key_name): api_secret = Settings.query.get(key_name) if not api_secret: api_secret = Settings(id=key_name, value=generate_password(30)) db.session.add(api_secret) try: db.session.commit() except IntegrityError: db.session.rollback() raise else: api_secret.value = generate_password(30) db.session.add(api_secret) try: db.session.commit() except IntegrityError: db.session.rollback() raise return User.generate_api_key(api_secret.value)