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.
>>> obj=comments.Comment.objects.get(pk=1)>>> obj.ownerTicket #116 ('#116 (Why <p> tags are so bar)')
>>> ar=rt.login('robin')>>> ar.show(comments.CommentsByRFC,obj.owner,... display_mode="grid",column_names="id body_short_preview reply_to user")+----+------------------------------------------------------------------------------------------+------------+-----------------+| ID | Preview | Reply to | Author |+====+==========================================================================================+============+=================+| 7 | breaking **De :** [lino@foo.net](mailto:lino@foo.net) | Comment #6 | Robin Rood || | [[mailto:foo@bar.com](mailto:foo@bar.com)] | | || | **Envoyé :** mardi 18 octobre 2016 08:52 | | || | **À :** [eexample@foo.com](mailto:Far@baz.net) | | || | **Objet :** [welcht] YOU modified FOO BAR Dear Aurélie , this is to notify / | | || | BAR BAR modified TODO: include a summary of the modifications. Any subsequent | | || | notifications about foo/ until you view this notification in the Lino web | | || | interface. Please visit [None](None) and follow your welcome messages. | | |+----+------------------------------------------------------------------------------------------+------------+-----------------+| 6 | Lorem ipsum **dolor sit amet** , consectetur adipiscing elit. Donec interdum | Comment #3 | Rolf Rompen || | dictum erat. Fusce condimentum erat a pulvinar ultricies. Phasellus gravida | | || | ullamcorper eros, sit amet blandit sapien laoreet quis. Donec accumsan mauris | | || | at risus lobortis, nec pretium tortor aliquam. Nulla vel enim vel eros ... | | |+----+------------------------------------------------------------------------------------------+------------+-----------------+| 5 | Lorem ipsum **dolor sit amet** , consectetur adipiscing elit. Nunc cursus | Comment #3 | Romain Raffault || | felis nisi, eu pellentesque lorem lobortis non. Aenean non sodales neque, | | || | vitae venenatis lectus. In eros dui, gravida et dolor at, pellentesque | | || | hendrerit magna. Quisque vel lectus dictum, rhoncus massa feugiat, condimentum | | || | sem. D... | | |+----+------------------------------------------------------------------------------------------+------------+-----------------+| 4 | | Who | What | Done? | | Comment #3 | Mathieu || | |------|---------------|-------| | | || | | Him | Bar | | | | || | | Her | Foo the Bar | **x** | | | || | | Them | Floop the pig | | | || | | | x | | | |+----+------------------------------------------------------------------------------------------+------------+-----------------+| 3 | Styled comment pasted from word! | Comment #1 | Marc |+----+------------------------------------------------------------------------------------------+------------+-----------------+| 2 | Here is a screenshot: [](/api/uploads/Uploads/2) | | |+----+------------------------------------------------------------------------------------------+------------+-----------------+| 1 | Here is a screenshot: | | Jean || | [](/api/uploads/Uploads/1) | | |+----+------------------------------------------------------------------------------------------+------------+-----------------+
When this comment has been published. A timestamp.
The Comment.owner field is a generic foreign key, i.e.
theoretically users can discuss about any database object, but actually the
application developer decides which database models can serve as topics
for commenting by
having these database models inherit from Commentable and
Add filters to the given queryset of comments, requested by the given
user.
Return None to not add any filter. Otherwise the return value should
be a django.db.models.Q object.
Default behaviour is that public comments are visible even to anonymous
while private comments are visible only to their author and to
PrivateCommentsReader.
You can override this class method to define your own privacy settings.
If you override this method, you probably want to define a
django.contrib.contenttypes.fields.GenericRelation field on
your model in order to write filter conditions based on the owner of the
comment.
Return a HTML formatted string with the description of this
Commentable as it should be displayed by the slave summary of
CommentsByRFC.
It must be a string and not an etree element. That’s because
it usually includes the content of RichTextField. If the API
required an element, it would require us to parse this content
just in order to generate HTML from it.
comments: The comments framework¶The
lino.modlib.commentsplugin adds a framework for handling comments.This article is a general description, see also comments in Noi and comments (comments in Avanti).
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.Print a full tree of comments¶
The CommentsByRFC table displays comments in “list” mode (one paragraph per comment)
Find a thread of comments:
Comments¶
The database model to represent a comment.
The author of the comment.
The user group this comment belongs to.
Inherited from
lino_xl.lib.groups.Groupwise.group.Default value is the first non-empty value of (1) the group of the
owner, (2) the user’scurrent_groupor (3) the site’s default group.The discussion topic this comment is about.
The
ownerof a comment must be an instance of a subclass ofCommentable.The full body text of your comment.
The first paragraph of your
body.The emotion of this comment.
When this comment has been published. A timestamp.
The
Comment.ownerfield is a generic foreign key, i.e. theoretically users can discuss about any database object, but actually the application developer decides which database models can serve as topics for commenting byhaving these database models inherit from
Commentableandadding the
CommentsByRFCpanel to their detail layout.Whether to show only (un)published comments, independently of the publication date.
Hide comments before this date.
Hide comments after this date.
Which event (created, modified or published) to consider when applying the date range given by
start_dateandend_date.Show all comments.
Show the comments posted by the current user.
Show the most recent comments that have been posted on this site.
Shows the comments about a given database row.
The choicelist with selections for
Comments.observed_event.Emotions¶
The list of available values for the
Comment.emotionfield.Comment types¶
The
CommentTypemodel is not being used in production, one day we will probably remove it.The table with all existing comment types.
This usually is accessible via the Configure menu.
Commentable¶
Mixin for models that are commentable, i.e. the rows of which can become discussion topic of comments.
The template to use for the comment that gets generated automatically when an end user creates an instance of this.
Set this to None if you don’t want Lino to generate any comment when an instance gets created.
Add filters to the given queryset of comments, requested by the given user.
Return None to not add any filter. Otherwise the return value should be a
django.db.models.Qobject.Default behaviour is that public comments are visible even to anonymous while private comments are visible only to their author and to
PrivateCommentsReader.You can override this class method to define your own privacy settings.
Usage example in
lino_xl.lib.groups.Groupandlino_xl.lib.tickets.Ticket.If you override this method, you probably want to define a
django.contrib.contenttypes.fields.GenericRelationfield on your model in order to write filter conditions based on the owner of the comment.Return a HTML formatted string with the description of this Commentable as it should be displayed by the slave summary of
CommentsByRFC.It must be a string and not an etree element. That’s because it usually includes the content of RichTextField. If the API required an element, it would require us to parse this content just in order to generate HTML from it.
Called when a comment about this is being created.
This is called from the
on_create()method of theComment, i.e. when initializing the row to be displayed by the insert window.This is automatically called when a comment has been created or modified.
Don’t read this¶