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
This commit is contained in:
Jan Dittberner 2009-01-18 22:42:51 +00:00
parent 1bbcc8e559
commit 08b4d46c84
7 changed files with 92 additions and 19 deletions

View file

@ -1,7 +1,7 @@
import logging
from pyalchemybiz.lib.base import *
from pyalchemybiz.model import customer, meta
from pyalchemybiz.model import customer, meta, person
log = logging.getLogger(__name__)
@ -19,3 +19,19 @@ class CustomerController(BaseController):
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')

View file

@ -1,15 +1,15 @@
# German translations for pyalchemybiz.
# Copyright (C) 2008 ORGANIZATION
# Copyright (C) 2008, 2009 Jan Dittberner
# This file is distributed under the same license as the pyalchemybiz
# project.
# Jan Dittberner <jan@dittberner.info>, 2008.
# Jan Dittberner <jan@dittberner.info>, 2009.
#
msgid ""
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: 2008-10-06 01:10+0200\n"
"PO-Revision-Date: 2009-01-18 23:31+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"
@ -19,6 +19,8 @@ msgstr ""
"Generated-By: Babel 0.9.1\n"
#: pyalchemybiz/controllers/index.py:11
#: pyalchemybiz/templates/customer/create.mako:3
#: pyalchemybiz/templates/customer/index.mako:3
msgid "Customer management"
msgstr "Kundenverwaltung"
@ -35,11 +37,31 @@ msgstr "Zurück zur %s."
msgid "FrontPage"
msgstr "Startseite"
#: pyalchemybiz/templates/customer/index.mako:3
msgid "Hello"
msgstr "Hallo"
#: pyalchemybiz/templates/customer/create.mako:4
msgid "Create new customer"
msgstr "Neuen Kunden anlegen"
#: pyalchemybiz/templates/customer/create.mako:8
msgid "First name:"
msgstr "Vorname:"
#: pyalchemybiz/templates/customer/create.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/index.mako:7
msgid "edit"
msgstr "bearbeiten"
msgid "edit customer"
msgstr "Kunden bearbeiten"
#: pyalchemybiz/templates/customer/index.mako:11
msgid "create new customer"
msgstr "neuen Kunden anlegen"
#~ msgid "Organization:"
#~ msgstr ""

View file

@ -1,14 +1,14 @@
# Translations template for pyalchemybiz.
# Copyright (C) 2008 ORGANIZATION
# Copyright (C) 2009 ORGANIZATION
# This file is distributed under the same license as the pyalchemybiz project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2008.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2009.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: pyalchemybiz 0.1\n"
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
"POT-Creation-Date: 2008-10-06 01:10+0200\n"
"POT-Creation-Date: 2009-01-18 23:30+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"
@ -18,6 +18,8 @@ msgstr ""
"Generated-By: Babel 0.9.1\n"
#: pyalchemybiz/controllers/index.py:11
#: pyalchemybiz/templates/customer/create.mako:3
#: pyalchemybiz/templates/customer/index.mako:3
msgid "Customer management"
msgstr ""
@ -34,11 +36,27 @@ msgstr ""
msgid "FrontPage"
msgstr ""
#: pyalchemybiz/templates/customer/index.mako:3
msgid "Hello"
#: pyalchemybiz/templates/customer/create.mako:4
msgid "Create new customer"
msgstr ""
#: pyalchemybiz/templates/customer/create.mako:8
msgid "First name:"
msgstr ""
#: pyalchemybiz/templates/customer/create.mako:10
msgid "Last name:"
msgstr ""
#: pyalchemybiz/templates/customer/create.mako:13
msgid "Add new customer"
msgstr ""
#: pyalchemybiz/templates/customer/index.mako:7
msgid "edit"
msgid "edit customer"
msgstr ""
#: pyalchemybiz/templates/customer/index.mako:11
msgid "create new customer"
msgstr ""

View file

@ -1,6 +1,6 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.1//EN"
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>${_('PyAlchemyBiz')}</title>
${h.stylesheet_link_tag('/pyalchemybiz.css')}

View file

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

View file

@ -1,9 +1,11 @@
<%inherit file="/base.mako" />
<h1>${_('Hello')}</h1>
<h1>${_('Customer management')}</h1>
<ul id="customers">
% for customer in c.customers:
<li>${customer | h} [${h.link_to(_('edit'), 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"))}]</li>
% endfor
</ul>
${h.link_to(_('create new customer'), h.url_for(action="create"))}