Example #1
0
 def link_badge(self, session, applicant_id, attendee_id):
     attendee = session.attendee(attendee_id)
     try:
         applicant = session.mits_applicant(applicant_id)
         applicant.attendee = attendee
         add_opt(attendee.ribbon_ints, c.MIVS)
         session.commit()
     except Exception:
         log.error('unexpected error linking applicant to a badge', exc_info=True)
         return {'error': 'Unexpected error: unable to link applicant to badge.'}
     else:
         return {
             'name': applicant.full_name,
             'comp_count': applicant.team.comped_badge_count
         }
    def link_badge(self, session, applicant_id, attendee_id):
        ids = []
        try:
            attendee = session.attendee(attendee_id)
            if attendee.badge_type != c.GUEST_BADGE:
                attendee.ribbon = add_opt(attendee.ribbon_ints,
                                          c.PANELIST_RIBBON)

            pa = session.panel_applicant(applicant_id)
            applicants = session.query(PanelApplicant).filter_by(
                first_name=pa.first_name,
                last_name=pa.last_name,
                email=pa.email)
            for applicant in applicants:
                ids.append(applicant.id)
                applicant.attendee_id = attendee_id

            session.commit()
        except Exception:
            log.error('unexpected error linking panelist to a badge',
                      exc_info=True)
            return {
                'error': 'Unexpected error: unable to link applicant to badge.'
            }
        else:
            return {'linked': ids, 'name': pa.full_name}
Example #3
0
 def child_ribbon_or_not(self):
     if self.age_group in [c.UNDER_6, c.UNDER_13]:
         self.ribbon = add_opt(self.ribbon_ints, c.UNDER_13)
     elif c.UNDER_13 in self.ribbon_ints and self.age_group not in [
             c.UNDER_6, c.UNDER_13
     ]:
         self.ribbon = remove_opt(self.ribbon_ints, c.UNDER_13)
Example #4
0
    def delete(self, session, id, return_to='index?'):
        attendee = session.attendee(id, allow_invalid=True)
        if attendee.group:
            if attendee.group.leader_id == attendee.id:
                message = 'You cannot delete the leader of a group; ' \
                    'you must make someone else the leader first, or just delete the entire group'
            elif attendee.is_unassigned:
                session.delete_from_group(attendee, attendee.group)
                message = 'Unassigned badge removed.'
            else:
                replacement_attendee = Attendee(**{attr: getattr(attendee, attr) for attr in [
                    'group', 'registered', 'badge_type', 'badge_num', 'paid', 'amount_paid', 'amount_extra'
                ]})
                if replacement_attendee.group and replacement_attendee.group.is_dealer:
                    replacement_attendee.ribbon = add_opt(replacement_attendee.ribbon_ints, c.DEALER_RIBBON)
                session.add(replacement_attendee)
                attendee._skip_badge_shift_on_delete = True
                session.delete_from_group(attendee, attendee.group)
                message = 'Attendee deleted, but this badge is still ' \
                    'available to be assigned to someone else in the same group'
        else:
            session.delete(attendee)
            message = 'Attendee deleted'

        raise HTTPRedirect(return_to + ('' if return_to[-1] == '?' else '&') + 'message={}', message)
    def delete(self, session, id, return_to='index?', **params):
        attendee = session.attendee(id, allow_invalid=True)
        if attendee.group:
            if attendee.group.leader_id == attendee.id:
                message = 'You cannot delete the leader of a group; ' \
                    'you must make someone else the leader first, or just delete the entire group'
            elif attendee.is_unassigned:
                session.delete_from_group(attendee, attendee.group)
                message = 'Unassigned badge removed.'
            else:
                replacement_attendee = Attendee(
                    **{
                        attr: getattr(attendee, attr)
                        for attr in [
                            'group', 'registered', 'badge_type', 'badge_num',
                            'paid', 'amount_paid_override', 'amount_extra'
                        ]
                    })
                if replacement_attendee.group and replacement_attendee.group.is_dealer:
                    replacement_attendee.ribbon = add_opt(
                        replacement_attendee.ribbon_ints, c.DEALER_RIBBON)
                session.add(replacement_attendee)
                attendee._skip_badge_shift_on_delete = True
                session.delete_from_group(attendee, attendee.group)
                message = 'Attendee deleted, but this badge is still ' \
                    'available to be assigned to someone else in the same group'
        else:
            session.delete(attendee)
            message = 'Attendee deleted'

        q_or_a = '?' if '?' not in return_to else '&'
        raise HTTPRedirect(
            return_to + ('' if return_to[-1] == '?' else q_or_a) +
            'message={}', message)
    def guest(self, session, poc_id, return_to='', message='', **params):
        """
        In some cases, we want pre-existing attendees (e.g., guests) to submit panel ideas.
        This submission form bypasses the need to enter in one's personal and contact info
        in favor of having the panel application automatically associated with an attendee
        record, both as the submitter and as the Point of Contact.
        """

        app = session.panel_application(
            params,
            checkgroups=PanelApplication.all_checkgroups,
            restricted=True,
            ignore_csrf=True)
        app.poc_id = poc_id
        attendee = session.attendee(id=poc_id)
        if attendee.badge_type != c.GUEST_BADGE:
            add_opt(attendee.ribbon_ints, c.PANELIST_RIBBON)
        panelist = PanelApplicant(app_id=app.id,
                                  attendee_id=attendee.id,
                                  submitter=True,
                                  first_name=attendee.first_name,
                                  last_name=attendee.last_name,
                                  email=attendee.email,
                                  cellphone=attendee.cellphone)
        other_panelists = compile_other_panelists_from_params(app, **params)
        go_to = return_to if 'ignore_return_to' not in params and return_to \
            else 'guest?poc_id=' + poc_id + '&return_to=' + return_to

        if cherrypy.request.method == 'POST':
            message = process_panel_app(session, app, panelist,
                                        other_panelists, **params)
            if not message:
                raise HTTPRedirect(
                    go_to + '&message={}',
                    'Your panel application has been submitted')

        return {
            'app': app,
            'message': message,
            'attendee': attendee,
            'poc_id': poc_id,
            'other_panelists': other_panelists,
            'return_to': return_to
        }
    def staffing_badge_and_ribbon_adjustments(self):
        if self.badge_type == c.STAFF_BADGE or c.STAFF_RIBBON in self.ribbon_ints:
            self.ribbon = remove_opt(self.ribbon_ints, c.VOLUNTEER_RIBBON)

        elif self.staffing and self.badge_type != c.STAFF_BADGE \
                and c.STAFF_RIBBON not in self.ribbon_ints and c.VOLUNTEER_RIBBON not in self.ribbon_ints:
            self.ribbon = add_opt(self.ribbon_ints, c.VOLUNTEER_RIBBON)

        if self.badge_type == c.STAFF_BADGE or c.STAFF_RIBBON in self.ribbon_ints:
            self.staffing = True
            if not self.overridden_price and self.paid in [c.NOT_PAID, c.PAID_BY_GROUP]:
                self.paid = c.NEED_NOT_PAY
Example #8
0
    def guest(self, session, poc_id, return_to='', message='', **params):
        """
        In some cases, we want pre-existing attendees (e.g., guests) to submit panel ideas.
        This submission form bypasses the need to enter in one's personal and contact info
        in favor of having the panel application automatically associated with an attendee
        record, both as the submitter and as the Point of Contact.
        """

        app = session.panel_application(
            params, checkgroups=PanelApplication.all_checkgroups, restricted=True, ignore_csrf=True)
        app.poc_id = poc_id
        attendee = session.attendee(id=poc_id)
        if attendee.badge_type != c.GUEST_BADGE:
            add_opt(attendee.ribbon_ints, c.PANELIST_RIBBON)
        panelist = PanelApplicant(
            app_id=app.id,
            attendee_id=attendee.id,
            submitter=True,
            first_name=attendee.first_name,
            last_name=attendee.last_name,
            email=attendee.email,
            cellphone=attendee.cellphone
        )
        other_panelists = compile_other_panelists_from_params(app, **params)
        go_to = return_to if 'ignore_return_to' not in params and return_to \
            else 'guest?poc_id=' + poc_id + '&return_to=' + return_to

        if cherrypy.request.method == 'POST':
            message = process_panel_app(session, app, panelist, other_panelists, **params)
            if not message:
                raise HTTPRedirect(go_to + '&message={}', 'Your panel application has been submitted')

        return {
            'app': app,
            'message': message,
            'attendee': attendee,
            'poc_id': poc_id,
            'other_panelists': other_panelists,
            'return_to': return_to
        }
Example #9
0
 def _cost_and_leader(self):
     assigned = [a for a in self.attendees if not a.is_unassigned]
     if len(assigned) == 1:
         [self.leader] = assigned
     if self.auto_recalc:
         self.cost = self.default_cost
     elif not self.cost:
         self.cost = 0
     if self.status == c.APPROVED and not self.approved:
         self.approved = datetime.now(UTC)
     if self.leader and self.is_dealer:
         self.leader.ribbon = add_opt(self.leader.ribbon_ints, c.DEALER_RIBBON)
     if not self.is_unpaid:
         for a in self.attendees:
             a.presave_adjustments()
Example #10
0
    def _badge_adjustments(self):
        from uber.badge_funcs import needs_badge_num
        if self.badge_type == c.PSEUDO_DEALER_BADGE:
            self.ribbon = add_opt(self.ribbon_ints, c.DEALER_RIBBON)

        self.badge_type = self.badge_type_real

        old_type = self.orig_value_of('badge_type')
        old_num = self.orig_value_of('badge_num')

        if not needs_badge_num(self):
            self.badge_num = None

        if old_type != self.badge_type or old_num != self.badge_num:
            self.session.update_badge(self, old_type, old_num)
        elif needs_badge_num(self) and not self.badge_num:
            self.badge_num = self.session.get_next_badge_num(self.badge_type)
Example #11
0
 def _cost_and_leader(self):
     assigned = [a for a in self.attendees if not a.is_unassigned]
     if len(assigned) == 1:
         [self.leader] = assigned
     if self.auto_recalc:
         self.cost = self.default_cost
     elif not self.cost:
         self.cost = 0
     if not self.amount_paid:
         self.amount_paid = 0
     if not self.amount_refunded:
         self.amount_refunded = 0
     if self.status == c.APPROVED and not self.approved:
         self.approved = datetime.now(UTC)
     if self.leader and self.is_dealer:
         self.leader.ribbon = add_opt(self.leader.ribbon_ints, c.DEALER_RIBBON)
     if not self.is_unpaid:
         for a in self.attendees:
             a.presave_adjustments()
Example #12
0
    def _staffing_adjustments(self):
        if self.is_dept_head:
            self.staffing = True
            if c.SHIFT_CUSTOM_BADGES or \
                    c.STAFF_BADGE not in c.PREASSIGNED_BADGE_TYPES:
                self.badge_type = c.STAFF_BADGE
            if self.paid == c.NOT_PAID:
                self.paid = c.NEED_NOT_PAY
        elif c.VOLUNTEER_RIBBON in self.ribbon_ints and self.is_new:
            self.staffing = True

        if not self.is_new:
            old_ribbon = map(int, self.orig_value_of('ribbon').split(',')) \
                if self.orig_value_of('ribbon') else []
            old_staffing = self.orig_value_of('staffing')

            if self.staffing and not old_staffing or \
                    c.VOLUNTEER_RIBBON in self.ribbon_ints and \
                    c.VOLUNTEER_RIBBON not in old_ribbon:
                self.staffing = True

            elif old_staffing and not self.staffing \
                    or c.VOLUNTEER_RIBBON not in self.ribbon_ints \
                    and c.VOLUNTEER_RIBBON in old_ribbon \
                    and not self.is_dept_head:
                self.unset_volunteering()

        if self.badge_type == c.STAFF_BADGE:
            self.ribbon = remove_opt(self.ribbon_ints, c.VOLUNTEER_RIBBON)

        elif self.staffing and self.badge_type != c.STAFF_BADGE and \
                c.VOLUNTEER_RIBBON not in self.ribbon_ints:
            self.ribbon = add_opt(self.ribbon_ints, c.VOLUNTEER_RIBBON)

        if self.badge_type == c.STAFF_BADGE:
            self.staffing = True
            if not self.overridden_price \
                    and self.paid in [c.NOT_PAID, c.PAID_BY_GROUP]:
                self.paid = c.NEED_NOT_PAY
Example #13
0
 def child_ribbon_or_not(self):
     if self.age_group in [c.UNDER_6, c.UNDER_13]:
         self.ribbon = add_opt(self.ribbon_ints, c.UNDER_13)
     elif c.UNDER_13 in self.ribbon_ints and self.age_group not in [c.UNDER_6, c.UNDER_13]:
         self.ribbon = remove_opt(self.ribbon_ints, c.UNDER_13)
Example #14
0
 def child_badge(self):
     if self.age_group not in [c.UNDER_21, c.OVER_21, c.AGE_UNKNOWN
                               ] and self.badge_type == c.ATTENDEE_BADGE:
         self.badge_type = c.CHILD_BADGE
         if self.age_group in [c.UNDER_6, c.UNDER_13]:
             self.ribbon = add_opt(self.ribbon_ints, c.UNDER_13)
Example #15
0
 def test_add_opt_empty(self):
     assert str(c.DEALER_RIBBON) == add_opt(Attendee().ribbon_ints, c.DEALER_RIBBON)
    def form(self, session, message='', edit_id=None, **params):
        """
        Our production NGINX config caches the page at /preregistration/form.
        Since it's cached, we CAN'T return a session cookie with the page. We
        must POST to a different URL in order to bypass the cache and get a
        valid session cookie. Thus, this page is also exposed as "post_form".
        """
        params['id'] = 'None'   # security!
        group = Group()

        if edit_id is not None:
            attendee = self._get_unsaved(
                edit_id,
                if_not_found=HTTPRedirect('form?message={}', 'That preregistration has already been finalized'))
            attendee.apply(params, restricted=True)
            params.setdefault('pii_consent', True)
        else:
            attendee = session.attendee(params, ignore_csrf=True, restricted=True)

            if attendee.badge_type == c.PSEUDO_DEALER_BADGE:
                if not c.DEALER_REG_OPEN:
                    return render('static_views/dealer_reg_closed.html') if c.AFTER_DEALER_REG_START \
                        else render('static_views/dealer_reg_not_open.html')

                # Both the Attendee class and Group class have identically named
                # address fields. In order to distinguish the two sets of address
                # fields in the params, the Group fields are prefixed with "group_"
                # when the form is submitted. To prevent instantiating the Group object
                # with the Attendee's address fields, we must clone the params and
                # rename all the "group_" fields.
                group_params = dict(params)
                for field_name in ['country', 'region', 'zip_code', 'address1', 'address2', 'city']:
                    group_params[field_name] = params.get('group_{}'.format(field_name), '')
                    if params.get('copy_address'):
                        params[field_name] = group_params[field_name]
                        attendee.apply(params)

                group = session.group(group_params, ignore_csrf=True, restricted=True)

        if c.PAGE == 'post_dealer':
            attendee.badge_type = c.PSEUDO_DEALER_BADGE
        elif not attendee.badge_type:
            attendee.badge_type = c.ATTENDEE_BADGE

        if cherrypy.request.method == 'POST' or edit_id is not None:
            message = check_pii_consent(params, attendee) or message
            if not message and attendee.badge_type not in c.PREREG_BADGE_TYPES:
                message = 'Invalid badge type!'
            if not message and c.BADGE_PROMO_CODES_ENABLED and params.get('promo_code'):
                if session.lookup_promo_or_group_code(params.get('promo_code'), PromoCodeGroup):
                    Charge.universal_promo_codes[attendee.id] = params.get('promo_code')
                message = session.add_promo_code_to_attendee(attendee, params.get('promo_code'))

        if message:
            return {
                'message':    message,
                'attendee':   attendee,
                'group':      group,
                'edit_id':    edit_id,
                'affiliates': session.affiliates(),
                'cart_not_empty': Charge.unpaid_preregs,
                'copy_address': params.get('copy_address'),
                'promo_code_code': params.get('promo_code', ''),
                'pii_consent': params.get('pii_consent'),
                'name': params.get('name', ''),
                'badges': params.get('badges', 0),
            }

        if 'first_name' in params:
            if attendee.badge_type == c.PSEUDO_DEALER_BADGE:
                message = check(group, prereg=True)

            message = message or check(attendee, prereg=True)

            if attendee.badge_type in [c.PSEUDO_GROUP_BADGE, c.PSEUDO_DEALER_BADGE]:
                message = "Please enter a group name" if not params.get('name') else message
            else:
                params['badges'] = 0
                params['name'] = ''

            if not message:
                if attendee.badge_type == c.PSEUDO_DEALER_BADGE:
                    attendee.paid = c.PAID_BY_GROUP
                    group.attendees = [attendee]
                    session.assign_badges(group, params['badges'])
                    group.status = c.WAITLISTED if c.DEALER_REG_SOFT_CLOSED else c.UNAPPROVED
                    attendee.ribbon = add_opt(attendee.ribbon_ints, c.DEALER_RIBBON)
                    attendee.badge_type = c.ATTENDEE_BADGE

                    session.add_all([attendee, group])
                    session.commit()
                    try:
                        send_email.delay(
                            c.MARKETPLACE_EMAIL,
                            c.MARKETPLACE_EMAIL,
                            '{} Received'.format(c.DEALER_APP_TERM.title()),
                            render('emails/dealers/reg_notification.txt', {'group': group}, encoding=None),
                            model=group.to_dict('id'))
                        send_email.delay(
                            c.MARKETPLACE_EMAIL,
                            attendee.email,
                            '{} Received'.format(c.DEALER_APP_TERM.title()),
                            render('emails/dealers/application.html', {'group': group}, encoding=None),
                            'html',
                            model=group.to_dict('id'))
                    except Exception:
                        log.error('unable to send marketplace application confirmation email', exc_info=True)
                    raise HTTPRedirect('dealer_confirmation?id={}', group.id)
                else:
                    track_type = c.UNPAID_PREREG
                    if attendee.id in Charge.unpaid_preregs:
                        track_type = c.EDITED_PREREG
                        # Clear out any previously cached targets, in case the unpaid badge
                        # has been edited and changed from a single to a group or vice versa.
                        del Charge.unpaid_preregs[attendee.id]

                    Charge.unpaid_preregs[attendee.id] = Charge.to_sessionized(attendee,
                                                                               params.get('name'),
                                                                               params.get('badges'))
                    Tracking.track(track_type, attendee)

                if session.attendees_with_badges().filter_by(
                        first_name=attendee.first_name, last_name=attendee.last_name, email=attendee.email).count():

                    raise HTTPRedirect('duplicate?id={}', group.id if attendee.paid == c.PAID_BY_GROUP else attendee.id)

                if attendee.banned:
                    raise HTTPRedirect('banned?id={}', group.id if attendee.paid == c.PAID_BY_GROUP else attendee.id)

                if c.PREREG_REQUEST_HOTEL_INFO_OPEN:
                    hotel_page = 'hotel?edit_id={}' if edit_id else 'hotel?id={}'
                    raise HTTPRedirect(hotel_page, group.id if attendee.paid == c.PAID_BY_GROUP else attendee.id)
                else:
                    raise HTTPRedirect('index')

        else:
            if edit_id is None:
                if attendee.badge_type == c.PSEUDO_DEALER_BADGE:
                    # All new dealer signups should default to receiving the
                    # hotel info email, even if the deadline has passed.
                    # There's a good chance some dealers will apply for a table
                    # AFTER the hotel booking deadline, but BEFORE the hotel
                    # booking is sent out. This ensures they'll still receive
                    # the email, as requested by the Marketplace Department.
                    attendee.requested_hotel_info = True

            if attendee.badge_type == c.PSEUDO_DEALER_BADGE and c.DEALER_REG_SOFT_CLOSED:
                message = '{} is closed, but you can ' \
                    'fill out this form to add yourself to our waitlist'.format(c.DEALER_REG_TERM.title())

        promo_code_group = None
        if attendee.promo_code:
            promo_code_group = session.query(PromoCode).filter_by(code=attendee.promo_code.code).first().group

        return {
            'message':    message,
            'attendee':   attendee,
            'badges': params.get('badges', 0),
            'name': params.get('name', ''),
            'group':      group,
            'promo_code_group': promo_code_group,
            'edit_id':    edit_id,
            'affiliates': session.affiliates(),
            'cart_not_empty': Charge.unpaid_preregs,
            'copy_address': params.get('copy_address'),
            'promo_code_code': params.get('promo_code', ''),
            'pii_consent': params.get('pii_consent'),
        }
Example #17
0
 def test_add_opt_duplicate(self):
     assert str(c.DEALER_RIBBON) == add_opt(Attendee(ribbon=c.DEALER_RIBBON).ribbon_ints, c.DEALER_RIBBON)
Example #18
0
    def form(self, session, message='', edit_id=None, **params):
        """
        Our production NGINX config caches the page at /preregistration/form.
        Since it's cached, we CAN'T return a session cookie with the page. We
        must POST to a different URL in order to bypass the cache and get a
        valid session cookie. Thus, this page is also exposed as "post_form".
        """
        params['id'] = 'None'   # security!
        group = Group()

        if edit_id is not None:
            attendee = self._get_unsaved(
                edit_id,
                if_not_found=HTTPRedirect('form?message={}', 'That preregistration has already been finalized'))
            attendee.apply(params, restricted=True)
            params.setdefault('pii_consent', True)
        else:
            attendee = session.attendee(params, ignore_csrf=True, restricted=True)

            if attendee.badge_type == c.PSEUDO_DEALER_BADGE:
                if not c.DEALER_REG_OPEN:
                    return render('static_views/dealer_reg_closed.html') if c.AFTER_DEALER_REG_START \
                        else render('static_views/dealer_reg_not_open.html')

                # Both the Attendee class and Group class have identically named
                # address fields. In order to distinguish the two sets of address
                # fields in the params, the Group fields are prefixed with "group_"
                # when the form is submitted. To prevent instantiating the Group object
                # with the Attendee's address fields, we must clone the params and
                # rename all the "group_" fields.
                group_params = dict(params)
                for field_name in ['country', 'region', 'zip_code', 'address1', 'address2', 'city']:
                    group_params[field_name] = params.get('group_{}'.format(field_name), '')
                    if params.get('copy_address'):
                        params[field_name] = group_params[field_name]

                group = session.group(group_params, ignore_csrf=True, restricted=True)

        if c.PAGE == 'post_dealer':
            attendee.badge_type = c.PSEUDO_DEALER_BADGE
        elif not attendee.badge_type:
            attendee.badge_type = c.ATTENDEE_BADGE

        if cherrypy.request.method == 'POST' or edit_id is not None:
            message = check_pii_consent(params, attendee) or message
            if not message and attendee.badge_type not in c.PREREG_BADGE_TYPES:
                message = 'Invalid badge type!'
            if not message and c.BADGE_PROMO_CODES_ENABLED and params.get('promo_code'):
                message = session.add_promo_code_to_attendee(attendee, params.get('promo_code'))

        if message:
            return {
                'message':    message,
                'attendee':   attendee,
                'group':      group,
                'edit_id':    edit_id,
                'affiliates': session.affiliates(),
                'cart_not_empty': Charge.unpaid_preregs,
                'copy_address': params.get('copy_address'),
                'promo_code': params.get('promo_code', ''),
                'pii_consent': params.get('pii_consent'),
            }

        if 'first_name' in params:
            message = check(attendee, prereg=True)
            if not message and attendee.badge_type == c.PSEUDO_DEALER_BADGE:
                message = check(group, prereg=True)

            if attendee.badge_type in [c.PSEUDO_GROUP_BADGE, c.PSEUDO_DEALER_BADGE]:
                message = "Please enter a group name" if not params.get('name') else ''
            else:
                params['badges'] = 0
                params['name'] = ''

            if not message:
                if attendee.badge_type == c.PSEUDO_DEALER_BADGE:
                    attendee.paid = c.PAID_BY_GROUP
                    group.attendees = [attendee]
                    session.assign_badges(group, params['badges'])
                    group.status = c.WAITLISTED if c.DEALER_REG_SOFT_CLOSED else c.UNAPPROVED
                    attendee.ribbon = add_opt(attendee.ribbon_ints, c.DEALER_RIBBON)
                    attendee.badge_type = c.ATTENDEE_BADGE

                    session.add_all([attendee, group])
                    session.commit()
                    try:
                        send_email.delay(
                            c.MARKETPLACE_EMAIL,
                            c.MARKETPLACE_EMAIL,
                            'Dealer Application Received',
                            render('emails/dealers/reg_notification.txt', {'group': group}, encoding=None),
                            model=group.to_dict('id'))
                        send_email.delay(
                            c.MARKETPLACE_EMAIL,
                            attendee.email,
                            'Dealer Application Received',
                            render('emails/dealers/application.html', {'group': group}, encoding=None),
                            'html',
                            model=group.to_dict('id'))
                    except Exception:
                        log.error('unable to send marketplace application confirmation email', exc_info=True)
                    raise HTTPRedirect('dealer_confirmation?id={}', group.id)
                else:
                    track_type = c.UNPAID_PREREG
                    if attendee.id in Charge.unpaid_preregs:
                        track_type = c.EDITED_PREREG
                        # Clear out any previously cached targets, in case the unpaid badge
                        # has been edited and changed from a single to a group or vice versa.
                        del Charge.unpaid_preregs[attendee.id]

                    Charge.unpaid_preregs[attendee.id] = Charge.to_sessionized(attendee,
                                                                               params.get('name'),
                                                                               params.get('badges'))
                    Tracking.track(track_type, attendee)

                if session.attendees_with_badges().filter_by(
                        first_name=attendee.first_name, last_name=attendee.last_name, email=attendee.email).count():

                    raise HTTPRedirect('duplicate?id={}', group.id if attendee.paid == c.PAID_BY_GROUP else attendee.id)

                if attendee.banned:
                    raise HTTPRedirect('banned?id={}', group.id if attendee.paid == c.PAID_BY_GROUP else attendee.id)

                if c.PREREG_REQUEST_HOTEL_INFO_OPEN:
                    hotel_page = 'hotel?edit_id={}' if edit_id else 'hotel?id={}'
                    raise HTTPRedirect(hotel_page, group.id if attendee.paid == c.PAID_BY_GROUP else attendee.id)
                else:
                    raise HTTPRedirect('index')

        else:
            if edit_id is None:
                if attendee.badge_type == c.PSEUDO_DEALER_BADGE:
                    # All new dealer signups should default to receiving the
                    # hotel info email, even if the deadline has passed.
                    # There's a good chance some dealers will apply for a table
                    # AFTER the hotel booking deadline, but BEFORE the hotel
                    # booking is sent out. This ensures they'll still receive
                    # the email, as requested by the Marketplace Department.
                    attendee.requested_hotel_info = True

            if attendee.badge_type == c.PSEUDO_DEALER_BADGE and c.DEALER_REG_SOFT_CLOSED:
                message = 'Dealer registration is closed, but you can ' \
                    'fill out this form to add yourself to our waitlist'

        promo_code_group = None
        if attendee.promo_code:
            promo_code_group = session.query(PromoCode).filter_by(code=attendee.promo_code.code).first().group

        return {
            'message':    message,
            'attendee':   attendee,
            'group':      group,
            'promo_code_group': promo_code_group,
            'edit_id':    edit_id,
            'affiliates': session.affiliates(),
            'cart_not_empty': Charge.unpaid_preregs,
            'copy_address': params.get('copy_address'),
            'promo_code': params.get('promo_code', ''),
            'pii_consent': params.get('pii_consent'),
        }
Example #19
0
 def test_add_opt_second(self):
     # add_opt doesn't preserve order and isn't meant to, so convert both values to sets
     # otherwise this unit test fails randomly
     assert set([str(c.VOLUNTEER_RIBBON), str(c.DEALER_RIBBON)]) == set(
         add_opt(Attendee(ribbon=c.VOLUNTEER_RIBBON).ribbon_ints, c.DEALER_RIBBON).split(','))
Example #20
0
 def test_add_opt_duplicate(self):
     assert str(c.DEALER_RIBBON) == add_opt(Attendee(ribbon=c.DEALER_RIBBON).ribbon_ints, c.DEALER_RIBBON)
Example #21
0
 def test_add_opt_empty(self):
     assert str(c.DEALER_RIBBON) == add_opt(Attendee().ribbon_ints, c.DEALER_RIBBON)
Example #22
0
 def roughing_it(self):
     if self.site_type == c.PRIMITIVE:
         self.ribbon = add_opt(self.ribbon_ints, c.ROUGHING_IT)
Example #23
0
 def child_badge(self):
     if self.age_group not in [c.UNDER_21, c.OVER_21, c.AGE_UNKNOWN] and self.badge_type == c.ATTENDEE_BADGE:
         self.badge_type = c.CHILD_BADGE
         if self.age_group in [c.UNDER_6, c.UNDER_13]:
             self.ribbon = add_opt(self.ribbon_ints, c.UNDER_13)
Example #24
0
 def test_add_opt_second(self):
     # add_opt doesn't preserve order and isn't meant to, so convert both values to sets
     # otherwise this unit test fails randomly
     assert set([str(c.VOLUNTEER_RIBBON), str(c.DEALER_RIBBON)]) == set(
         add_opt(Attendee(ribbon=c.VOLUNTEER_RIBBON).ribbon_ints, c.DEALER_RIBBON).split(','))
Example #25
0
 def roughing_it(self):
     if self.site_type == c.PRIMITIVE:
         self.ribbon = add_opt(self.ribbon_ints, c.ROUGHING_IT)