Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More
The show() function¶
This document shows some usage examples of the show method of an action request.
This page contains code snippets (lines starting with >>>), which are
being tested during our development workflow. The following
snippet initializes the demo project used throughout this page.
>>> from lino_book.projects.avanti1.startup import *
The show() method checks whether the user has permission to see the
specified actor. The rt.show() function opens an action request for robin.
So the following two are equivalent:
>>> rt.show(cal.EntryStates)
======= ============ ============ ============= ============= ======== ============= =========
value name text Button text Fill guests Stable Transparent No auto
------- ------------ ------------ ------------- ------------- -------- ------------- ---------
10 suggested Suggested ? Yes No No No
20 draft Draft ☐ Yes No No No
50 took_place Took place ☑ No Yes No No
70 cancelled Cancelled ☒ No Yes Yes Yes
======= ============ ============ ============= ============= ======== ============= =========
>>> rt.login('robin').show(cal.EntryStates)
======= ============ ============ ============= ============= ======== ============= =========
value name text Button text Fill guests Stable Transparent No auto
------- ------------ ------------ ------------- ------------- -------- ------------- ---------
10 suggested Suggested ? Yes No No No
20 draft Draft ☐ Yes No No No
50 took_place Took place ☑ No Yes No No
70 cancelled Cancelled ☒ No Yes Yes Yes
======= ============ ============ ============= ============= ======== ============= =========
Show links and urls¶
You may want to show which cells would be clickable if your request was rendered in an interactive front end. This makes the table less beautiful but more informative.
>>> rt.show(courses.Topics)
==== ================== ================== ================== =====
ID Designation Designation (de) Designation (fr) No.
---- ------------------ ------------------ ------------------ -----
1 Citizen course Citizen course Citizen course 1
2 Language courses Language courses Language courses 2
==== ================== ================== ================== =====
>>> rt.show(courses.Topics, show_links=True)
=========== ================== ================== ================== =====
ID Designation Designation (de) Designation (fr) No.
----------- ------------------ ------------------ ------------------ -----
`1 <…>`__ Citizen course Citizen course Citizen course 1
`2 <…>`__ Language courses Language courses Language courses 2
=========== ================== ================== ================== =====
You may want to make it even more informative by showing the full urls of the links.
>>> rt.show(courses.Topics, show_urls=True)
================================= ================== ================== ================== =====
ID Designation Designation (de) Designation (fr) No.
--------------------------------- ------------------ ------------------ ------------------ -----
`1 </#/api/courses/Topics/1>`__ Citizen course Citizen course Citizen course 1
`2 </#/api/courses/Topics/2>`__ Language courses Language courses Language courses 2
================================= ================== ================== ================== =====
Links in displayfield columns are shown even when show_links is not specified (that’s actually a bug but nobody has complained about it so far):
>>> language_courses = courses.Topic.objects.get(pk=2)
>>> rt.show(courses.ActivitiesByTopic, language_courses)
====================================== =========== ============= ================== =========== ============= =========== ========
Activity When Times Available places Confirmed Free places Requested Trying
-------------------------------------- ----------- ------------- ------------------ ----------- ------------- ----------- --------
`Alphabetisation (16/01/2017) <…>`__ Every day 09:00-12:00 5 3 0 3 2
`Alphabetisation (16/01/2017) <…>`__ Every day 14:00-17:00 15 2 0 4 13
`Alphabetisation (16/01/2017) <…>`__ Every day 18:00-20:00 15 12 0 11 3
**Total (3 rows)** **35** **17** **0** **18** **18**
====================================== =========== ============= ================== =========== ============= =========== ========
Here are a few more examples
>>> language_courses = courses.Topic.objects.get(pk=2)
>>> rt.show(courses.LinesByTopic, language_courses)
==================== ====================== ====================== ====================== ================== ============ ===================== ===================== ============ ==============
Reference Designation Designation (de) Designation (fr) Topic Layout Calendar entry type Manage presences as Recurrency Repeat every
-------------------- ---------------------- ---------------------- ---------------------- ------------------ ------------ --------------------- --------------------- ------------ --------------
Alphabetisation Alphabetisation Alphabetisation Language courses Activities Lesson Pupil weekly 1
German A1+ German A1+ German A1+ Language courses Activities Lesson Pupil weekly 1
German A2 German A2 German A2 Language courses Activities Lesson Pupil weekly 1
German A2 (women) German A2 (women) German A2 (women) Language courses Activities Lesson Pupil weekly 1
German for beginners German for beginners German for beginners Language courses Activities Lesson Pupil weekly 1
**Total (5 rows)** **5**
==================== ====================== ====================== ====================== ================== ============ ===================== ===================== ============ ==============
>>> rt.show(courses.AllActivities, show_links=True)
========================= ============ ======================= ================== =========== =============
Activity line Start date Instructor Author When Times
------------------------- ------------ ----------------------- ------------------ ----------- -------------
`Alphabetisation <…>`__ 16/01/2017 `Laura Lieblig <…>`__ `nelly <…>`__ Every day 18:00-20:00
`Alphabetisation <…>`__ 16/01/2017 `Laura Lieblig <…>`__ `nathalie <…>`__ Every day 14:00-17:00
`Alphabetisation <…>`__ 16/01/2017 `Laura Lieblig <…>`__ `martina <…>`__ Every day 09:00-12:00
========================= ============ ======================= ================== =========== =============
The following simulates a case where a browser window was still open but the session had become invalid and hence th user was anonymous.
>>> rt.login('').show(courses.MyCoursesGiven, check_permission=False)
...
Error while executing <ActionRequest courses.MyCoursesGiven.grid({'known_values':
{'teacher': <lino.core.auth.utils.AnonymousUser object at ...>}, 'user': 'anonymous'})>:
Field 'id' expected a number but got <lino.core.auth.utils.AnonymousUser object at ...>.
(Subsequent warnings will be silenced.)
Field 'id' expected a number but got <lino.core.auth.utils.AnonymousUser object at ...>.
(set catch_layout_exceptions to see details)
This case no longer happens:
>>> res = test_client.get('/api/courses/MyCoursesGiven')
Forbidden (Permission denied): /api/courses/MyCoursesGiven
Traceback (most recent call last):
...
django.core.exceptions.PermissionDenied: As 000 (Anonymous) you have no view permission for this action.
More examples…
>>> rt.login('laura').show(courses.MyCoursesGiven)
...
============ ====================================== =========== ============= ====== =============
Start date Activity When Times Room Workflow
------------ -------------------------------------- ----------- ------------- ------ -------------
16/01/2017 `Alphabetisation (16/01/2017) <…>`__ Every day 09:00-12:00 **Started**
16/01/2017 `Alphabetisation (16/01/2017) <…>`__ Every day 14:00-17:00 **Started**
16/01/2017 `Alphabetisation (16/01/2017) <…>`__ Every day 18:00-20:00 **Started**
============ ====================================== =========== ============= ====== =============
>>> obj = courses.Course.objects.get(pk=1)
>>> rt.login('laura').show('cal.EventsByOwner', obj)
...
`[img add] <…>`__ `⏏ <…>`__ |
February 2017: `Fri 24. <…>`__? `Thu 23. <…>`__? `Tue 21. <…>`__? `Mon 20. <…>`__? `Fri 17. <…>`__? `Thu 16. <…>`__? `Tue 14. <…>`__? `Mon 13. <…>`__? `Fri 10. <…>`__? `Thu 09. <…>`__? `Tue 07. <…>`__☑ `Mon 06. <…>`__☑ `Fri 03. <…>`__☒ `Thu 02. <…>`__☑
January 2017: `Tue 31. <…>`__☑ `Mon 30. <…>`__☑ `Fri 27. <…>`__☑ `Thu 26. <…>`__☑ `Tue 24. <…>`__☑ `Mon 23. <…>`__☑ `Fri 20. <…>`__☑ `Thu 19. <…>`__☒ `Tue 17. <…>`__☑ `Mon 16. <…>`__☑
Suggested : 10 , Draft : 0 , Took place : 12 , Cancelled : 2 `[img add] <…>`__
Even though Nathalie is author of the morning course, it is Laura (the teacher) who is responsible for the individual events.
>>> rt.login('laura').show('cal.MyEvents')
...
====================================== ======== ===================================
Calendar entry Client Workflow
-------------------------------------- -------- -----------------------------------
`Lesson 19 (16.02.2017 09:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 19 (16.02.2017 14:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 19 (16.02.2017 18:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 20 (17.02.2017 09:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 20 (17.02.2017 14:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 20 (17.02.2017 18:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 21 (20.02.2017 09:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 21 (20.02.2017 14:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 21 (20.02.2017 18:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 22 (21.02.2017 09:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 22 (21.02.2017 14:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 22 (21.02.2017 18:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 23 (23.02.2017 09:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 23 (23.02.2017 14:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 23 (23.02.2017 18:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 24 (24.02.2017 09:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 24 (24.02.2017 14:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
`Lesson 24 (24.02.2017 18:00) <…>`__ [▽] **? Suggested** → [☐] [☑] [☒]
====================================== ======== ===================================
>>> rt.show(courses.ReminderStates)
======= =========== =========== =============
value name text Button text
------- ----------- ----------- -------------
10 draft Draft
20 sent Sent
30 ok OK
40 final Final
90 cancelled Cancelled
======= =========== =========== =============
>>> rt.login("romain").show(courses.DitchingEnrolments)
============== ================================ ============================== =================
Missing rate Participant Activity Primary coach
-------------- -------------------------------- ------------------------------ -----------------
54,17 ABID Abdul Báásid (63/romain) Alphabetisation (16/01/2017) Romain Raffault
54,17 CISSE Chátá (51/romain) Alphabetisation (16/01/2017) Romain Raffault
50,00 BEK-MURZIN Agápiiá (61/romain) Alphabetisation (16/01/2017) Romain Raffault
============== ================================ ============================== =================
>>> obj = courses.Course.objects.get(pk=1)
>>> rt.login('rolf').show('courses.EnrolmentsByCourse', obj, show_urls=True)
...
================================================================= ======== ============= ========== =========== ======== ============== ================================================== ============================================
Participant Gender Nationality Age Childcare Remark Missing rate Workflow Municipality
----------------------------------------------------------------- -------- ------------- ---------- ----------- -------- -------------- -------------------------------------------------- --------------------------------------------
`ARNOLD Alexei (30/nathalie) </#/api/avanti/Clients/30>`__ Male 28 years No 50,00 **Confirmed** → [Cancelled] [Requested] [Trying] `4700 Eupen </#/api/countries/Places/1>`__
`ABDELNOUR Aámir (26/nelly) </#/api/avanti/Clients/26>`__ Male 28 years No **Requested** → [Confirm] [Cancelled] [Trying] `4700 Eupen </#/api/countries/Places/1>`__
`ARENT Afánásiiá (25/robin) </#/api/avanti/Clients/25>`__ Female 27 years No 50,00 **Trying** → [Requested] `4700 Eupen </#/api/countries/Places/1>`__
`DEMEULENAERE Dorothée (22/nelly) </#/api/avanti/Clients/22>`__ Female unknown No **Confirmed** → [Cancelled] [Requested] [Trying] `4700 Eupen </#/api/countries/Places/1>`__
`ABBASI Aáishá (19/romain) </#/api/avanti/Clients/19>`__ Female 20 years No **Requested** → [Confirm] [Cancelled] [Trying] `4700 Eupen </#/api/countries/Places/1>`__
`ALEKSANDROV Akim (17/nathalie) </#/api/avanti/Clients/17>`__ Male 18 years No **Trying** → [Requested] `4700 Eupen </#/api/countries/Places/1>`__
`ABBAS Aábid (16/nelly) </#/api/avanti/Clients/16>`__ Male 17 years No **Confirmed** → [Cancelled] [Requested] [Trying] `4700 Eupen </#/api/countries/Places/1>`__
`ABEZGAUZ Adrik (13/nelly) </#/api/avanti/Clients/13>`__ Male 16 years No **Requested** → [Confirm] [Cancelled] [Trying] `4700 Eupen </#/api/countries/Places/1>`__
================================================================= ======== ============= ========== =========== ======== ============== ================================================== ============================================
NB In the snippet above, the Municipality field (which is a virtual FK field) was not clickable until 20251126. Seems that this was a bug that nobody had noticed until now.
>>> kwargs = dict(column_names="id user owner", limit=3,
... display_mode=DISPLAY_MODE_GRID)
>>> rt.login("robin").show(comments.Comments, **kwargs)
...
==== ========== ==================================
ID Author Topic
---- ---------- ----------------------------------
1 audrey `BALLO Armáni (80/romain) <…>`__
2 martina `BALLO Armáni (80/romain) <…>`__
3 nathalie `BALLO Armáni (80/romain) <…>`__
==== ========== ==================================