def check_in_sign(user_id): user = User.query.filter_by(id=user_id).first() if user is None: flash('User does not exist', 'error') return redirect(url_for('manual-check-in')) if request.method == 'GET': date_fmt = '%B %d, %Y' today = datetime.now(tz).date() return render_template('users/sign.html', user=user, date=today.strftime(date_fmt), check_in=True) signed_info = extract_waiver_info(user) if 'error' in signed_info: flash(signed_info['error'], 'error') return redirect(request.url) waiver = Waiver(signed_info) DB.session.add(waiver) DB.session.commit() user.status = status.CONFIRMED DB.session.add(user) DB.session.commit() batch.keen_add_event(user.id, 'waivers_signed', waiver.time_signed) flash( "You've successfully confirmed your invitation to {}".format( settings.HACKATHON_NAME), 'success') age = calculate_age(user.birthday) return render_template('users/admin/confirm_check_in.html', user=user, age=age, requires_eid=False)
def complete_user_sign_up(): if settings.REGISTRATION_CLOSED: current_user.status = status.LATE else: current_user.status = status.WAITLISTED if settings.SENT_ACCEPTANCES else status.PENDING current_user.time_applied = datetime.utcnow() batch.keen_add_event(current_user.id, 'sign_ups', current_user.time_applied) try: DB.session.add(current_user) DB.session.commit() except DataError as e: flash( 'There was an error with your registration information. Please try again.', 'error') return redirect(request.url) g.log = g.log.bind(email=current_user.email) g.log.info('User successfully applied') if current_user.confirmed: batch.send_applied_email(current_user) flash( 'Congratulations! You have successfully applied for {0}! You should receive a confirmation email shortly' .format(settings.HACKATHON_NAME), 'success') return redirect(url_for('dashboard')) elif current_user.type == 'local': # we couldn't send these emails to people who signed up locally # until now since we didn't have their first names batch.send_confirmation_email(current_user) flash( 'Congratulations! You have successfully applied for {0}! You must confirm your email before your application will be considered!' .format(settings.HACKATHON_NAME), 'warning') return redirect(url_for('dashboard'))
def sign(): if current_user.status not in [ status.ADMIN, status.SIGNING ]: # they aren't allowed to accept their invitation message = { status.NEW: "You haven't completed your application for {0}! Please submit your application before visiting this page!" .format(settings.HACKATHON_NAME), status.PENDING: "You haven't been accepted to {0}! Please wait for your invitation before visiting this page!" .format(settings.HACKATHON_NAME), status.CONFIRMED: "You've already accepted your invitation to {0}! We look forward to seeing you here!" .format(settings.HACKATHON_NAME), status.REJECTED: "You've already rejected your {0} invitation. Unfortunately, for space considerations you cannot change your response." .format(settings.HACKATHON_NAME), None: "Corporate users cannot view this page." } if current_user.status in message: flash(message[current_user.status], 'error') return redirect(url_for('dashboard')) if request.method == 'GET': date_fmt = '%B %d, %Y' today = datetime.now(tz).date() return render_template('users/sign.html', user=current_user, date=today.strftime(date_fmt)) else: signed_info = extract_waiver_info(current_user) if 'error' in signed_info: flash(signed_info['error'], 'error') return redirect(request.url) waiver = Waiver(signed_info) DB.session.add(waiver) DB.session.commit() current_user.status = status.CONFIRMED DB.session.add(current_user) DB.session.commit() batch.keen_add_event(current_user.id, 'waivers_signed', waiver.time_signed) batch.send_attending_email(current_user) flash( "You've successfully confirmed your invitation to {}".format( settings.HACKATHON_NAME), 'success') return redirect(url_for('dashboard'))
def check_in_post(): email = request.form.get('email') user = User.query.filter_by(email=email).first() if user.school_id == 23: waiver = Waiver.query.filter_by(user_id=user.id).first() if not waiver.ut_eid: eid = request.form.get('eid') waiver.ut_eid = eid DB.session.add(waiver) DB.session.commit() user.checked_in = True DB.session.add(user) DB.session.commit() batch.keen_add_event(user.id, 'check_in', datetime.utcnow()) flash('Checked in {0} {1}'.format(user.fname, user.lname), 'success') return redirect(url_for('manual-check-in'))
def accept(): if current_user.status not in [ status.ACCEPTED, status.ADMIN ]: # they aren't allowed to accept their invitation message = { status.NEW: "You haven't completed your application for {0}! " "Please submit your application before visiting this page!".format( settings.HACKATHON_NAME), status.PENDING: "You haven't been accepted to {0}! " "Please wait for your invitation before visiting this page!". format(settings.HACKATHON_NAME), status.CONFIRMED: "You've already accepted your invitation to {0}! " "We look forward to seeing you here!".format( settings.HACKATHON_NAME), status.REJECTED: "You've already rejected your {0} invitation. " "Unfortunately, for space considerations " "you cannot change your response.".format(settings.HACKATHON_NAME), None: "Corporate users cannot view this page." } if current_user.status in message: flash(message[current_user.status], 'error') return redirect(url_for('dashboard')) if request.method == 'GET': return render_template('users/accept.html', user=current_user) else: if 'accept' in request.form: # User has accepted the invite current_user.status = status.SIGNING flash('You have successfully confirmed your invitation to {0}'. format(settings.HACKATHON_NAME)) else: current_user.status = status.DECLINED DB.session.add(current_user) DB.session.commit() user_decision = status.CONFIRMED if current_user.status == status.SIGNING else status.DECLINED batch.keen_add_event(current_user.id, user_decision, datetime.utcnow()) return redirect(url_for('dashboard'))