pyalchemybiz/pyalchemybiz/controllers/customer.py
Jan Dittberner 08b4d46c84 add code for creating new customers
* update string catalog and german translation (addresses #11)
 * create new actions for adding customers in customers controller
   (addresses #12)

git-svn-id: file:///var/www/wwwusers/usr01/svn/pyalchemybiz/trunk@10 389c73d4-bf09-4d3d-a15e-f94a37d0667a
2009-01-18 22:42:51 +00:00

38 lines
1 KiB
Python

import logging
from pyalchemybiz.lib.base import *
from pyalchemybiz.model import customer, meta, person
log = logging.getLogger(__name__)
class CustomerController(BaseController):
def index(self):
sess = meta.Session()
cust_q = sess.query(customer.Customer)
c.customers = cust_q.all()
return render('/customer/index.mako')
def edit(self, id):
sess = meta.Session()
cust_q = sess.query(customer.Customer)
c.customer = cust_q.filter(customer.Customer.id==id).one()
return render('/customer/edit.mako')
def create(self):
sess = meta.Session()
return render('/customer/create.mako')
def create_process(self):
sess = meta.Session()
cust = customer.Customer()
sess.save(cust)
cust.person = person.Person()
cust.person.firstname = request.params['firstname']
cust.person.lastname = request.params['lastname']
sess.save(cust.person)
sess.commit()
redirect_to(action='index')