odoo/doc/howto/howto_website/website-dependency

59 lines
1.8 KiB
Plaintext

# HG changeset patch
# Parent 5426218c6da91a13911e64eeb18a0cc2e19083c7
diff --git a/__openerp__.py b/__openerp__.py
--- a/__openerp__.py
+++ b/__openerp__.py
@@ -15,7 +15,7 @@
'version': '0.1',
# any module necessary for this one to work correctly
- 'depends': ['web'],
+ 'depends': ['website'],
'data': [
'security/ir.model.access.csv',
'views/templates.xml',
diff --git a/controllers/my_controller.py b/controllers/my_controller.py
--- a/controllers/my_controller.py
+++ b/controllers/my_controller.py
@@ -12,17 +12,12 @@ teaching_assistants = [
]
class my_controller(main.Home):
- @http.route('/', auth='none')
+ @http.route('/', auth='public')
def index(self):
- tas = [
- '<li><a href="/tas/%d/">%s</a></li>' % (i, ta['name'])
- for i, ta in enumerate(teaching_assistants)
- ]
+ return http.request.website.render('academy.index', {
+ 'tas': teaching_assistants,
+ })
- return "" % {
- 'tas': '\n'.join(tas)
- }
-
- @http.route('/tas/<int:id>/', auth='none')
+ @http.route('/tas/<int:id>/', auth='public', website=True)
def ta(self, id):
- return "" % teaching_assistants[id]
+ return http.request.website.render('academy.ta', teaching_assistants[id])
diff --git a/views/templates.xml b/views/templates.xml
--- a/views/templates.xml
+++ b/views/templates.xml
@@ -17,7 +17,11 @@
</p>
<h2>Teaching Assistants</h2>
<ul>
- <t t-raw="tas"/>
+ <li t-foreach="tas" t-as="ta">
+ <a t-att-href="url_for('/tas/%d/' % ta_index)">
+ <t t-esc="ta['name']"/>
+ </a>
+ </li>
</ul>
</body>
</html>