def calc_sales_state(date): if TicketType.get_tickets_remaining() < 1: # We've hit capacity - no more tickets will be sold return "sold-out" elif date > datetime(2016, 8, 7): return "sales-ended" elif TicketType.get_price_cheapest_full() is None: # Tickets not currently available, probably just for this round, but we haven't hit site capacity return "unavailable" else: return "available"
def main(): full_price = TicketType.get_price_cheapest_full() if not (feature_enabled('BANK_TRANSFER') or feature_enabled('GOCARDLESS')) and full_price is not None: # Only card payment left full_price += StripePayment.premium('GBP', full_price) state = get_site_state() if app.config.get('DEBUG'): state = request.args.get("site_state", state) return render_template('home/%s.html' % state, full_price=full_price)
def main(cfp_type="talk"): if cfp_type not in ["talk", "workshop", "installation"]: abort(404) ignore_closed = "closed" in request.args if app.config.get("CFP_CLOSED") and not ignore_closed: return render_template("cfp/closed.html") forms = [ TalkProposalForm(prefix="talk"), WorkshopProposalForm(prefix="workshop"), InstallationProposalForm(prefix="installation"), ] (form,) = [f for f in forms if f.type == cfp_type] form.active_cfp_type = cfp_type # If the user is already logged in set their name & email for the form if current_user.is_authenticated(): form.name.data = current_user.name form.email.data = current_user.email if request.method == "POST": app.logger.info("Checking %s proposal for %s (%s)", cfp_type, form.name.data, form.email.data) if form.validate_on_submit(): new_user = False if current_user.is_anonymous(): try: create_current_user(form.email.data, form.name.data) new_user = True except IntegrityError as e: app.logger.warn("Adding user raised %r, possible double-click", e) flash("An error occurred while creating an account for you. Please try again.") return redirect(url_for(".main")) if cfp_type == "talk": cfp = TalkProposal() cfp.length = form.length.data elif cfp_type == "workshop": cfp = WorkshopProposal() cfp.length = form.length.data cfp.attendees = form.attendees.data cfp.cost = form.cost.data elif cfp_type == "installation": cfp = InstallationProposal() cfp.size = form.size.data cfp.funds = form.funds.data cfp.user_id = current_user.id cfp.title = form.title.data cfp.requirements = form.requirements.data cfp.description = form.description.data cfp.notice_required = form.notice_required.data cfp.needs_help = form.needs_help.data db.session.add(cfp) db.session.commit() # Send confirmation message msg = Message( "Electromagnetic Field CFP Submission", sender=app.config["CONTENT_EMAIL"], recipients=[current_user.email] ) msg.body = render_template("emails/cfp-submission.txt", cfp=cfp, type=cfp_type, new_user=new_user) mail.send(msg) return redirect(url_for(".complete")) full_price = TicketType.get_price_cheapest_full() return render_template( "cfp/main.html", full_price=full_price, forms=forms, active_cfp_type=cfp_type, has_errors=bool(form.errors), ignore_closed=ignore_closed, )
def main(cfp_type='talk'): if cfp_type not in ['talk', 'workshop', 'installation']: abort(404) ignore_closed = 'closed' in request.args if app.config.get('CFP_CLOSED') and not ignore_closed: return render_template('cfp/closed.html') forms = [ TalkProposalForm(prefix="talk"), WorkshopProposalForm(prefix="workshop"), InstallationProposalForm(prefix="installation") ] (form, ) = [f for f in forms if f.type == cfp_type] form.active_cfp_type = cfp_type # If the user is already logged in set their name & email for the form if current_user.is_authenticated(): form.name.data = current_user.name form.email.data = current_user.email if request.method == 'POST': app.logger.info('Checking %s proposal for %s (%s)', cfp_type, form.name.data, form.email.data) if form.validate_on_submit(): new_user = False if current_user.is_anonymous(): try: create_current_user(form.email.data, form.name.data) new_user = True except IntegrityError as e: app.logger.warn('Adding user raised %r, possible double-click', e) flash( 'An error occurred while creating an account for you. Please try again.' ) return redirect(url_for('.main')) if cfp_type == 'talk': cfp = TalkProposal() cfp.length = form.length.data elif cfp_type == 'workshop': cfp = WorkshopProposal() cfp.length = form.length.data cfp.attendees = form.attendees.data cfp.cost = form.cost.data elif cfp_type == 'installation': cfp = InstallationProposal() cfp.size = form.size.data cfp.funds = form.funds.data cfp.user_id = current_user.id cfp.title = form.title.data cfp.requirements = form.requirements.data cfp.description = form.description.data cfp.notice_required = form.notice_required.data cfp.needs_help = form.needs_help.data db.session.add(cfp) db.session.commit() # Send confirmation message msg = Message('Electromagnetic Field CFP Submission', sender=app.config['CONTENT_EMAIL'], recipients=[current_user.email]) msg.body = render_template('emails/cfp-submission.txt', cfp=cfp, type=cfp_type, new_user=new_user) mail.send(msg) return redirect(url_for('.complete')) full_price = TicketType.get_price_cheapest_full() return render_template('cfp/main.html', full_price=full_price, forms=forms, active_cfp_type=cfp_type, has_errors=bool(form.errors), ignore_closed=ignore_closed)