def edit_policy(self, policy_id): """Edit an existing Policy""" policy = get_policy(policy_id) if not policy: abort(404) c.policy_id = policy.id c.policy_type = policy.policy_type c.POLICY_NAME = POLICY_NAME c.POLICY_URL_MAP = POLICY_URL_MAP c.form = PolicyForm(request.POST, policy, csrf_context=session) rules = get_policy_rules(policy_id, True) if not rules: del c.form.enabled if request.method == 'POST' and c.form.validate(): try: updated = update_policy(c.form, policy, c.user, request.host, request.remote_addr) if updated: flash(_('The policy has been updated')) else: flash(_('No changes were made to the policy')) except IntegrityError: Session.rollback() flash(_('The update of the policy failed')) redirect(url(POLICY_URL_MAP[str(policy.policy_type)])) return self.render('/settings/policy_edit.html')
def policy_rules(self, policy_id): """Display policy rules""" policy = get_policy(policy_id) if not policy: abort(404) c.policy_id = policy_id c.policy_type = policy.policy_type c.POLICY_URL_MAP = POLICY_URL_MAP c.policy = policy.name c.policy_name = POLICY_NAME[str(policy.policy_type)] c.rules = get_policy_rules(policy_id) return self.render('/settings/policy_rules.html')