flash('This card is already registered', 'error') else: flash('Your card was saved successfully, but it may not be immediately available', 'warning') app.logger.exception('Something has gone terribly wrong when creating a card') return redirect(url_for('user.cards')) context = { 'title': 'Add New Breeze Card', 'description': 'Add a new MARTA Breeze Card to your BreezeMinder.com account', 'form': form } return render_template('user/cards/add.html', **context) @fresh_login_required @nocache def delete_card(pk_hash): card = BreezeCard.objects.get_or_404(pk_hash=pk_hash, owner=current_user._get_current_object()) card.delete() flash('Card removed successfully', 'success') return redirect(url_for('user.cards')) app.add_url_rule('/cards/', 'user.cards', cards) app.add_url_rule('/cards/view/<pk_hash>', 'user.cards.view', view_card) app.add_url_rule('/cards/ical/<pk_hash>', 'user.cards.ical', card_ical) app.add_url_rule('/cards/reload/<pk_hash>', 'user.cards.reload', reload_card, methods=['GET', 'POST']) app.add_url_rule('/cards/add/', 'user.cards.add', add_card, methods=['GET', 'POST']) app.add_url_rule('/cards/delete/<pk_hash>', 'user.cards.delete', delete_card)
if error: # There is actually an error app.logger.error('Caught 404 accessing page: %s' % request.path) context = { 'title': 'Page Not Found', 'description': 'The page you are accessing cannot be found', 'show_footer_ad': True } return render_template('errors/404.html', **context), 404 @app.errorhandler(500) @nocache def handle_500(error=None): if error: # There is actually an error app.logger.critical('Caught 500 accessing page: %s. Message: %s' % (request.path, error.message)) app.logger.critical(traceback.format_exc(error)) context = { 'title': 'Internal Server Error', 'description': 'The server is experiencing issues at the moment', 'show_footer_ad': True } return render_template('errors/500.html', **context), 500 app.add_url_rule('/404.html', 'error.404', handle_404) app.add_url_rule('/500.html', 'error.500', handle_500)
def contact(): form = ContactForm(request.form) if request.method == 'POST' and form.validate(): try: Messaging.objects.create(recipients=['*****@*****.**'], sender=form.email.data, subject='[BM Feedback] %s' % form.subject.data, message=form.message.data) flash('Message sent successfully', 'success') except: flash('Your message could not be sent at this time', 'error') return redirect(url_for('contact')) context = { 'form': form, 'title': 'Contact Us', 'description': 'A contact form to send feedback or concerns to BreezeMinder.com' } return render_template('pages/contact.html', **context) app.add_url_rule('/favicon.ico', 'favicon', favicon) app.add_url_rule('/', 'index', index) app.add_url_rule('/privacy/', 'privacy', privacy) app.add_url_rule('/terms/', 'terms', terms) app.add_url_rule('/contact/', 'contact', contact, methods=['GET', 'POST'])
flash('You have successfully cancelled verifying your mobile number', 'success') return redirect(url_for('user.profile')) @fresh_login_required def change_password(): form = PasswordChangeForm(request.form) if request.method == 'POST' and form.validate(): # Check current pasword if current_user.hash_password(form.current_password.data) != current_user.password: flash('Your current password is incorrect', 'error') else: current_user.set_password(form.password.data) current_user.save() flash('Password changed successfully', 'success') return redirect(url_for('user.password')) context = { 'title': 'Change Password', 'description': 'Change your BreezeMinder.com account password', 'form': form } return render_template('user/password.html', **context) app.add_url_rule('/me/', 'user.profile', profile, methods=['GET', 'POST']) app.add_url_rule('/me/mobile/resend', 'user.mobile.resend', resend_cell_code) app.add_url_rule('/me/mobile/cancel', 'user.mobile.cancel', cancel_cell_verify) app.add_url_rule('/me/password/', 'user.password', change_password, methods=['GET', 'POST'])
session.update() if request.args.get('next'): return redirect_next() else: return redirect(url_for('user.profile')) except: app.logger.info('Invalid login attempt for username %s' % form.email.data) flash('Invalid username/password', 'error') return redirect(url_for('auth.login', next=request.args.get('next', '/'))) context = { 'title': 'Login', 'description': 'Login form for BreezeMinder.com to access Breeze cards and MARTA reminders', 'form': form } return render_template('auth/login.html', **context) def logout(): logout_user() return redirect_next() app.add_url_rule('/register/', 'auth.register', register, methods=['GET', 'POST']) app.add_url_rule('/reset-password/', 'auth.reset_password', reset_password, methods=['GET', 'POST']) app.add_url_rule('/reset-password/<auth_code>', 'auth.new_password', new_password, methods=['GET', 'POST']) app.add_url_rule('/verify/<pk_hash>', 'auth.verify', verify) app.add_url_rule('/login/', 'auth.login', login, methods=['GET', 'POST']) app.add_url_rule('/logout/', 'auth.logout', logout)
pass else: qs = qs.filter(stop_id=stop.id) # Process ordered by arrival - grouped by stop for stop in qs.only('stop_id', 'arrival').order_by('arrival'): if stop.stop_id not in data: data[stop.stop_id] = { 'refresh': stop.arrival - start, 'times': [] } if len(data[stop.stop_id]['times']) >= 3: continue data[stop.stop_id]['times'].append( ScheduledStop.seconds_to_timestring(stop.arrival) ) resp = make_response(json.dumps(data)) resp.cache_control.no_cache = True resp.headers['Content-Type'] = 'application/json' return resp app.add_url_rule('/marta/', 'marta.status', status, methods=['GET', 'POST']) app.add_url_rule('/marta/route/<route_id>.json', 'marta.route.details', route_details) app.add_url_rule('/marta/realtime/<route_id>.json', 'marta.route.realtime', route_realtime) app.add_url_rule('/marta/upcoming/<route_id>.json', 'marta.route.upcoming', route_upcoming)