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:
parent
08b4d46c84
commit
84191f4b2c
7 changed files with 74 additions and 12 deletions
|
@ -14,17 +14,27 @@ class CustomerController(BaseController):
|
||||||
c.customers = cust_q.all()
|
c.customers = cust_q.all()
|
||||||
return render('/customer/index.mako')
|
return render('/customer/index.mako')
|
||||||
|
|
||||||
|
def create(self):
|
||||||
|
sess = meta.Session()
|
||||||
|
return render('/customer/create.mako')
|
||||||
|
|
||||||
def edit(self, id):
|
def edit(self, id):
|
||||||
sess = meta.Session()
|
sess = meta.Session()
|
||||||
cust_q = sess.query(customer.Customer)
|
cust_q = sess.query(customer.Customer)
|
||||||
c.customer = cust_q.filter(customer.Customer.id==id).one()
|
c.customer = cust_q.filter(customer.Customer.id==id).one()
|
||||||
return render('/customer/edit.mako')
|
return render('/customer/edit.mako')
|
||||||
|
|
||||||
def create(self):
|
def delete(self, id):
|
||||||
sess = meta.Session()
|
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()
|
sess = meta.Session()
|
||||||
cust = customer.Customer()
|
cust = customer.Customer()
|
||||||
sess.save(cust)
|
sess.save(cust)
|
||||||
|
@ -35,3 +45,14 @@ class CustomerController(BaseController):
|
||||||
sess.commit()
|
sess.commit()
|
||||||
|
|
||||||
redirect_to(action='index')
|
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')
|
||||||
|
|
Binary file not shown.
|
@ -9,7 +9,7 @@ msgstr ""
|
||||||
"Project-Id-Version: pyalchemybiz 0.1\n"
|
"Project-Id-Version: pyalchemybiz 0.1\n"
|
||||||
"Report-Msgid-Bugs-To: jan@dittberner.info\n"
|
"Report-Msgid-Bugs-To: jan@dittberner.info\n"
|
||||||
"POT-Creation-Date: 2008-10-06 00:50+0200\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"
|
"Last-Translator: Jan Dittberner <jan@dittberner.info>\n"
|
||||||
"Language-Team: de <de@li.org>\n"
|
"Language-Team: de <de@li.org>\n"
|
||||||
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
|
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
|
||||||
|
@ -20,6 +20,7 @@ msgstr ""
|
||||||
|
|
||||||
#: pyalchemybiz/controllers/index.py:11
|
#: pyalchemybiz/controllers/index.py:11
|
||||||
#: pyalchemybiz/templates/customer/create.mako:3
|
#: pyalchemybiz/templates/customer/create.mako:3
|
||||||
|
#: pyalchemybiz/templates/customer/edit.mako:3
|
||||||
#: pyalchemybiz/templates/customer/index.mako:3
|
#: pyalchemybiz/templates/customer/index.mako:3
|
||||||
msgid "Customer management"
|
msgid "Customer management"
|
||||||
msgstr "Kundenverwaltung"
|
msgstr "Kundenverwaltung"
|
||||||
|
@ -42,26 +43,36 @@ msgid "Create new customer"
|
||||||
msgstr "Neuen Kunden anlegen"
|
msgstr "Neuen Kunden anlegen"
|
||||||
|
|
||||||
#: pyalchemybiz/templates/customer/create.mako:8
|
#: pyalchemybiz/templates/customer/create.mako:8
|
||||||
|
#: pyalchemybiz/templates/customer/edit.mako:8
|
||||||
msgid "First name:"
|
msgid "First name:"
|
||||||
msgstr "Vorname:"
|
msgstr "Vorname:"
|
||||||
|
|
||||||
#: pyalchemybiz/templates/customer/create.mako:10
|
#: pyalchemybiz/templates/customer/create.mako:10
|
||||||
|
#: pyalchemybiz/templates/customer/edit.mako:10
|
||||||
msgid "Last name:"
|
msgid "Last name:"
|
||||||
msgstr "Nachname:"
|
msgstr "Nachname:"
|
||||||
|
|
||||||
#: pyalchemybiz/templates/customer/create.mako:13
|
#: pyalchemybiz/templates/customer/create.mako:13
|
||||||
#, fuzzy
|
|
||||||
msgid "Add new customer"
|
msgid "Add new customer"
|
||||||
msgstr "Neuen Kunden hinzufügen"
|
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
|
#: pyalchemybiz/templates/customer/index.mako:7
|
||||||
msgid "edit customer"
|
msgid "edit customer"
|
||||||
msgstr "Kunden bearbeiten"
|
msgstr "Kunden bearbeiten"
|
||||||
|
|
||||||
|
#: pyalchemybiz/templates/customer/index.mako:7
|
||||||
|
msgid "delete customer"
|
||||||
|
msgstr "Kunden löschen"
|
||||||
|
|
||||||
#: pyalchemybiz/templates/customer/index.mako:11
|
#: pyalchemybiz/templates/customer/index.mako:11
|
||||||
msgid "create new customer"
|
msgid "create new customer"
|
||||||
msgstr "neuen Kunden anlegen"
|
msgstr "Neuen Kunden anlegen"
|
||||||
|
|
||||||
#~ msgid "Organization:"
|
|
||||||
#~ msgstr ""
|
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: pyalchemybiz 0.1\n"
|
"Project-Id-Version: pyalchemybiz 0.1\n"
|
||||||
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\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"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -19,6 +19,7 @@ msgstr ""
|
||||||
|
|
||||||
#: pyalchemybiz/controllers/index.py:11
|
#: pyalchemybiz/controllers/index.py:11
|
||||||
#: pyalchemybiz/templates/customer/create.mako:3
|
#: pyalchemybiz/templates/customer/create.mako:3
|
||||||
|
#: pyalchemybiz/templates/customer/edit.mako:3
|
||||||
#: pyalchemybiz/templates/customer/index.mako:3
|
#: pyalchemybiz/templates/customer/index.mako:3
|
||||||
msgid "Customer management"
|
msgid "Customer management"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
@ -41,10 +42,12 @@ msgid "Create new customer"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: pyalchemybiz/templates/customer/create.mako:8
|
#: pyalchemybiz/templates/customer/create.mako:8
|
||||||
|
#: pyalchemybiz/templates/customer/edit.mako:8
|
||||||
msgid "First name:"
|
msgid "First name:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: pyalchemybiz/templates/customer/create.mako:10
|
#: pyalchemybiz/templates/customer/create.mako:10
|
||||||
|
#: pyalchemybiz/templates/customer/edit.mako:10
|
||||||
msgid "Last name:"
|
msgid "Last name:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
@ -52,10 +55,22 @@ msgstr ""
|
||||||
msgid "Add new customer"
|
msgid "Add new customer"
|
||||||
msgstr ""
|
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
|
#: pyalchemybiz/templates/customer/index.mako:7
|
||||||
msgid "edit customer"
|
msgid "edit customer"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
#: pyalchemybiz/templates/customer/index.mako:7
|
||||||
|
msgid "delete customer"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
#: pyalchemybiz/templates/customer/index.mako:11
|
#: pyalchemybiz/templates/customer/index.mako:11
|
||||||
msgid "create new customer"
|
msgid "create new customer"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<h1>${_('Customer management')}</h1>
|
<h1>${_('Customer management')}</h1>
|
||||||
<h2>${_('Create new customer')}</h2>
|
<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">
|
<div id="createcustomerform">
|
||||||
<label for="firstname">${_('First name:')}</label><br />
|
<label for="firstname">${_('First name:')}</label><br />
|
||||||
${h.text_field('firstname')}<br />
|
${h.text_field('firstname')}<br />
|
||||||
|
|
15
pyalchemybiz/templates/customer/edit.mako
Normal file
15
pyalchemybiz/templates/customer/edit.mako
Normal 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()}
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
<ul id="customers">
|
<ul id="customers">
|
||||||
% for customer in c.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
|
% endfor
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue