def edit_redirect_post(redirect_id: int): vm = EditRedirectViewModel(redirect_id) vm.process_form() if not vm.validate(): return vm.to_dict() cms_service.update_redirect(vm.redirect_id, vm.name, vm.short_url, vm.url) return flask.redirect('/admin/redirects')
def add_redirect_post(): vm = EditRedirectViewModel() vm.process_form() if not vm.validate(): return vm.to_dict() cms_service.create_redirect(vm.name, vm.short_url, vm.url, vm.user.email) return flask.redirect('/admin/redirects')
def edit_redirect_post(redirect_id: int): vm = EditRedirectViewModel(redirect_id) vm.process_form() if not vm.validate(): log.notice(f"User cannot edit redirect, error: {vm.user.email} - {vm.error}.") return vm.to_dict() cms_service.update_redirect(vm.redirect_id, vm.name, vm.short_url, vm.url) log.notice(f"User edited redirect: {vm.user.email}, {vm.name} --> /{vm.short_url}.") return flask.redirect('/admin/redirects')
def add_redirect_post(): vm = EditRedirectViewModel() vm.process_form() if not vm.validate(): log.notice(f"User cannot add new redirect, error: {vm.user.email} - {vm.error}.") return vm.to_dict() cms_service.create_redirect(vm.name, vm.short_url, vm.url, vm.user.email) log.notice(f"User adding new redirect: {vm.user.email}, {vm.name} --> {vm.short_url}.") return flask.redirect('/admin/redirects')