Esempio n. 1
0
 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})
Esempio n. 2
0
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
Esempio n. 3
0
 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'))
Esempio n. 4
0
    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'))
Esempio n. 5
0
 def get_absolute_url(self):
     return url_for('order:order-pay-page')
Esempio n. 6
0
 def inaccessible_callback(self, name, **kwargs):
     return redirect(url_for('user.login'))
Esempio n. 7
0
 def get_absolute_url(self):
     return url_for('core.detail_main', name=self.name)
Esempio n. 8
0
 def inaccessible_callback(self, name, **kwargs):
     return redirect(url_for('admin.index'))
Esempio n. 9
0
 def inner(*args, **kwargs):
     if current_user.is_authenticated:
         return redirect(url_for('admin.index'))
     else:
         return view(*args, **kwargs)
Esempio n. 10
0
 def dispatch_request(self, *args, **kwargs):
     current_app.logger.info('User %s logout' % current_user.name)
     logout_user()
     return redirect(url_for('core.mainpage'))