handle non-existing users correctly and don't use id for the list action
addresses #21
This commit is contained in:
parent
f832a1615d
commit
787f6050d4
1 changed files with 7 additions and 3 deletions
|
@ -24,8 +24,12 @@ class CustomerController(BaseController):
|
||||||
"""
|
"""
|
||||||
Display a customer's details.
|
Display a customer's details.
|
||||||
"""
|
"""
|
||||||
|
if id is None:
|
||||||
|
abort(404)
|
||||||
cust_q = meta.Session.query(customer.Customer)
|
cust_q = meta.Session.query(customer.Customer)
|
||||||
c.customer = cust_q.get(int(id))
|
c.customer = cust_q.get(int(id))
|
||||||
|
if c.customer is None:
|
||||||
|
abort(404)
|
||||||
return render('/derived/customer/view.mako')
|
return render('/derived/customer/view.mako')
|
||||||
|
|
||||||
def new(self):
|
def new(self):
|
||||||
|
@ -52,7 +56,7 @@ class CustomerController(BaseController):
|
||||||
meta.Session.delete(cust)
|
meta.Session.delete(cust)
|
||||||
meta.Session.commit()
|
meta.Session.commit()
|
||||||
|
|
||||||
redirect_to(action='list')
|
redirect_to(action='list', id=None)
|
||||||
|
|
||||||
def create(self):
|
def create(self):
|
||||||
"""
|
"""
|
||||||
|
@ -67,7 +71,7 @@ class CustomerController(BaseController):
|
||||||
meta.Session.add(cust.person)
|
meta.Session.add(cust.person)
|
||||||
meta.Session.commit()
|
meta.Session.commit()
|
||||||
|
|
||||||
redirect_to(action='list')
|
redirect_to(action='list', id=None)
|
||||||
|
|
||||||
def save(self, id):
|
def save(self, id):
|
||||||
"""
|
"""
|
||||||
|
@ -81,4 +85,4 @@ class CustomerController(BaseController):
|
||||||
meta.Session.add(cust.person)
|
meta.Session.add(cust.person)
|
||||||
meta.Session.commit()
|
meta.Session.commit()
|
||||||
|
|
||||||
redirect_to(action='list')
|
redirect_to(action='list', id=None)
|
||||||
|
|
Loading…
Reference in a new issue