add customer edit and customer delete function

- minimal edit customer implemented (fixes #14)
 - change create customer (fixes #12)
 - minimal delete customer implemented (fixes #15)
 - update translations (addresses #16)

git-svn-id: file:///var/www/wwwusers/usr01/svn/pyalchemybiz/trunk@11 389c73d4-bf09-4d3d-a15e-f94a37d0667a
This commit is contained in:
Jan Dittberner 2009-02-08 21:07:22 +00:00
parent 08b4d46c84
commit 84191f4b2c
7 changed files with 74 additions and 12 deletions

View file

@ -14,17 +14,27 @@ class CustomerController(BaseController):
c.customers = cust_q.all()
return render('/customer/index.mako')
def create(self):
sess = meta.Session()
return render('/customer/create.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):
def delete(self, id):
sess = meta.Session()
return render('/customer/create.mako')
cust_q = sess.query(customer.Customer)
cust = cust_q.filter(customer.Customer.id==id).one()
sess.delete(cust.person)
sess.delete(cust)
sess.commit()
def create_process(self):
redirect_to(action='index')
def process_create(self):
sess = meta.Session()
cust = customer.Customer()
sess.save(cust)
@ -35,3 +45,14 @@ class CustomerController(BaseController):
sess.commit()
redirect_to(action='index')
def process_edit(self, id):
sess = meta.Session()
cust_q = sess.query(customer.Customer)
cust = cust_q.filter(customer.Customer.id==id).one()
cust.person.firstname = request.params['firstname']
cust.person.lastname = request.params['lastname']
sess.add(cust.person)
sess.commit()
redirect_to(action='index')

View file

@ -9,7 +9,7 @@ msgstr ""
"Project-Id-Version: pyalchemybiz 0.1\n"
"Report-Msgid-Bugs-To: jan@dittberner.info\n"
"POT-Creation-Date: 2008-10-06 00:50+0200\n"
"PO-Revision-Date: 2009-01-18 23:31+0100\n"
"PO-Revision-Date: 2009-02-08 21:39+0100\n"
"Last-Translator: Jan Dittberner <jan@dittberner.info>\n"
"Language-Team: de <de@li.org>\n"
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
@ -20,6 +20,7 @@ msgstr ""
#: pyalchemybiz/controllers/index.py:11
#: pyalchemybiz/templates/customer/create.mako:3
#: pyalchemybiz/templates/customer/edit.mako:3
#: pyalchemybiz/templates/customer/index.mako:3
msgid "Customer management"
msgstr "Kundenverwaltung"
@ -42,26 +43,36 @@ msgid "Create new customer"
msgstr "Neuen Kunden anlegen"
#: pyalchemybiz/templates/customer/create.mako:8
#: pyalchemybiz/templates/customer/edit.mako:8
msgid "First name:"
msgstr "Vorname:"
#: pyalchemybiz/templates/customer/create.mako:10
#: pyalchemybiz/templates/customer/edit.mako:10
msgid "Last name:"
msgstr "Nachname:"
#: pyalchemybiz/templates/customer/create.mako:13
#, fuzzy
msgid "Add new customer"
msgstr "Neuen Kunden hinzufügen"
#: pyalchemybiz/templates/customer/edit.mako:4
msgid "Edit customer"
msgstr "Kunden bearbeiten"
#: pyalchemybiz/templates/customer/edit.mako:13
msgid "Save changes"
msgstr "Änderungen speichern"
#: pyalchemybiz/templates/customer/index.mako:7
msgid "edit customer"
msgstr "Kunden bearbeiten"
#: pyalchemybiz/templates/customer/index.mako:7
msgid "delete customer"
msgstr "Kunden löschen"
#: pyalchemybiz/templates/customer/index.mako:11
msgid "create new customer"
msgstr "neuen Kunden anlegen"
#~ msgid "Organization:"
#~ msgstr ""
msgstr "Neuen Kunden anlegen"

View file

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: pyalchemybiz 0.1\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2009-01-18 23:30+0100\n"
"POT-Creation-Date: 2009-02-08 21:39+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -19,6 +19,7 @@ msgstr ""
#: pyalchemybiz/controllers/index.py:11
#: pyalchemybiz/templates/customer/create.mako:3
#: pyalchemybiz/templates/customer/edit.mako:3
#: pyalchemybiz/templates/customer/index.mako:3
msgid "Customer management"
msgstr ""
@ -41,10 +42,12 @@ msgid "Create new customer"
msgstr ""
#: pyalchemybiz/templates/customer/create.mako:8
#: pyalchemybiz/templates/customer/edit.mako:8
msgid "First name:"
msgstr ""
#: pyalchemybiz/templates/customer/create.mako:10
#: pyalchemybiz/templates/customer/edit.mako:10
msgid "Last name:"
msgstr ""
@ -52,10 +55,22 @@ msgstr ""
msgid "Add new customer"
msgstr ""
#: pyalchemybiz/templates/customer/edit.mako:4
msgid "Edit customer"
msgstr ""
#: pyalchemybiz/templates/customer/edit.mako:13
msgid "Save changes"
msgstr ""
#: pyalchemybiz/templates/customer/index.mako:7
msgid "edit customer"
msgstr ""
#: pyalchemybiz/templates/customer/index.mako:7
msgid "delete customer"
msgstr ""
#: pyalchemybiz/templates/customer/index.mako:11
msgid "create new customer"
msgstr ""

View file

@ -3,7 +3,7 @@
<h1>${_('Customer management')}</h1>
<h2>${_('Create new customer')}</h2>
${h.start_form(h.url_for(action='create_process'), method='post')}
${h.start_form(h.url_for(action='process_create'), method='post')}
<div id="createcustomerform">
<label for="firstname">${_('First name:')}</label><br />
${h.text_field('firstname')}<br />

View file

@ -0,0 +1,15 @@
<%inherit file="/base.mako" />
<h1>${_('Customer management')}</h1>
<h2>${_('Edit customer')}</h2>
${h.start_form(h.url_for(action='process_edit'), method='post')}
<div id="editcustomerform">
<label for="firstname">${_('First name:')}</label><br />
${h.text_field('firstname', c.customer.person.firstname)}<br />
<label for="lastname">${_('Last name:')}</label><br />
${h.text_field('lastname', c.customer.person.lastname)}<br />
${h.submit(_('Save changes'))}
</div>
${h.end_form()}

View file

@ -4,7 +4,7 @@
<ul id="customers">
% for customer in c.customers:
<li>${customer | h} [${h.link_to(_('edit customer'), h.url_for(id=customer.id, action="edit"))}]</li>
<li>${customer | h} [${h.link_to(_('edit customer'), h.url_for(id=customer.id, action="edit"))}] [${h.link_to(_('delete customer'), h.url_for(id=customer.id, action="delete"))}]</li>
% endfor
</ul>