From 6d25d63981872c8080293ec1e77d8410dc3eae75 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Thu, 30 Jan 2014 15:07:23 +0100 Subject: [PATCH] [ADD] lectures model, demonstrate date fields & options --- doc/howto/howto_website.rst | 28 ++++- doc/howto/howto_website/lectures-model-add | 115 +++++++++++++++++++++ doc/howto/howto_website/series | 1 + 3 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 doc/howto/howto_website/lectures-model-add diff --git a/doc/howto/howto_website.rst b/doc/howto/howto_website.rst index 025cc3a5c1a..d9a84a30e42 100644 --- a/doc/howto/howto_website.rst +++ b/doc/howto/howto_website.rst @@ -423,8 +423,30 @@ they can be moved around as necessary (cancelled/rescheduled), they can have numerous pieces of data attached both intrinsic (lecture transcripts) and extrinsic (attendance records, student discussions, etc…). -.. calendar model -.. demo data for events dates +.. patch:: + +.. TODO:: ``-u`` did not work, not even ``-uall``, new data file does not get + installed + +Note a new feature: ``t-field`` tags can take options through +``t-field-options``. The options must be a JSON_ object. Available options +depend on the field's type and potentially the display widget (some types +of fields can be displayed in multiple manners). In this case, the same +``date`` field is displayed using custom date formats, one being the generic +``long`` (which depends on the current user's locale) and the other being +an explicit format for `the weekday in short form +`_. + +.. note:: in edition mode, formatted date and datetime fields revert to a + canonical representation in order to provide all of the field's + information. + +.. warning:: if you edit the course's dates, you will notice that the two + displays of the ``date`` field are unlinked, if one is edited + the second one will not change until the edition is saved. This + is a limitation of the current ``website`` but may be improved in + future releases. + .. access & formatting .. sending & storing comments (?) @@ -449,3 +471,5 @@ Administration and ERP Integration .. _templates: http://en.wikipedia.org/wiki/Web_template .. _your openerp: http://localhost:8069/ + +.. _JSON: http://www.json.org diff --git a/doc/howto/howto_website/lectures-model-add b/doc/howto/howto_website/lectures-model-add new file mode 100644 index 00000000000..dd53130721d --- /dev/null +++ b/doc/howto/howto_website/lectures-model-add @@ -0,0 +1,115 @@ +# HG changeset patch +# Parent 65912bc56408d6bf61b2023a79a48e06a22fe9e2 + +diff --git a/__openerp__.py b/__openerp__.py +--- a/__openerp__.py ++++ b/__openerp__.py +@@ -6,5 +6,6 @@ + 'ir.model.access.csv', + 'views/templates.xml', + 'data/teaching_assistants.xml', ++ 'data/lectures.xml', + ] + } +diff --git a/controllers.py b/controllers.py +--- a/controllers.py ++++ b/controllers.py +@@ -4,10 +4,15 @@ from openerp.addons.web.controllers impo + class Home(main.Home): + @http.route('/', auth='public') + def index(self): ++ 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) ++ lectures = Lectures.browse( ++ cr, uid, Lectures.search(cr, uid, [], context=context), context=context) + return http.request.website.render('academy.index', { + 'tas': tas, ++ 'lectures': lectures, + }) + + @http.route('/tas//', auth='public', website=True) +diff --git a/data/lectures.xml b/data/lectures.xml +new file mode 100644 +--- /dev/null ++++ b/data/lectures.xml +@@ -0,0 +1,24 @@ ++ ++ ++ ++ Lecture 1 ++ 2014-01-06 ++ ++ ++ Lecture 2 ++ 2014-01-08 ++ ++ ++ Lecture 3 ++ 2014-01-10 ++ ++ ++ Lecture 4 ++ 2014-01-13 ++ ++ ++ Lecture 5 ++ 2014-01-15 ++ ++ ++ +diff --git a/ir.model.access.csv b/ir.model.access.csv +--- a/ir.model.access.csv ++++ b/ir.model.access.csv +@@ -1,2 +1,3 @@ + 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 +diff --git a/models.py b/models.py +--- a/models.py ++++ b/models.py +@@ -9,3 +9,12 @@ class TeachingAssistants(orm.Model): + 'name': fields.char(), + 'biography': fields.html(), + } ++ ++class Lectures(orm.Model): ++ _name = 'academy.lectures' ++ _order = 'date ASC' ++ ++ _columns = { ++ 'name': fields.char(required=True), ++ 'date': fields.date(required=True), ++ } +diff --git a/views/templates.xml b/views/templates.xml +--- a/views/templates.xml ++++ b/views/templates.xml +@@ -22,6 +22,27 @@ + + + ++

Course Calendar

++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++
DateDayTopic
++ ++ ++ ++ ++ ++
+ + +
diff --git a/doc/howto/howto_website/series b/doc/howto/howto_website/series index e54bbbb05e1..162e9df8bbe 100644 --- a/doc/howto/howto_website/series +++ b/doc/howto/howto_website/series @@ -13,3 +13,4 @@ ta-view-fix ta-t-field ta-html-biography ta-template-biography +lectures-model-add