odoo/doc/howto/howto_website/website-dependency

59 lines
1.7 KiB
Plaintext

# HG changeset patch
# Parent 5a5145642f3604f09c5685d37beaddc497d3c850
diff --git a/__openerp__.py b/__openerp__.py
--- a/__openerp__.py
+++ b/__openerp__.py
@@ -1,6 +1,7 @@
{
'name': "Academy",
'category': "Tools",
+ 'depends': ['website'],
'data': [
'views/templates.xml',
]
diff --git a/controllers.py b/controllers.py
--- a/controllers.py
+++ b/controllers.py
@@ -10,18 +10,12 @@ teaching_assistants = [
]
class Home(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,
+ })
- # how in fuck do I get a db here?
- 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>