odoo/doc/howto/howto_website/website-dependency

62 lines
2.1 KiB
Plaintext
Raw Normal View History

2014-01-27 15:54:00 +00:00
# HG changeset patch
2014-02-07 10:22:03 +00:00
# Parent b2da66732141558bdf8fcc21000b98a8b67a1340
2014-01-27 15:54:00 +00:00
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'],
2014-01-27 15:54:00 +00:00
+ 'depends': ['website'],
'data': [
'security/ir.model.access.csv',
2014-01-27 15:54:00 +00:00
'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
2014-02-07 10:11:57 +00:00
@@ -12,20 +12,12 @@ teaching_assistants = [
2014-01-27 15:54:00 +00:00
]
class my_controller(main.Home):
2014-01-27 15:54:00 +00:00
- @http.route('/', auth='none')
+ @http.route('/', auth='public')
def index(self):
2014-02-07 10:11:57 +00:00
- cr, uid, context = http.request.cr, http.request.uid, http.request.context
2014-01-27 15:54:00 +00:00
- 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,
+ })
2014-02-07 10:11:57 +00:00
- return http.request.registry['ir.ui.view'].render(cr, uid, 'academy.index', {
2014-01-27 15:54:00 +00:00
- 'tas': '\n'.join(tas)
2014-02-07 10:11:57 +00:00
- }, context=context)
2014-01-27 15:54:00 +00:00
-
- @http.route('/tas/<int:id>/', auth='none')
+ @http.route('/tas/<int:id>/', auth='public', website=True)
def ta(self, id):
2014-02-07 10:11:57 +00:00
- cr, uid, context = http.request.cr, http.request.uid, http.request.context
- return http.request.registry['ir.ui.view'].render(
2014-02-07 10:22:03 +00:00
- cr, uid, "academy.ta", teaching_assistants[id], context=context)
2014-01-27 15:54:00 +00:00
+ 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>