Esempio 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)
Esempio n. 2
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)
Esempio n. 3
0
 def _get_user_data(self, user):
     if user is None:
         return {}
     user_data = {
         t.name: getattr(user, t.name, None)
         for t in PersonalDataType
     }
     user_data['title'] = get_title_uuid(self.regform, user_data['title'])
     return user_data
Esempio n. 4
0
 def _register_user(self, user, notify):
     # Fill only the personal data fields, custom fields are left empty.
     data = {
         pdt.name: getattr(user, pdt.name, None)
         for pdt in PersonalDataType
     }
     data['title'] = get_title_uuid(self.regform, data['title'])
     with db.session.no_autoflush:
         create_registration(self.regform,
                             data,
                             management=True,
                             notify_user=notify)
Esempio n. 5
0
 def _get_user_data(self):
     user_id = request.args.get('user')
     if user_id is None:
         return {}
     elif user_id.isdigit():
         # existing indico user
         user = User.find_first(id=user_id, is_deleted=False)
         user_data = {t.name: getattr(user, t.name, None) if user else '' for t in PersonalDataType}
     else:
         # non-indico user
         data = GenericCache('pending_identities').get(user_id, {})
         user_data = {t.name: data.get(t.name) for t in PersonalDataType}
     user_data['title'] = get_title_uuid(self.regform, user_data['title'])
     return user_data
Esempio n. 6
0
 def _get_user_data(self):
     user_id = request.args.get('user')
     if user_id is None:
         return {}
     elif user_id.isdigit():
         # existing indico user
         user = User.find_first(id=user_id, is_deleted=False)
         user_data = {t.name: getattr(user, t.name, None) if user else '' for t in PersonalDataType}
     else:
         # non-indico user
         data = GenericCache('pending_identities').get(user_id, {})
         user_data = {t.name: data.get(t.name) for t in PersonalDataType}
     user_data['title'] = get_title_uuid(self.regform, user_data['title'])
     return user_data
Esempio n. 7
0
 def _register_user(self, user, notify):
     # Fill only the personal data fields, custom fields are left empty.
     data = {pdt.name: getattr(user, pdt.name, None) for pdt in PersonalDataType}
     data['title'] = get_title_uuid(self.regform, data['title'])
     with db.session.no_autoflush:
         create_registration(self.regform, data, management=True, notify_user=notify)
Esempio n. 8
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)