comments (comments in Avanti)

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

A tested document

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

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

Overview

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
True

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'>]

Tests

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

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

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) <Detail>`__
 2    martina         `ABAD Aábdeen (114) <Detail>`__
 3    nathalie        `ABAD Aábdeen (114) <Detail>`__
 4    nelly           `ABAD Aábdeen (114) <Detail>`__
 5    sandra          `ABAD Aábdeen (114) <Detail>`__
 6    Laura Lieblig   `ABAD Aábdeen (114) <Detail>`__
==== =============== =================================

Anonymous users don't see any comment:

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

Nathalie sees only her comments:

>>> rt.login("nathalie").show(comments.Comments,
...     column_names="id user owner", limit=6)
... 
==== ========== ========================================
 ID   Author     Topic
---- ---------- ----------------------------------------
 3    nathalie   `ABAD Aábdeen (114) <Detail>`__
 12   nathalie   `ABBASI Aáishá (118) <Detail>`__
 21   nathalie   `ABDOU Abeer (143) <Detail>`__
 30   nathalie   `ABOOD Abdul Fáttááh (163) <Detail>`__
 39   nathalie   `ALEKSANDROV Akim (116) <Detail>`__
 48   nathalie   `ASTAFUROV Agáfiiá (175) <Detail>`__
==== ========== ========================================
>>> rt.show(comments.RecentComments)
>>> rt.login("audrey").show(comments.RecentComments)
>>> rt.login("nathalie").show(comments.RecentComments)
... 
`... <Detail>`__ by *nathalie* about `ABDELRAHMAN Aáqil (133) <Detail>`__ :
...