Пример #1
0
    def registration(self):
        """
        Invokes registration of an user
        """
        registration_form = self.get_registration_form()

        if request.method == "POST" and registration_form.validate():
            existing = self.search(
                [("email", "=", request.form["email"]), ("company", "=", request.nereid_website.company.id)]
            )
            if existing:
                flash(_("A registration already exists with this email. " "Please contact customer care"))
            else:
                user_id = self.create(
                    {
                        "name": registration_form.name.data,
                        "display_name": registration_form.name.data,
                        "email": registration_form.email.data,
                        "password": registration_form.password.data,
                        "company": request.nereid_website.company.id,
                    }
                )
                self.create_act_code(user_id)
                registration.send(user_id)
                user = self.browse(user_id)
                self.send_activation_email(user)
                flash(_("Registration Complete. Check your email for activation"))
                return redirect(request.args.get("next", url_for("nereid.website.home")))

        return render_template("registration.jinja", form=registration_form)
Пример #2
0
    def registration(self):
        """
        Invokes registration of an user
        """
        registration_form = self.get_registration_form()

        if request.method == 'POST' and registration_form.validate():
            existing = self.search([
                ('email', '=', request.form['email']),
                ('company', '=', request.nereid_website.company.id),
                ])
            if existing:
                flash(_('A registration already exists with this email. '
                    'Please contact customer care')
                )
            else:
                user_id = self.create({
                    'name': registration_form.name.data,
                    'display_name': registration_form.name.data,
                    'email': registration_form.email.data,
                    'password': registration_form.password.data,
                    'company': request.nereid_website.company.id,
                    })
                self.create_act_code(user_id)
                registration.send(user_id)
                user = self.browse(user_id)
                self.send_activation_email(user)
                flash(
                    _('Registration Complete. Check your email for activation')
                )
                return redirect(
                    request.args.get('next', url_for('nereid.website.home'))
                )

        return render_template('registration.jinja', form=registration_form)
Пример #3
0
    def registration(cls):
        """
        Invokes registration of an user
        """
        Party = Pool().get('party.party')
        ContactMechanism = Pool().get('party.contact_mechanism')

        registration_form = cls.get_registration_form()

        if registration_form.validate_on_submit():
            with Transaction().set_context(active_test=False):
                existing = cls.search([
                    ('email', '=', registration_form.email.data.lower()),
                    ('company', '=', current_website.company.id),
                ])
            if existing:
                message = _('A registration already exists with this email. '
                            'Please contact customer care')
                if request.is_xhr or request.is_json:
                    return jsonify(message=unicode(message)), 400
                else:
                    flash(message)
            else:
                party = Party(name=registration_form.name.data)
                party.addresses = []
                party.contact_mechanisms = [
                    ContactMechanism(type="email",
                                     value=registration_form.email.data)
                ]
                party.save()
                nereid_user = cls(
                    **{
                        'party': party.id,
                        'display_name': registration_form.name.data,
                        'email': registration_form.email.data,
                        'password': registration_form.password.data,
                        'company': current_website.company.id,
                    })
                nereid_user.save()
                registration.send(nereid_user)
                nereid_user.send_activation_email()
                message = _(
                    'Registration Complete. Check your email for activation')
                if request.is_xhr or request.is_json:
                    return jsonify(message=unicode(message)), 201
                else:
                    flash(message)
                return redirect(
                    request.args.get('next', url_for('nereid.website.home')))

        if registration_form.errors and (request.is_xhr or request.is_json):
            return jsonify({
                'message': unicode(_('Form has errors')),
                'errors': registration_form.errors,
            }), 400

        return render_template('registration.jinja', form=registration_form)
Пример #4
0
    def registration(cls):
        """
        Invokes registration of an user
        """
        Party = Pool().get('party.party')

        registration_form = cls.get_registration_form()

        if registration_form.validate_on_submit():
            with Transaction().set_context(active_test=False):
                existing = cls.search([
                    ('email', '=', registration_form.email.data),
                    ('company', '=', request.nereid_website.company.id),
                ])
            if existing:
                message = _(
                    'A registration already exists with this email. '
                    'Please contact customer care'
                )
                if request.is_xhr or request.is_json:
                    return jsonify(message=unicode(message)), 400
                else:
                    flash(message)
            else:
                party = Party(name=registration_form.name.data)
                party.addresses = []
                party.save()
                nereid_user = cls(**{
                    'party': party.id,
                    'display_name': registration_form.name.data,
                    'email': registration_form.email.data,
                    'password': registration_form.password.data,
                    'company': request.nereid_website.company.id,
                }
                )
                nereid_user.save()
                registration.send(nereid_user)
                nereid_user.send_activation_email()
                message = _(
                    'Registration Complete. Check your email for activation'
                )
                if request.is_xhr or request.is_json:
                    return jsonify(message=unicode(message)), 201
                else:
                    flash(message)
                return redirect(
                    request.args.get('next', url_for('nereid.website.home'))
                )

        if registration_form.errors and (request.is_xhr or request.is_json):
            return jsonify({
                'message': unicode(_('Form has errors')),
                'errors': registration_form.errors,
            }), 400

        return render_template('registration.jinja', form=registration_form)
Пример #5
0
    def registration(cls):
        """
        Invokes registration of an user
        """
        Party = Pool().get("party.party")
        ContactMechanism = Pool().get("party.contact_mechanism")

        registration_form = cls.get_registration_form()

        if registration_form.validate_on_submit():
            with Transaction().set_context(active_test=False):
                existing = cls.search(
                    [("email", "=", registration_form.email.data.lower()), ("company", "=", current_website.company.id)]
                )
            if existing:
                message = _("A registration already exists with this email. " "Please contact customer care")
                if request.is_xhr or request.is_json:
                    return jsonify(message=unicode(message)), 400
                else:
                    flash(message)
            else:
                party = Party(name=registration_form.name.data)
                party.addresses = []
                party.contact_mechanisms = [ContactMechanism(type="email", value=registration_form.email.data)]
                party.save()
                nereid_user = cls(
                    **{
                        "party": party.id,
                        "display_name": registration_form.name.data,
                        "email": registration_form.email.data,
                        "password": registration_form.password.data,
                        "company": current_website.company.id,
                    }
                )
                nereid_user.save()
                registration.send(nereid_user)
                nereid_user.send_activation_email()
                message = _("Registration Complete. Check your email for activation")
                if request.is_xhr or request.is_json:
                    return jsonify(message=unicode(message)), 201
                else:
                    flash(message)
                return redirect(request.args.get("next", url_for("nereid.website.home")))

        if registration_form.errors and (request.is_xhr or request.is_json):
            return jsonify({"message": unicode(_("Form has errors")), "errors": registration_form.errors}), 400

        return render_template("registration.jinja", form=registration_form)
Пример #6
0
    def registration(cls):
        """
        Invokes registration of an user
        """
        Party = Pool().get('party.party')

        registration_form = cls.get_registration_form()

        if request.method == 'POST' and registration_form.validate():
            existing = cls.search([
                ('email', '=', request.form['email']),
                ('company', '=', request.nereid_website.company.id),
            ]
            )
            if existing:
                flash(_(
                    'A registration already exists with this email. '
                    'Please contact customer care')
                )
            else:
                party = Party(name=registration_form.name.data)
                party.addresses = []
                party.save()
                nereid_user = cls(**{
                    'party': party.id,
                    'display_name': registration_form.name.data,
                    'email': registration_form.email.data,
                    'password': registration_form.password.data,
                    'company': request.nereid_website.company.id,
                }
                )
                nereid_user.save()
                nereid_user.create_act_code()
                registration.send(nereid_user)
                nereid_user.send_activation_email()
                flash(
                    _('Registration Complete. Check your email for activation')
                )
                return redirect(
                    request.args.get('next', url_for('nereid.website.home'))
                )

        return render_template('registration.jinja', form=registration_form)
Пример #7
0
    def registration(cls):
        """
        Invokes registration of an user
        """
        registration_form = cls.get_registration_form()

        if request.method == 'POST' and registration_form.validate():
            existing = cls.search([
                ('email', '=', request.form['email']),
                ('company', '=', request.nereid_website.company.id),
            ])
            if existing:
                flash(
                    _('A registration already exists with this email. '
                      'Please contact customer care'))
            else:
                nereid_user = cls.create({
                    'name':
                    registration_form.name.data,
                    'display_name':
                    registration_form.name.data,
                    'email':
                    registration_form.email.data,
                    'password':
                    registration_form.password.data,
                    'company':
                    request.nereid_website.company.id,
                })
                nereid_user.create_act_code()
                registration.send(nereid_user)
                nereid_user.send_activation_email()
                flash(
                    _('Registration Complete. Check your email for activation')
                )
                return redirect(
                    request.args.get('next', url_for('nereid.website.home')))

        return render_template('registration.jinja', form=registration_form)