def put(self, id): json_data = request.get_json() if not json_data: return {'message': 'No input data received for updating CSR'}, 400 auth_csr = CSR.find_by_username(g.oidc_token_info['username']) edit_csr = CSR.query.filter_by(csr_id=id).first_or_404() if auth_csr.csr_id != edit_csr.csr_id: return { 'message': 'You do not have permission to edit this CSR' }, 403 try: edit_csr = self.csr_schema.load(json_data, instance=edit_csr, partial=True).data except ValidationError as err: return {'message': err.messages}, 422 db.session.add(edit_csr) db.session.commit() result = self.csr_schema.dump(edit_csr) # Purge cache of old CSR record so the new one can be fetched by the next request for it. cache.delete('csr_detail_%s' % g.oidc_token_info['username']) return {'service_request': result.data, 'errors': result.errors}, 200
def clear_offices_cache(cls): """Clear active offices cache.""" cache.delete(Office.offices_cache_key)
def delete_user_cache(cls, username): idir_id = username.split("idir/")[-1] key = (CSR.format_string % idir_id).lower() cache.delete(key)