Ejemplo n.º 1
0
    def _process(self):
        form = make_registration_form(self.regform)()
        if self._can_register() and form.validate_on_submit():
            registration = create_registration(self.regform, form.data,
                                               self.invitation)
            return redirect(
                url_for('.display_regform', registration.locator.registrant))
        elif form.is_submitted():
            # not very pretty but usually this never happens thanks to client-side validation
            for error in form.error_list:
                flash(error, 'error')

        user_data = {
            t.name: getattr(session.user, t.name, None) if session.user else ''
            for t in PersonalDataType
        }
        if self.invitation:
            user_data.update((attr, getattr(self.invitation, attr))
                             for attr in ('first_name', 'last_name', 'email'))
        user_data['title'] = get_title_uuid(self.regform, user_data['title'])
        return self.view_class.render_template(
            'display/regform_display.html',
            self.event,
            regform=self.regform,
            sections=get_event_section_data(self.regform),
            payment_conditions=payment_event_settings.get(
                self.event, 'conditions'),
            payment_enabled=self.event.has_feature('payment'),
            user_data=user_data,
            invitation=self.invitation,
            registration=self.registration,
            management=False,
            login_required=self.regform.require_login and not session.user,
            is_restricted_access=self.is_restricted_access)
Ejemplo n.º 2
0
    def _process(self):
        form = make_registration_form(self.regform, management=self.management, registration=self.registration)()

        if form.validate_on_submit():
            data = form.data
            notify_user = data.pop('notify_user', False)
            modify_registration(self.registration, data, management=self.management, notify_user=notify_user)
            return redirect(self.success_url)
        elif form.is_submitted():
            # not very pretty but usually this never happens thanks to client-side validation
            for error in form.error_list:
                flash(error, 'error')

        registration_data = {r.field_data.field.html_field_name: camelize_keys(r.user_data)
                             for r in self.registration.data}
        section_data = camelize_keys(get_event_section_data(self.regform, management=self.management,
                                                            registration=self.registration))

        registration_metadata = {
            'paid': self.registration.is_paid,
            'manager': self.management
        }

        return self.view_class.render_template(self.template_file, self.event, event=self.event,
                                               sections=section_data, regform=self.regform,
                                               registration_data=registration_data,
                                               registration_metadata=registration_metadata,
                                               registration=self.registration)
Ejemplo n.º 3
0
 def _process(self):
     return WPManageRegistration.render_template(
         'management/regform_modify.html',
         self.event,
         event=self.event_new,
         sections=get_event_section_data(self.regform, management=True),
         regform=self.regform)
Ejemplo n.º 4
0
 def _process(self):
     form = make_registration_form(self.regform, management=True)()
     if form.validate_on_submit():
         data = form.data
         session[
             'registration_notify_user_default'] = notify_user = data.pop(
                 'notify_user', False)
         create_registration(self.regform,
                             data,
                             management=True,
                             notify_user=notify_user)
         flash(_("The registration was created."), 'success')
         return redirect(url_for('.manage_reglist', self.regform))
     elif form.is_submitted():
         # not very pretty but usually this never happens thanks to client-side validation
         for error in form.error_list:
             flash(error, 'error')
     return WPManageRegistration.render_template(
         'display/regform_display.html',
         self._conf,
         event=self.event_new,
         sections=get_event_section_data(self.regform),
         regform=self.regform,
         post_url=url_for('.create_registration', self.regform),
         user_data=self._get_user_data(),
         management=True)
Ejemplo n.º 5
0
    def _process(self):
        form = make_registration_form(self.regform)()
        if form.validate_on_submit():
            registration = create_registration(self.regform, form.data, self.invitation)
            return redirect(url_for(".display_regform", registration.locator.registrant))
        elif form.is_submitted():
            # not very pretty but usually this never happens thanks to client-side validation
            for error in form.error_list:
                flash(error, "error")

        user_data = {t.name: getattr(session.user, t.name, None) if session.user else "" for t in PersonalDataType}
        if self.invitation:
            user_data.update((attr, getattr(self.invitation, attr)) for attr in ("first_name", "last_name", "email"))
        return self.view_class.render_template(
            "display/regform_display.html",
            self.event,
            event=self.event,
            sections=get_event_section_data(self.regform),
            regform=self.regform,
            payment_conditions=payment_event_settings.get(self.event, "conditions"),
            payment_enabled=self.event.has_feature("payment"),
            currency=payment_event_settings.get(self.event, "currency"),
            user_data=user_data,
            invitation=self.invitation,
            registration=self.registration,
            login_required=self.regform.require_login and not session.user,
        )
Ejemplo n.º 6
0
    def _process(self):
        form = make_registration_form(self.regform)()
        if form.validate_on_submit():
            registration = create_registration(self.regform, form.data, self.invitation)
            return redirect(url_for('.display_regform', registration.locator.registrant))
        elif form.is_submitted():
            # not very pretty but usually this never happens thanks to client-side validation
            for error in form.error_list:
                flash(error, 'error')

        user_data = {t.name: getattr(session.user, t.name, None) if session.user else '' for t in PersonalDataType}
        if self.invitation:
            user_data.update((attr, getattr(self.invitation, attr)) for attr in ('first_name', 'last_name', 'email'))
        user_data['title'] = get_title_uuid(self.regform, user_data['title'])
        return self.view_class.render_template('display/regform_display.html', self._conf, event=self.event_new,
                                               regform=self.regform,
                                               sections=get_event_section_data(self.regform),
                                               payment_conditions=payment_event_settings.get(self.event_new,
                                                                                             'conditions'),
                                               payment_enabled=self.event_new.has_feature('payment'),
                                               user_data=user_data,
                                               invitation=self.invitation,
                                               registration=self.registration,
                                               management=False,
                                               login_required=self.regform.require_login and not session.user)
Ejemplo n.º 7
0
 def _process(self):
     return WPManageRegistration.render_template(
         "management/regform_modify.html",
         self.event,
         event=self.event_new,
         sections=get_event_section_data(self.regform, management=True),
         regform=self.regform,
     )
Ejemplo n.º 8
0
 def _process(self):
     form = make_registration_form(self.regform)()
     if form.validate_on_submit():
         create_registration(self.regform, form.data, management=True)
         flash(_("The registration was created."), 'success')
         return redirect(url_for('.manage_reglist', self.regform))
     elif form.is_submitted():
         # not very pretty but usually this never happens thanks to client-side validation
         for error in form.error_list:
             flash(error, 'error')
     user_data = {t.name: getattr(self.user, t.name, None) if self.user else '' for t in PersonalDataType}
     return WPManageRegistration.render_template('display/regform_display.html', self.event, event=self.event,
                                                 sections=get_event_section_data(self.regform), regform=self.regform,
                                                 post_url=url_for('.create_registration', self.regform),
                                                 user_data=user_data, management=True)
Ejemplo n.º 9
0
 def _process(self):
     form = make_registration_form(self.regform, management=True)()
     if form.validate_on_submit():
         data = form.data
         session['registration_notify_user_default'] = notify_user = data.pop('notify_user', False)
         create_registration(self.regform, data, management=True, notify_user=notify_user)
         flash(_("The registration was created."), 'success')
         return redirect(url_for('.manage_reglist', self.regform))
     elif form.is_submitted():
         # not very pretty but usually this never happens thanks to client-side validation
         for error in form.error_list:
             flash(error, 'error')
     return WPManageRegistration.render_template('display/regform_display.html', self.event,
                                                 sections=get_event_section_data(self.regform), regform=self.regform,
                                                 post_url=url_for('.create_registration', self.regform),
                                                 user_data=self._get_user_data(), management=True)
Ejemplo n.º 10
0
 def _process(self):
     form = make_registration_form(self.regform, management=True)()
     if form.validate_on_submit():
         data = form.data
         notify_user = data.pop('notify_user', False)
         create_registration(self.regform, data, management=True, notify_user=notify_user)
         flash(_("The registration was created."), 'success')
         return redirect(url_for('.manage_reglist', self.regform))
     elif form.is_submitted():
         # not very pretty but usually this never happens thanks to client-side validation
         for error in form.error_list:
             flash(error, 'error')
     user_data = {t.name: getattr(self.user, t.name, None) if self.user else '' for t in PersonalDataType}
     return WPManageRegistration.render_template('display/regform_display.html', self.event, event=self.event,
                                                 sections=get_event_section_data(self.regform), regform=self.regform,
                                                 post_url=url_for('.create_registration', self.regform),
                                                 user_data=user_data, management=True)
Ejemplo n.º 11
0
    def _process(self):
        form = make_registration_form(self.regform,
                                      management=self.management,
                                      registration=self.registration)()

        verif_field, reg_field = ('', '')
        for k in form._fields:
            if form._fields[k].label.text.lower() == 'registration option':
                reg_field = form._fields[k].label.field_id
            if form._fields[k].label.text.lower() == 'verification code':
                verif_field = form._fields[k].label.field_id

        verif_code = ''
        if verif_field and form._fields[verif_field].data:
            verif_code = form._fields[verif_field].data
        elif request.form.get(verif_field):
            verif_code = request.form.get(verif_field)

        reg_opt = ''
        if reg_field and form._fields[reg_field].data:
            reg_opt = form._fields[reg_field].data

        opt_text = ''
        if reg_opt:
            for i in self.regform.active_fields:
                if i.title.lower() == 'registration option':
                    for k in i.data['captions']:
                        if k == next(iter(reg_opt)):
                            opt_text = i.data['captions'][k]
                else:
                    continue

        members_choice = False
        if opt_text and re.search(r' members', opt_text, flags=re.IGNORECASE):
            members_choice = True

        registration_data = {
            r.field_data.field.html_field_name: camelize_keys(r.user_data)
            for r in self.registration.data
        }

        reg_allowed = False
        if members_choice:
            str_list = [
                registration_data['first_name'] +
                registration_data['last_name'] + '/' + str(self.event.id) +
                '/' + datetime.today().strftime('%Y-%m-%d'),
                registration_data['first_name'] +
                registration_data['last_name'] + '/' + str(self.event.id) +
                '/' +
                (datetime.now() + timedelta(days=-1)).strftime('%Y-%m-%d'),
                registration_data['first_name'] +
                registration_data['last_name'] + '/' + str(self.event.id) +
                '/' +
                (datetime.now() + timedelta(days=-2)).strftime('%Y-%m-%d')
            ]
            for strn in str_list:
                sha = hmac.new(u''.encode(),
                               strn.lower().encode('utf-8'),
                               hashlib.sha256).hexdigest()
                md = hmac.new(''.encode(), sha.encode(),
                              hashlib.md5).hexdigest()
                enc = codecs.encode(codecs.decode(
                    md, 'hex'), 'base64').decode().replace("\n", "").replace(
                        "=", "").replace("/", "9").replace("+", "8")
                print(strn.lower())
                print(enc)
                if enc == verif_code:
                    reg_allowed = True

        setattr(self.regform, 'member_attempt', False)
        if (members_choice and reg_allowed) or not members_choice:
            if form.validate_on_submit():
                data = form.data
                notify_user = not self.management or data.pop(
                    'notify_user', False)
                if self.management:
                    session['registration_notify_user_default'] = notify_user
                modify_registration(self.registration,
                                    data,
                                    management=self.management,
                                    notify_user=notify_user)
                return redirect(self.success_url)
            elif form.is_submitted():
                # not very pretty but usually this never happens thanks to client-side validation
                for error in form.error_list:
                    flash(error, 'error')
        else:
            setattr(self.regform, 'member_attempt', True)

        section_data = camelize_keys(
            get_event_section_data(self.regform,
                                   management=self.management,
                                   registration=self.registration))

        registration_metadata = {
            'paid': self.registration.is_paid,
            'manager': self.management
        }

        return self.view_class.render_template(
            self.template_file,
            self.event,
            sections=section_data,
            regform=self.regform,
            registration_data=registration_data,
            registration_metadata=registration_metadata,
            registration=self.registration)
Ejemplo n.º 12
0
    def _process(self):
        form = make_registration_form(self.regform)()

        verif_field, reg_field = ('', '')
        for k in form._fields:
            if form._fields[k].label.text.lower() == 'registration option':
                reg_field = form._fields[k].label.field_id
            if form._fields[k].label.text.lower() == 'verification code':
                verif_field = form._fields[k].label.field_id

        verif_code = ''
        if verif_field and form._fields[verif_field].data:
            verif_code = form._fields[verif_field].data
        elif request.args.get('vc'):
            verif_code = request.args.get('vc')

        reg_opt = ''
        if reg_field and form._fields[reg_field].data:
            reg_opt = form._fields[reg_field].data

        opt_text = ''
        if reg_opt:
            for i in self.regform.active_fields:
                if i.title.lower() == 'registration option':
                    for k in i.data['captions']:
                        if k == next(iter(reg_opt)):
                            opt_text = i.data['captions'][k]
                else:
                    continue

        members_choice = False
        if opt_text and re.search(r' members', opt_text, flags=re.IGNORECASE):
            members_choice = True

        user_data = {
            t.name: getattr(session.user, t.name, None) if session.user else ''
            for t in PersonalDataType
        }

        reg_allowed = False
        if members_choice:
            str_list = [
                user_data['first_name'] + user_data['last_name'] + '/' +
                str(self.event.id) + '/' +
                datetime.today().strftime('%Y-%m-%d'),
                user_data['first_name'] + user_data['last_name'] + '/' +
                str(self.event.id) + '/' +
                (datetime.now() + timedelta(days=-1)).strftime('%Y-%m-%d'),
                user_data['first_name'] + user_data['last_name'] + '/' +
                str(self.event.id) + '/' +
                (datetime.now() + timedelta(days=-2)).strftime('%Y-%m-%d')
            ]
            for strn in str_list:
                sha = hmac.new(u''.encode(),
                               strn.lower().encode('utf-8'),
                               hashlib.sha256).hexdigest()
                md = hmac.new(''.encode(), sha.encode(),
                              hashlib.md5).hexdigest()
                enc = codecs.encode(codecs.decode(
                    md, 'hex'), 'base64').decode().replace("\n", "").replace(
                        "=", "").replace("/", "9").replace("+", "8")
                if enc == verif_code:
                    reg_allowed = True

        setattr(self.regform, 'member_attempt', False)
        if (members_choice and reg_allowed) or not members_choice:
            if form.validate_on_submit() and not self.regform.limit_reached:
                registration = create_registration(self.regform, form.data,
                                                   self.invitation)
                return redirect(
                    url_for('.display_regform',
                            registration.locator.registrant))
            elif form.is_submitted():
                # not very pretty but usually this never happens thanks to client-side validation
                for error in form.error_list:
                    flash(error, 'error')
        else:
            setattr(self.regform, 'member_attempt', True)

        if self.invitation:
            user_data.update((attr, getattr(self.invitation, attr))
                             for attr in ('first_name', 'last_name', 'email'))
        user_data['title'] = get_title_uuid(self.regform, user_data['title'])

        if verif_field:
            user_data[verif_field] = request.args.get('vc')

        return self.view_class.render_template(
            'display/regform_display.html',
            self.event,
            regform=self.regform,
            sections=get_event_section_data(self.regform),
            payment_conditions=payment_event_settings.get(
                self.event, 'conditions'),
            payment_enabled=self.event.has_feature('payment'),
            vc=request.args.get('vc'),
            user_data=user_data,
            invitation=self.invitation,
            registration=self.registration,
            management=False,
            login_required=self.regform.require_login and not session.user)
Ejemplo n.º 13
0
 def _process(self):
     return WPManageRegistration.render_template('management/regform_modify.html', self.event, event=self.event_new,
                                                 sections=get_event_section_data(self.regform, management=True),
                                                 regform=self.regform,
                                                 currency=event_settings.get(self.event, 'currency'))