def dispatch_request(self, *args, **kwargs): form = LoginForm() if form.validate_on_submit(): login_user(form.login_user_instance) current_app.logger.info('User %s logged in' % form.login_user_instance.name) return redirect(url_for('admin.index')) return self.get_template({'form': form})
def test_detail(client): r = client.post('/') assert r.status_code == 200 with client.db.init_db(): id = client.db.c.execute( 'SELECT id FROM articles DESC LIMIT 1').fetchone()[0] with client.app.test_request_context(): url = url_for('detail', id=id) r = client.get(url) assert r.status_code == 200
def post(self, *args, **kwargs): order = OrderModel.query.filter_by( id=session.pop(O_I, None)).first_or_404() customer = stripe.Customer.create(email='*****@*****.**', source=request.form['stripeToken']) charge = stripe.Charge.create(customer=customer.id, amount=order.total_price * 100, currency='usd', description='Flask Charge') order.make_sales() return redirect(url_for('payment.success-pay'))
def post(self, *args, **kwargs): form = OrderForm() if not form.validate_on_submit(): return self.get_template({'form': form}) order = OrderModel(**form.get_order_data()) order.set_items(self.cart) self.cart_dispatch('clear') if session.get(O_I): o = OrderModel.query.filter_by(id=session[O_I]).first() if o: o.delete() session[O_I] = order.id return redirect(url_for('order.order-pay'))
def get_absolute_url(self): return url_for('order:order-pay-page')
def inaccessible_callback(self, name, **kwargs): return redirect(url_for('user.login'))
def get_absolute_url(self): return url_for('core.detail_main', name=self.name)
def inaccessible_callback(self, name, **kwargs): return redirect(url_for('admin.index'))
def inner(*args, **kwargs): if current_user.is_authenticated: return redirect(url_for('admin.index')) else: return view(*args, **kwargs)
def dispatch_request(self, *args, **kwargs): current_app.logger.info('User %s logout' % current_user.name) logout_user() return redirect(url_for('core.mainpage'))