cal (Calendar)

A tested document

This is a tested document. The following instructions are used for initialization:

>>> from lino_patrols.projects.patrols1.startup import *

Customized cal.Event model

class lino_patrols.lib.cal.Event
complete

Check this to prevent more users from joining this service tour.

closed

Check this when you have submitted your legacy report for this service tour.

Planner columns

class lino_patrols.lib.cal.PlannerColumns

A choicelist of columns to show in certain reports.

Especially in the daily view in lino_xl.lib.calview (calview.DailyPlanner). Also in patrols.DaysToPlan.

>>> rt.show(cal.PlannerColumns)
======= ====== ===============
 value   name   text
------- ------ ---------------
 10             Bot-MdP
 20             BM-FP-TB-MT-W
 30             BM-FP-VP-B
 40             Bayehon
 50             Warche
 60             Noire Eau
 70             Vélo
 99             etc
======= ====== ===============

Event layouts

In Patrols we have a second EventLayouts

>>> rt.show(cal.EventLayouts)
======= =============== ================== ============
 value   name            text               Table name
------- --------------- ------------------ ------------
 100     default         Calendar entries   cal.Events
 200     service_tours   Service tours      cal.Tours
======= =============== ================== ============

Linking to a calendar entry

When we have more than one event layout, the get_detail_action is responsible for returning the correct table for showing the detail of a given calendar entry.

For example let’s look at two different calendar entries:

>>> obj1 = cal.Event.objects.first()
>>> obj1
Event #15 ("New Year's Day (01.01.2027)")
>>> obj1.event_type
EventType #2 ('Holidays')
>>> obj2 = cal.Event.objects.filter(event_type__name="Deployment").first()
>>> obj2
Event #231 ('Patrols (26/02/2026 Bot-MdP) (27.02.2026 10:00)')
>>> obj2.event_type
EventType #3 ('Deployment')
>>> ar = rt.login("robin", show_urls=True)
>>> ar.obj2htmls(obj1)
'<a href="/admin/#/api/cal/Events/15">01/01/2027 New Year\'s Day</a>'
>>> ar.obj2url(obj1)
'/admin/#/api/cal/Events/15'
>>> ar.obj2url(obj2)
'/admin/#/api/cal/Tours/231'
>>> obj1.get_detail_action(ar)
<BoundAction(cal.Events, <lino.core.actions.common.ShowDetail detail ('Detail')>)>
>>> obj2.get_detail_action(ar)
<BoundAction(cal.Tours, <lino.core.actions.common.ShowDetail detail ('Detail')>)>

Miscellaneous

The cal.Guest model has no detail layout in Patrols.

>>> print(cal.Guests.detail_layout)
None