courses : Managing courses¶
courses plugin adds functionality for managing
The internal name "courses" is for historic reasons. We should one day rename the plugin to "activities". We didn't yet do this because we are so used with the old name and because a rename will require extra attention with database migrations.
This is a tested document. The following instructions are used for initialization:
>>> from lino import startup >>> startup('lino_book.projects.min9.settings') >>> from lino.api.doctest import *
- class lino_xl.lib.courses.Course¶
Django database model to represent an activity.
Don't generate meeting having their start date beyond this date.
Until when new enrolments are accepted.
Available places. The maximum number of participants to allow in this activity.
Number of free places.
Number of requested places.
Number of trying places.
Number of confirmed places.
Inherited database fields:
- class lino_xl.lib.courses.Courses¶
Base table for all activities.
Whether to show or to hide courses in an exposed state.
That is, all courses in a state that has
CourseState.is_exposedset to True.
This parameter is ignored if the
stateparameter is also specified.
- class lino_xl.lib.courses.MyActivities¶
Show the courses authored by me (i.e. where I am the responsible manager). Compare
- class lino_xl.lib.courses.MyCoursesGiven¶
Show the courses given by me (i.e. where I am the teacher). Compare
This requires the
partnerfield in my user settings to point to me as a teacher.
For users whose
partnerfield is empty, this list shows all courses without teacher.
- class lino_xl.lib.courses.ActivitiesByLine¶
Show the courses per course line.
- class lino_xl.lib.courses.ActivitiesByTopic¶
Shows the courses of a given topic.
- class lino_xl.lib.courses.Enrolment¶
Django database model to represent an activity enrolment.
Virtual HtmlBox field showing the name and address of the participant.
- class lino_xl.lib.courses.AllEnrolments¶
Show global list of all enrolments.
- class lino_xl.lib.courses.PendingRequestedEnrolments¶
Show all requested enrolments.
- class lino_xl.lib.courses.PendingConfirmedEnrolments¶
Show all confirmed enrolments.
- class lino_xl.lib.courses.EnrolmentsByPupil¶
Show all enrolments of a given pupil.
- class lino_xl.lib.courses.EnrolmentsByCourse¶
Show the enrolments of a this course.
The state of an enrolment can be one of the following:
>>> rt.show('courses.EnrolmentStates') ======= =========== =========== ============= ============= ============== value name text Button text invoiceable Uses a place ------- ----------- ----------- ------------- ------------- -------------- 10 requested Requested No No 11 trying Trying No Yes 20 confirmed Confirmed Yes Yes 30 cancelled Cancelled No No ======= =========== =========== ============= ============= ==============
- class lino_xl.lib.courses.EnrolmentStates¶
The list of possible states of an enrolment.
The default implementation has the following values:
The enrolment was cancelled before it even started.
The enrolment was was successfully ended.
The enrolment was abandoned.
- class lino_xl.lib.courses.Line¶
Django database model to represent an activity line.
The designation of this activity line as seen by the user e.g. when selecting the line.
One field for every
The text to print as title in enrolments.
The body template to use when printing an activity of this line. Leave empty to use the site's default (defined by body_template on the
The default configuration contains only one choice:
>>> rt.show(courses.ActivityLayouts) ======= ========= ============ ============================ value name text Table ------- --------- ------------ ---------------------------- C default Activities courses.ActivitiesByLayout ======= ========= ============ ============================
The layout of an activity can customize how data fields and related data are to
be laid out on screen. This is done by defining a subclass of
ActivitiesByLayout and referring to it in the
- class lino_xl.lib.courses.ActivityLayouts¶
>>> rt.show(courses.CourseStates) ======= ========== ========== ========= ========== ============= ================= value name text Exposed Editable Invoiceable Update calendar ------- ---------- ---------- --------- ---------- ------------- ----------------- 10 draft Draft Yes Yes No No 20 active Started Yes No Yes No 30 inactive Inactive No No No No 40 closed Closed No No No No ======= ========== ========== ========= ========== ============= =================
Every course state has itself some additional attributes that are used to group them at certain places.
- class lino_xl.lib.courses.CourseState¶
For example you can retrieve a list of course states that are to be
considered "exposed" (
>>> courses.CourseStates.filter(is_exposed=True) [<courses.CourseStates.draft:10>, <courses.CourseStates.active:20>]
>>> courses.CourseStates.filter(is_exposed=False) [<courses.CourseStates.inactive:30>, <courses.CourseStates.closed:40>]
As an application developer you can redefine the items of
CourseStates in order to adapt it to the needs of your
TODO: Write a tutorial about redefining choicelists.
- class lino_xl.lib.courses.Plugin¶
- teacher_model = 'contacts.Person'
- pupil_model = 'contacts.Person'
- pupil_name_fields = "pupil__name"
The value to use as
Note that this remains a text string while
quick_search_fieldsis resolved into a tuple of data elements at site startup.