Welcome | Get started | Dive into Lino | Contribute | Reference

comments (comments in Avanti)

The lino.modlib.comments in Lino Avanti is configured and used to satisfy the application requirements.

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

>>> from lino import startup
>>> startup('lino_book.projects.avanti1.settings')
>>> from lino.api.doctest import *


Comments in Lino Avanti are considered confidential data and can be seen only by users with appropriate permission.

See also User types in Lino Avanti.

Private comments are seen only by their respective author.

Public comments are shown to other social workers. Comments are never shown to the external supervisor.

A system administrator can see all comments (it makes no sense to hide them because a system admin can easily create or use a user account with the permissions they want).

Comments are private by default:

>>> dd.plugins.comments.private_default

There is only one Commentable thing in Lino Avanti: the client.

>>> list(rt.models_by_base(comments.Commentable))
[<class 'lino_avanti.lib.avanti.models.Client'>]


The demo database contains 108 comments, and they are all private.

>>> rt.models.comments.Comment.objects.all().count()
>>> rt.models.comments.Comment.objects.filter(private=True).count()

Robin can see them all.

>>> rt.login("robin").show(comments.Comments,
...     column_names="id user owner", limit=6)
==== =============== =============================================================
 ID   Author          Topic
---- --------------- -------------------------------------------------------------
 1    audrey          `ABAD Aábdeen (114/nathalie) </#/api/avanti/Clients/114>`__
 2    martina         `ABAD Aábdeen (114/nathalie) </#/api/avanti/Clients/114>`__
 3    nathalie        `ABAD Aábdeen (114/nathalie) </#/api/avanti/Clients/114>`__
 4    nelly           `ABAD Aábdeen (114/nathalie) </#/api/avanti/Clients/114>`__
 5    sandra          `ABAD Aábdeen (114/nathalie) </#/api/avanti/Clients/114>`__
 6    Laura Lieblig   `ABAD Aábdeen (114/nathalie) </#/api/avanti/Clients/114>`__
==== =============== =============================================================

Nathalie sees only her own comments:

>>> rt.login("nathalie").show(comments.Comments,
...     column_names="id user owner", limit=6)
==== ========== ==============================================================
 ID   Author     Topic
---- ---------- --------------------------------------------------------------
 3    nathalie   `ABAD Aábdeen (114/nathalie) </#/api/avanti/Clients/114>`__
 12   nathalie   `ABBAS Aábid (115/nelly) </#/api/avanti/Clients/115>`__
 21   nathalie   `ABBASI Aáishá (118/romain) </#/api/avanti/Clients/118>`__
 30   nathalie   `ABDALLAH Aáish (127/robin) </#/api/avanti/Clients/127>`__
 39   nathalie   `ABDELLA Aákif (128/nathalie) </#/api/avanti/Clients/128>`__
 48   nathalie   `ABDELNOUR Aámir (125/nelly) </#/api/avanti/Clients/125>`__
==== ========== ==============================================================
>>> rt.login("nathalie").show(comments.RecentComments)
`... </#/api/comments/RecentComments/102>`__ by **nathalie** in reply to **martina** about `ABDULLAH Afááf (155/robin) </#/api/avanti/Clients/155>`__ :

Anonymous users and auditors don't see any comment:

>>> rt.show(comments.Comments,
...     column_names="id user owner", limit=6)
No data to display
>>> rt.show(comments.RecentComments)
>>> rt.login("audrey").show(comments.RecentComments)