[ADD] lectures model, demonstrate date fields & options
This commit is contained in:
parent
8a73978063
commit
6d25d63981
|
@ -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
|
||||
<http://babel.pocoo.org/docs/dates/#date-fields>`_.
|
||||
|
||||
.. 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
|
||||
|
|
|
@ -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/<model("academy.tas"):ta>/', 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 @@
|
||||
+<openerp>
|
||||
+ <data>
|
||||
+ <record model="academy.lectures">
|
||||
+ <field name="name">Lecture 1</field>
|
||||
+ <field name="date">2014-01-06</field>
|
||||
+ </record>
|
||||
+ <record model="academy.lectures">
|
||||
+ <field name="name">Lecture 2</field>
|
||||
+ <field name="date">2014-01-08</field>
|
||||
+ </record>
|
||||
+ <record model="academy.lectures">
|
||||
+ <field name="name">Lecture 3</field>
|
||||
+ <field name="date">2014-01-10</field>
|
||||
+ </record>
|
||||
+ <record model="academy.lectures">
|
||||
+ <field name="name">Lecture 4</field>
|
||||
+ <field name="date">2014-01-13</field>
|
||||
+ </record>
|
||||
+ <record model="academy.lectures">
|
||||
+ <field name="name">Lecture 5</field>
|
||||
+ <field name="date">2014-01-15</field>
|
||||
+ </record>
|
||||
+ </data>
|
||||
+</openerp>
|
||||
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 @@
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
+ <h2>Course Calendar</h2>
|
||||
+ <table class="table table-condensed table-hover">
|
||||
+ <tr>
|
||||
+ <th>Date</th>
|
||||
+ <th>Day</th>
|
||||
+ <th>Topic</th>
|
||||
+ </tr>
|
||||
+ <tr t-foreach="lectures" t-as="lecture">
|
||||
+ <td>
|
||||
+ <span t-field="lecture.date"
|
||||
+ t-field-options='{"format": "long"}'/>
|
||||
+ </td>
|
||||
+ <td>
|
||||
+ <span t-field="lecture.date"
|
||||
+ t-field-options='{"format": "EEE"}'/>
|
||||
+ </td>
|
||||
+ <td>
|
||||
+ <span t-field="lecture.name"/>
|
||||
+ </td>
|
||||
+ </tr>
|
||||
+ </table>
|
||||
</div>
|
||||
</div>
|
||||
<div class="oe_structure"/>
|
|
@ -13,3 +13,4 @@ ta-view-fix
|
|||
ta-t-field
|
||||
ta-html-biography
|
||||
ta-template-biography
|
||||
lectures-model-add
|
||||
|
|
Loading…
Reference in New Issue