improve template structure (fixes #18)
This commit is contained in:
parent
84191f4b2c
commit
3f4d76dd99
12 changed files with 70 additions and 62 deletions
|
@ -12,17 +12,17 @@ class CustomerController(BaseController):
|
|||
sess = meta.Session()
|
||||
cust_q = sess.query(customer.Customer)
|
||||
c.customers = cust_q.all()
|
||||
return render('/customer/index.mako')
|
||||
return render('/derived/customer/index.mako')
|
||||
|
||||
def create(self):
|
||||
sess = meta.Session()
|
||||
return render('/customer/create.mako')
|
||||
return render('/derived/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')
|
||||
return render('/derived/customer/edit.mako')
|
||||
|
||||
def delete(self, id):
|
||||
sess = meta.Session()
|
||||
|
|
|
@ -9,7 +9,4 @@ class IndexController(BaseController):
|
|||
|
||||
def index(self):
|
||||
c.menuitems = [(_("Customer management"), "customer", "index")]
|
||||
# Return a rendered template
|
||||
# return render('/some/template.mako')
|
||||
# or, Return a response
|
||||
return render('/index.mako')
|
||||
return render('/derived/index/index.mako')
|
||||
|
|
|
@ -3,5 +3,5 @@
|
|||
Consists of functions to typically be used within templates, but also
|
||||
available to Controllers. This module is available to both as 'h'.
|
||||
"""
|
||||
from webhelpers.rails.wrapped import *
|
||||
from webhelpers.html.tags import *
|
||||
from routes import url_for, redirect_to
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>${_('PyAlchemyBiz')}</title>
|
||||
${h.stylesheet_link_tag('/pyalchemybiz.css')}
|
||||
${h.javascript_include_tag(
|
||||
'/javascripts/pyalchemybiz.js', builtins=True)}
|
||||
</head>
|
||||
<body>
|
||||
<div class="content">
|
||||
${next.body()}\
|
||||
<p class="footer">
|
||||
${_("Return to the %s.") % \
|
||||
h.link_to(_('FrontPage'),
|
||||
h.url_for(controller="index", action="index"))}
|
||||
</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
30
pyalchemybiz/templates/base/base.mako
Normal file
30
pyalchemybiz/templates/base/base.mako
Normal file
|
@ -0,0 +1,30 @@
|
|||
## -*- coding: utf-8 -*-
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
|
||||
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>${self.title()}</title>
|
||||
${h.stylesheet_link('/pyalchemybiz.css')}
|
||||
${h.javascript_link('/javascripts/jquery.js', '/javascripts/pyalchemybiz.js')}
|
||||
${self.head()}
|
||||
</head>
|
||||
<body>
|
||||
${self.header()}
|
||||
${self.tabs()}
|
||||
${self.menu()}
|
||||
${self.heading()}
|
||||
${self.breadcrumbs()}
|
||||
${next.body()}
|
||||
${self.footer()}
|
||||
</body>
|
||||
</html>
|
||||
|
||||
<%def name="title()">${_('PyAlchemyBiz')}</%def>
|
||||
<%def name="head()"></%def>
|
||||
<%def name="header()"><a name="top"></a></%def>
|
||||
<%def name="tabs()"></%def>
|
||||
<%def name="menu()"></%def>
|
||||
<%def name="heading()"><h1>${c.heading or _('PyAlchemyBiz')}</h1></%def>
|
||||
<%def name="breadcrumbs()"></%def>
|
||||
<%def name="footer()"><p><a href="#top">Top ^</a></p></%def>
|
5
pyalchemybiz/templates/base/customer.mako
Normal file
5
pyalchemybiz/templates/base/customer.mako
Normal file
|
@ -0,0 +1,5 @@
|
|||
<%inherit file="/base/base.mako" />
|
||||
|
||||
${next.body()}
|
||||
<%def name="title()">${parent.title()} - ${_('Customer management')}</%def>
|
||||
<%def name="heading()"><h1>${_('Customer management')}</h1></%def>
|
|
@ -1,15 +0,0 @@
|
|||
<%inherit file="/base.mako" />
|
||||
|
||||
<h1>${_('Customer management')}</h1>
|
||||
<h2>${_('Create new customer')}</h2>
|
||||
|
||||
${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 />
|
||||
<label for="lastname">${_('Last name:')}</label><br />
|
||||
${h.text_field('lastname')}<br />
|
||||
|
||||
${h.submit(_('Add new customer'))}
|
||||
</div>
|
||||
${h.end_form()}
|
|
@ -1,15 +0,0 @@
|
|||
<%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()}
|
14
pyalchemybiz/templates/derived/customer/create.mako
Normal file
14
pyalchemybiz/templates/derived/customer/create.mako
Normal file
|
@ -0,0 +1,14 @@
|
|||
<%inherit file="/base/customer.mako" />
|
||||
|
||||
${h.form(h.url_for(action='process_create'))}
|
||||
<fieldset id="createcustomerform">
|
||||
<label for="firstname">${_('First name:')}</label><br />
|
||||
${h.text('firstname')}<br />
|
||||
<label for="lastname">${_('Last name:')}</label><br />
|
||||
${h.text('lastname')}<br />
|
||||
|
||||
${h.submit('submit', _('Add new customer'))}
|
||||
</fieldset>
|
||||
${h.end_form()}
|
||||
|
||||
<%def name="heading()"><h1>${_('Create new customer')}</h1></%def>
|
14
pyalchemybiz/templates/derived/customer/edit.mako
Normal file
14
pyalchemybiz/templates/derived/customer/edit.mako
Normal file
|
@ -0,0 +1,14 @@
|
|||
<%inherit file="/base/customer.mako" />
|
||||
|
||||
${h.form(h.url_for(action='process_edit'))}
|
||||
<fieldset id="editcustomerform">
|
||||
<label for="firstname">${_('First name:')}</label><br />
|
||||
${h.text('firstname', c.customer.person.firstname)}<br />
|
||||
<label for="lastname">${_('Last name:')}</label><br />
|
||||
${h.text('lastname', c.customer.person.lastname)}<br />
|
||||
|
||||
${h.submit('save', _('Save changes'))}
|
||||
</fieldset>
|
||||
${h.end_form()}
|
||||
|
||||
<%def name="heading()"><h1>${_('Edit customer')}</h1></%def>
|
|
@ -1,6 +1,4 @@
|
|||
<%inherit file="/base.mako" />
|
||||
|
||||
<h1>${_('Customer management')}</h1>
|
||||
<%inherit file="/base/customer.mako" />
|
||||
|
||||
<ul id="customers">
|
||||
% for customer in c.customers:
|
|
@ -1,4 +1,4 @@
|
|||
<%inherit file="base.mako" />
|
||||
<%inherit file="/base/base.mako" />
|
||||
|
||||
<ul id="menu">
|
||||
% for item in c.menuitems:
|
Loading…
Reference in a new issue