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
CommentsByOwner.
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.comments
plugin adds a framework for handling comments.This article is a general description, see also comments (comments in Noi) and comments (comments in Avanti).
Side note: Code snippets (lines starting with
>>>
) in this document get tested as part of our development workflow. The following initialization snippet tells you which demo project is being used in this document.Don’t read this¶
Comments¶
The database model to represent a comment.
The author of the comment.
The discussion topic this comment is about.
The
owner
of 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.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 byhaving these database models inherit from
Commentable
andadding the
CommentsByRFC
panel 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_date
andend_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 for a given database object.
The choicelist with selections for
Comments.observed_event
.Emotions¶
The list of available values for the
Comment.emotion
field.Comment types¶
The
CommentType
model 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.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.
Usage example in
lino_xl.lib.groups.Group
andlino_xl.lib.tickets.Ticket
.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 CommentsByOwner.
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.
This is automatically called when a comment has been created or modified.