def register(context, request): schema = RegisterSchema().bind(request=request) form = Form(schema, buttons=(Button('register', _(u'Register')), )) rendered_form = None if 'register' in request.POST: try: appstruct = form.validate(request.POST.items()) except ValidationFailure, e: request.session.flash(_(u"There was an error."), 'error') rendered_form = e.render() else: settings = get_settings() appstruct['groups'] = u'' appstruct['roles'] = u'' register_groups = settings['kotti.register.group'] if register_groups: appstruct['groups'] = [register_groups] register_roles = settings['kotti.register.role'] if register_roles: appstruct['roles'] = set(['role:' + register_roles]) appstruct['send_email'] = True form = UserAddFormView(context, request) form.add_user_success(appstruct) success_msg = _( 'Congratulations! You are successfully registered. ' 'You should receive an email with a link to set your ' 'password momentarily.') request.session.flash(success_msg, 'success') return HTTPFound(location=request.application_url)
def register(context, request): schema = RegisterSchema().bind(request=request) form = Form(schema, buttons=(Button('register', _(u'Register')),)) rendered_form = None if 'register' in request.POST: try: appstruct = form.validate(request.POST.items()) except ValidationFailure, e: request.session.flash(_(u"There was an error."), 'error') rendered_form = e.render() else: settings = get_settings() appstruct['groups'] = u'' appstruct['roles'] = u'' register_groups = settings['kotti.register.group'] if register_groups: appstruct['groups'] = [register_groups] register_roles = settings['kotti.register.role'] if register_roles: appstruct['roles'] = set(['role:' + register_roles]) appstruct['send_email'] = True form = UserAddFormView(context, request) form.add_user_success(appstruct) success_msg = _( 'Congratulations! You are successfully registered. ' 'You should receive an email with a link to set your ' 'password momentarily.' ) request.session.flash(success_msg, 'success') return HTTPFound(location=request.application_url)
def register(context, request): schema = RegisterSchema().bind(request=request) form = Form(schema, buttons=(Button('register', _('Register')),)) rendered_form = None if 'register' in request.POST: try: appstruct = form.validate(request.POST.items()) except ValidationFailure as e: request.session.flash(_("There was an error."), 'error') rendered_form = e.render() else: settings = get_settings() appstruct['groups'] = '' appstruct['roles'] = '' register_groups = settings['kotti.register.group'] if register_groups: appstruct['groups'] = [register_groups] register_roles = settings['kotti.register.role'] if register_roles: appstruct['roles'] = {'role:' + register_roles} appstruct['send_email'] = True form = UserAddFormView(context, request) form.add_user_success(appstruct) success_msg = _( 'Congratulations! You are successfully registered. ' 'You should be receiving an email with a link to set your ' 'password. Doing so will activate your account.' ) request.session.flash(success_msg, 'success') name = appstruct['name'] notify(UserSelfRegistered(get_principals()[name], request)) return HTTPFound(location=request.application_url) if rendered_form is None: rendered_form = form.render(request.params) api = template_api( context, request, page_title=_("Register - ${title}", mapping=dict(title=context.title)), ) return { 'api': api, 'form': rendered_form, }
def register(context, request): schema = RegisterSchema().bind(request=request) form = Form(schema, buttons=(Button('register', _(u'Register')), )) rendered_form = None if 'register' in request.POST: try: appstruct = form.validate(request.POST.items()) except ValidationFailure as e: request.session.flash(_(u"There was an error."), 'error') rendered_form = e.render() else: settings = get_settings() appstruct['groups'] = u'' appstruct['roles'] = u'' register_groups = settings['kotti.register.group'] if register_groups: appstruct['groups'] = [register_groups] register_roles = settings['kotti.register.role'] if register_roles: appstruct['roles'] = {'role:' + register_roles} appstruct['send_email'] = True form = UserAddFormView(context, request) form.add_user_success(appstruct) success_msg = _( 'Congratulations! You are successfully registered. ' 'You should be receiving an email with a link to set your ' 'password. Doing so will activate your account.') request.session.flash(success_msg, 'success') name = appstruct['name'] notify(UserSelfRegistered(get_principals()[name], request)) return HTTPFound(location=request.application_url) if rendered_form is None: rendered_form = form.render(request.params) api = template_api( context, request, page_title=_(u"Register - ${title}", mapping=dict(title=context.title)), ) return { 'api': api, 'form': rendered_form, }
def register(context, request): schema = RegisterSchema().bind(request=request) form = Form(schema, buttons=(Button("register", _("Register")),)) rendered_form = None if "register" in request.POST: try: appstruct = form.validate(request.POST.items()) except ValidationFailure as e: request.session.flash(_("There was an error."), "error") rendered_form = e.render() else: settings = get_settings() appstruct["groups"] = "" appstruct["roles"] = "" register_groups = settings["kotti.register.group"] if register_groups: appstruct["groups"] = [register_groups] register_roles = settings["kotti.register.role"] if register_roles: appstruct["roles"] = {"role:" + register_roles} appstruct["send_email"] = True form = UserAddFormView(context, request) form.add_user_success(appstruct) success_msg = _( "Congratulations! You are successfully registered. " "You should be receiving an email with a link to set your " "password. Doing so will activate your account." ) request.session.flash(success_msg, "success") name = appstruct["name"] notify(UserSelfRegistered(get_principals()[name], request)) return HTTPFound(location=request.application_url) if rendered_form is None: rendered_form = form.render(request.params) api = template_api( context, request, page_title=_("Register - ${title}", mapping=dict(title=context.title)), ) return {"api": api, "form": rendered_form}
def register(context, request): schema = RegisterSchema().bind(request=request) form = Form(schema, buttons=(Button("register", _(u"Register")),)) rendered_form = None if "register" in request.POST: try: appstruct = form.validate(request.POST.items()) except ValidationFailure as e: request.session.flash(_(u"There was an error."), "error") rendered_form = e.render() else: settings = get_settings() appstruct["groups"] = u"" appstruct["roles"] = u"" register_groups = settings["kotti.register.group"] if register_groups: appstruct["groups"] = [register_groups] register_roles = settings["kotti.register.role"] if register_roles: appstruct["roles"] = {"role:" + register_roles} appstruct["send_email"] = True form = UserAddFormView(context, request) form.add_user_success(appstruct) success_msg = _( "Congratulations! You are successfully registered. " "You should be receiving an email with a link to set your " "password. Doing so will activate your account." ) request.session.flash(success_msg, "success") name = appstruct["name"] notify(UserSelfRegistered(get_principals()[name], request)) return HTTPFound(location=request.application_url) if rendered_form is None: rendered_form = form.render(request.params) api = template_api(context, request, page_title=_(u"Register - ${title}", mapping=dict(title=context.title))) return {"api": api, "form": rendered_form}