示例#1
0
 def make_order(self):
     username = session['user']
     user = Session.query(User).filter(User.name==username).first()
     
     dish_id = request.params['dish_id']
     
     o = Session.query(Order).filter(Order.date==datetime.date.today()).first()
     
     if o == None:
         o = Order()
         o.date = datetime.date.today()
         Session.add(o)
         Session.commit()
     
     od = OrderDetail()
     od.order_id = o.id
     od.user_id = user.id
     od.dish_id = dish_id
     od.quantity = request.params['quantity']
     od.notes = request.params['notes']
     od.date = datetime.date.today()
     
     Session.add(od)
     Session.commit()
     
     redirect(url.current(action='get_today_order'))
示例#2
0
    def get_today_order(self):
        o = Session.query(Order).filter(Order.date==datetime.date.today()).first()

        if o != None:
            c.details = Session.query(OrderDetail).filter(OrderDetail.order_id==o.id)
        else:
            c.details = None
        
        return render("/today_order.mako")
示例#3
0
 def cancel_order(self):
     detail_id = request.params['detail_id']
     
     detail = Session.query(OrderDetail).get(detail_id)
     
     Session.delete(detail)
     Session.commit()
     
     redirect(url.current(action='get_today_order'))
示例#4
0
    def create(self):
        """POST /banners: Create a new item"""
        u = User()
        u.name = request.params['name']
        u.password = request.params['password']
        
        Session.add(u)
        Session.commit()

        return redirect(url.current(action='index'))
示例#5
0
    def register_user(self):
        u = User()
        u.name = request.params['name']
        u.password = request.params['password']
        u.email = request.params['email']
        u.enabled = True
        
        Session.add(u)
        Session.commit()

        redirect(url.current(action='index'))
示例#6
0
    def update(self):
        id = request.params['user_id']
        u = Session.query(User).filter(User.id==id).first()
        u.name = request.params['name']
        u.password = request.params['password']
        u.email = request.params['email']
        
        Session.add(u)
        Session.commit()

        return redirect(url.current(action='index'))
示例#7
0
 def create(self):
     """POST /banners: Create a new item"""
     # url('banners')
     u = User()
     u.name = request.params['name']
     u.password = request.params['password']
     u.email = request.params['email']
     
     Session.add(u)
     Session.commit()
             
     return 'User: %s added correctly' % request.params['name']
示例#8
0
    def authenticate(self):
        form_username = str(request.params.get('username'))
        form_password = str(request.params.get('password'))


        # Get user data from database
        user = Session.query(User).filter(User.name==form_username).first()

        if user is None: # User does not exist
            return render('/login.mako')

        # Wrong password? (MD5 hashes used here)
        
        #if user.password != md5.md5(form_password).hexdigest():
        if user.password != form_password:
            return "Bad authentication." #render('login.mako')

        # Mark user as logged in
        session['user'] = form_username
        session.save()

        if user.name == "admin":
            return redirect(url(controller='admin/menu', action='index'))
        else:
            return redirect(url.current(action='index'))
        """    
示例#9
0
 def index(self):
     
     if 'c' in request.params:
         c.category_id = int(request.params['c'])
     else:
         c.category_id = 1
         
     c.categories = Session.query(Category)
     c.authenticated = ('user' in session)
     
     return render("/menu.mako")
示例#10
0
 def edit(self):
     id = request.params['user_id']
     c.user = Session.query(User).filter(User.id==id).first()
     return render('/admin/edit_user.mako')
示例#11
0
 def index(self):
     users = Session.query(User)
     c.users = users
     return render("/admin/users.mako")