diff --git a/doc/howto/howto_website.rst b/doc/howto/howto_website.rst index 67b13482583..f94c9a93c65 100644 --- a/doc/howto/howto_website.rst +++ b/doc/howto/howto_website.rst @@ -553,6 +553,30 @@ keep only the datetime and location: .. patch:: +Moving lectures and TAs +~~~~~~~~~~~~~~~~~~~~~~~ + +There are already demonstration data in events and event types, so we'll want +to delete them before inserting our own. The gist of the operation is fairly +simple, but there are lots of changes: + +* The custom models can be removed as we'll be using standard objects +* The controller has to be altered to fetch from standard objects + (``event.event`` and ``res.users``), we'll use groups to discriminate + between our academy objects and other demo objects, so that has to be used + as well +* HTML templates have to be slightly edited to match the new objects + (our lecture's ``date`` field is replaced by ``event.event``'s + ``date_begin``) +* Missing parts of the standard events have to be added (``res.partner``, + which is where "personal" informations are stored for ``res.users``, does + not have a biographical field. We have to add it) +* Finally demo files must be converted, and existing demo data should be + purged if we do not need it (e.g. existing non-lectures events and event + types can be removed before adding our own) + +.. patch:: + .. [#taprofile] the teaching assistants profile view ends up broken for now, but don't worry we'll get around to it diff --git a/doc/howto/howto_website/move-to-openerp-objects b/doc/howto/howto_website/move-to-openerp-objects new file mode 100644 index 00000000000..8623d8a90e5 --- /dev/null +++ b/doc/howto/howto_website/move-to-openerp-objects @@ -0,0 +1,300 @@ +# HG changeset patch +# Parent ade038cd6dfd855f1d423cffb3d4e242404c28f0 + +diff --git a/__init__.py b/__init__.py +--- a/__init__.py ++++ b/__init__.py +@@ -1,4 +1,3 @@ + # -*- coding: utf-8 -*- + import controllers + import models +- +diff --git a/__openerp__.py b/__openerp__.py +--- a/__openerp__.py ++++ b/__openerp__.py +@@ -17,10 +17,8 @@ + # any module necessary for this one to work correctly + 'depends': ['website', 'website_event'], + 'data': [ +- 'security/ir.model.access.csv', + 'views/templates.xml', + 'data/records.xml', +- 'data/views.xml', + ], + 'demo': [ + 'demo/teaching_assistants.xml', +diff --git a/controllers/academy.py b/controllers/academy.py +--- a/controllers/academy.py ++++ b/controllers/academy.py +@@ -6,18 +6,29 @@ from openerp.addons.web.controllers impo + class academy(main.Home): + @http.route('/', auth='public', website=True) + def index(self): ++ registry = http.request.registry + cr, uid, context = http.request.cr, http.request.uid, http.request.context +- Lectures = http.request.registry['academy.lectures'] +- tas = http.request.registry['academy.tas'].search_read( +- http.request.cr, http.request.uid, context=http.request.context) ++ ++ Data = registry['ir.model.data'] ++ _, ta_group_id = Data.get_object_reference(cr, uid, 'academy', 'tas') ++ tas = registry['res.users'].search_read( ++ http.request.cr, http.request.uid, ++ [('groups_id', '=', [ta_group_id])], ++ context=http.request.context) ++ ++ Lectures = registry['event.event'] ++ _, lecture_type_id = Data.get_object_reference(cr, uid, 'academy', 'lecture_type') + lectures = Lectures.browse( +- cr, uid, Lectures.search(cr, uid, [], context=context), context=context) ++ cr, uid, ++ Lectures.search(cr, uid, [('type', '=', lecture_type_id),], context=context), ++ context=context) ++ + return http.request.website.render('academy.index', { + 'tas': tas, + 'lectures': lectures, + }) + +- @http.route('/tas//', auth='public', website=True) ++ @http.route('/tas//', auth='public', website=True) + def ta(self, ta): + return http.request.website.render('academy.ta', { + 'ta': ta, +diff --git a/data/views.xml b/data/views.xml +deleted file mode 100644 +--- a/data/views.xml ++++ /dev/null +@@ -1,25 +0,0 @@ +- +- +- +- academy.lectures +- +- +- +- +- +- +- +- +- +- Academy lectures +- academy.lectures +- +- +- +- +- +- +- +diff --git a/demo/lectures.xml b/demo/lectures.xml +--- a/demo/lectures.xml ++++ b/demo/lectures.xml +@@ -1,24 +1,47 @@ + + +- ++ ++ ++ ++ ++ ++ Lecture ++ ++ ++ + Lecture 1 +- 2014-01-06 ++ 2015-01-06 10:00:00 ++ 2015-01-06 12:00:00 ++ ++ + +- ++ + Lecture 2 +- 2014-01-08 ++ 2015-01-08 10:00:00 ++ 2015-01-08 12:00:00 ++ ++ + +- ++ + Lecture 3 +- 2014-01-10 ++ 2015-01-10 10:00:00 ++ 2015-01-10 12:00:00 ++ ++ + +- ++ + Lecture 4 +- 2014-01-13 ++ 2015-01-13 10:00:00 ++ 2015-01-13 12:00:00 ++ ++ + +- ++ + Lecture 5 +- 2014-01-15 ++ 2015-01-15 10:00:00 ++ 2015-01-15 12:00:00 ++ ++ + + + +diff --git a/demo/teaching_assistants.xml b/demo/teaching_assistants.xml +--- a/demo/teaching_assistants.xml ++++ b/demo/teaching_assistants.xml +@@ -1,19 +1,54 @@ + + +- ++ + Diana Padilla + +- ++ ++ padilla ++ ++ ++ ++ + Jody Carroll + +- ++ ++ carroll ++ ++ ++ ++ + Lester Vaughn + +- ++ ++ vaughn ++ ++ ++ ++ + Paul Jimenez + +- ++ ++ jimenez ++ ++ ++ ++ + Tanya Harris + ++ ++ harris ++ ++ ++ ++ ++ Teaching Assistants ++ ++ + + +diff --git a/models/__init__.py b/models/__init__.py +--- a/models/__init__.py ++++ b/models/__init__.py +@@ -1,3 +1,3 @@ + # -*- coding: utf-8 -*- +-import academy ++import res_partner + +diff --git a/models/academy.py b/models/academy.py +deleted file mode 100644 +--- a/models/academy.py ++++ /dev/null +@@ -1,19 +0,0 @@ +-# -*- coding: utf-8 -*- +-from openerp.osv import orm, fields +- +-class TeachingAssistants(orm.Model): +- _name = "academy.tas" +- +- _columns = { +- 'name': fields.char(), +- 'biography': fields.html(), +- } +- +-class Lectures(orm.Model): +- _name = 'academy.lectures' +- _order = 'date ASC' +- +- _columns = { +- 'name': fields.char(required=True, string="Name"), +- 'date': fields.date(required=True, string="Date"), +- } +diff --git a/models/res_partner.py b/models/res_partner.py +new file mode 100644 +--- /dev/null ++++ b/models/res_partner.py +@@ -0,0 +1,8 @@ ++from openerp.osv import orm, fields ++ ++class Partner(orm.Model): ++ _inherit = 'res.partner' ++ ++ _columns = { ++ 'biography': fields.html(), ++ } +diff --git a/security/ir.model.access.csv b/security/ir.model.access.csv +deleted file mode 100644 +--- a/security/ir.model.access.csv ++++ /dev/null +@@ -1,3 +0,0 @@ +-id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink +-access_academy_tas,access_academy_tas,model_academy_tas,,1,0,0,0 +-access_academy_lectures,access_academy_lectures,model_academy_lectures,,1,0,0,0 +\ No newline at end of file +diff --git a/views/templates.xml b/views/templates.xml +--- a/views/templates.xml ++++ b/views/templates.xml +@@ -31,11 +31,11 @@ + + + +- + + +- + + +@@ -56,9 +56,9 @@ +
+
+
+-

++

+

Biography

+-
++
+
+
+
diff --git a/doc/howto/howto_website/series b/doc/howto/howto_website/series index 18f3e6aba0e..0cdae6542bf 100644 --- a/doc/howto/howto_website/series +++ b/doc/howto/howto_website/series @@ -21,3 +21,4 @@ events-menu-rename disable-events-filters events-remove-breadcrumbs simplify-lectures-list +move-to-openerp-objects