lino 25.8.0__py3-none-any.whl → 25.8.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
lino/__init__.py CHANGED
@@ -31,7 +31,7 @@ from django import VERSION
31
31
  from django.apps import AppConfig
32
32
  from django.conf import settings
33
33
  import warnings
34
- __version__ = '25.8.0'
34
+ __version__ = '25.8.2'
35
35
 
36
36
  # import setuptools # avoid UserWarning "Distutils was imported before Setuptools"?
37
37
 
@@ -22,14 +22,6 @@ class Plugin(ad.Plugin):
22
22
  """Which range of emotion icons to provide. Either "business" or "social".
23
23
  """
24
24
 
25
- private_default = True
26
- """Whether comments are private by default.
27
-
28
- The default value for the :attr:`lino.modlib.comments.Comment.private`
29
- field.
30
-
31
- """
32
-
33
25
  def setup_main_menu(self, site, user_type, m, ar=None):
34
26
  mg = site.plugins.office
35
27
  m = m.add_menu(mg.app_label, mg.verbose_name)
@@ -127,5 +127,8 @@ class Commentable(MemoReferrable):
127
127
  # def add_comments_filter(cls, qs, ar):
128
128
  # return qs
129
129
 
130
+ def get_comment_group(self):
131
+ pass
132
+
130
133
  def on_create_comment(self, comment, ar):
131
- comment.private = dd.plugins.comments.private_default
134
+ pass
@@ -19,12 +19,12 @@ from lino.core.requests import BaseRequest
19
19
  from lino.mixins import CreatedModified, BabelNamed
20
20
  from lino.mixins.periods import DateRangeObservable
21
21
  from lino.modlib.users.mixins import UserAuthored
22
+ from lino.modlib.users.mixins import PrivacyRelevant
22
23
  from lino.modlib.notify.mixins import ChangeNotifier
23
24
  from lino.modlib.search.mixins import ElasticSearchable
24
25
  from lino.modlib.gfks.mixins import Controllable
25
26
  from lino.modlib.memo.mixins import Previewable, MemoReferrable
26
27
  from lino.modlib.publisher.mixins import Publishable
27
- from lino_xl.lib.groups.mixins import Groupwise
28
28
  from .choicelists import CommentEvents, Emotions
29
29
  from .mixins import Commentable, MyEmotionField
30
30
  from .roles import CommentsReader, CommentsStaff
@@ -50,7 +50,7 @@ class Comment(
50
50
  Publishable,
51
51
  DateRangeObservable,
52
52
  MemoReferrable,
53
- Groupwise
53
+ PrivacyRelevant
54
54
  ):
55
55
  class Meta:
56
56
  app_label = "comments"
@@ -120,9 +120,6 @@ class Comment(
120
120
  )
121
121
  # more_text = dd.RichTextField(_("More text"), blank=True)
122
122
 
123
- private = models.BooleanField(
124
- _("Confidential"), default=dd.plugins.comments.private_default)
125
-
126
123
  comment_type = dd.ForeignKey("comments.CommentType", blank=True, null=True)
127
124
  # reply_vote = models.BooleanField(_("Upvote"), null=True, blank=True)
128
125
  # reply_vote = models.SmallIntegerField(_("Vote"), default=0,
@@ -287,6 +284,10 @@ class Comment(
287
284
  if self.owner_id:
288
285
  self.owner.on_create_comment(self, ar)
289
286
 
287
+ def get_default_group(self):
288
+ if self.owner:
289
+ return self.owner.get_comment_group()
290
+
290
291
  def after_ui_save(self, ar, cw):
291
292
  super().after_ui_save(ar, cw)
292
293
  if self.owner is not None:
@@ -352,15 +353,6 @@ class Comment(
352
353
  user = ar.get_user()
353
354
  if not user.user_type.has_required_roles([CommentsReader]):
354
355
  return qs.none()
355
- if user.is_anonymous:
356
- qs = qs.filter(private=False)
357
- elif not user.user_type.has_required_roles([CommentsStaff]):
358
- qs = qs.filter(Q(private=False) | Q(user=user))
359
-
360
- # sar = BaseRequest(user=ar.get_user())
361
- # for m in rt.models_by_base(Commentable):
362
- # qs = m.add_comments_filter(qs, sar)
363
-
364
356
  qs = qs.annotate(num_replies=models.Count("replies_to_this"))
365
357
  qs = qs.annotate(num_reactions=models.Count("reactions_to_this"))
366
358
  # qs = qs.annotate(my_emotion='reaction__emotion')
@@ -370,11 +362,6 @@ class Comment(
370
362
  qs = pv.observed_event.add_filter(qs, pv)
371
363
  return qs
372
364
 
373
- # @classmethod
374
- # def get_request_queryset(cls, ar, **filter):
375
- # qs = super().get_request_queryset(ar, **filter)
376
- # return qs
377
-
378
365
  # @dd.htmlbox()
379
366
  # def card_summary(self, ar):
380
367
  # if not ar:
@@ -72,7 +72,7 @@ class CommentDetail(dd.DetailLayout):
72
72
  )
73
73
 
74
74
  more2 = """
75
- id user
75
+ id user group
76
76
  owner_type owner_id
77
77
  created modified
78
78
  comment_type
@@ -38,7 +38,7 @@ from lino.modlib.linod.choicelists import schedule_daily
38
38
  from lino.modlib.memo.mixins import Previewable
39
39
  from lino.mixins.polymorphic import Polymorphic
40
40
  from lino_xl.lib.topics.mixins import Taggable
41
- from lino_xl.lib.groups.mixins import Groupwise
41
+ from lino.modlib.users.mixins import PrivacyRelevant
42
42
  # from .utils import render_node
43
43
 
44
44
  from lino.api import rt, dd
@@ -52,7 +52,7 @@ from .ui import *
52
52
 
53
53
  class Page(
54
54
  Hierarchical, Sequenced, Previewable, Commentable, PublishableContent,
55
- Taggable # , Groupwise
55
+ Taggable # PrivacyRelevant
56
56
  ):
57
57
  class Meta:
58
58
  verbose_name = _("Page")
@@ -24,6 +24,14 @@ class Plugin(ad.Plugin):
24
24
  partner_model = "contacts.Partner"
25
25
  demo_password = "1234"
26
26
  demo_username = None
27
+ private_default = True
28
+ """
29
+ Whether comments (and other PrivacyRelevant things) are private by default.
30
+
31
+ The default value for the :attr:`lino.modlib.users.PrivacyRelevant.private`
32
+ field.
33
+
34
+ """
27
35
 
28
36
  def on_init(self):
29
37
  super().on_init()
@@ -1,8 +1,9 @@
1
1
  # -*- coding: UTF-8 -*-
2
- # Copyright 2011-2020 Rumma & Ko Ltd
2
+ # Copyright 2011-2025 Rumma & Ko Ltd
3
3
  # License: GNU Affero General Public License v3 (see file COPYING for details)
4
4
 
5
5
  from django.db import models
6
+ from django.db.models import Q
6
7
 
7
8
  from django.utils.translation import gettext_lazy as _
8
9
 
@@ -16,7 +17,7 @@ from lino.core.exceptions import ChangedAPI
16
17
  from lino.core import model
17
18
  from lino.core import actions
18
19
  from lino.core import dbtables
19
- from lino.core.roles import SiteStaff
20
+ from lino.core.roles import SiteStaff, SiteAdmin
20
21
  from lino.modlib.printing.mixins import Printable
21
22
 
22
23
  from .roles import Helper, AuthorshipTaker
@@ -470,3 +471,56 @@ class Assignable(Authored):
470
471
  rt.models.notify.Message.emit_notification(
471
472
  ar, self, mt, msg,
472
473
  [(self.assigned_to, self.assigned_to.mail_mode)])
474
+
475
+
476
+ # class Groupwise(dd.Model):
477
+ class PrivacyRelevant(dd.Model):
478
+
479
+ class Meta:
480
+ abstract = True
481
+
482
+ private = models.BooleanField(
483
+ _("Confidential"), default=dd.plugins.users.private_default)
484
+ group = dd.ForeignKey("groups.Group", blank=True, null=True)
485
+
486
+ @classmethod
487
+ def get_request_queryset(cls, ar, **filter):
488
+ # Show only rows that belong to a group of which I am a member or which
489
+ # is public.
490
+ qs = super().get_request_queryset(ar, **filter)
491
+ user = ar.get_user()
492
+ if user.is_anonymous:
493
+ if dd.is_installed('groups'):
494
+ qs = qs.filter(group__private=False)
495
+ return qs.filter(private=False)
496
+ # if user.current_group is not None:
497
+ # qs = qs.filter(group=user.current_group)
498
+ if user.user_type.has_required_roles([SiteAdmin]):
499
+ return qs
500
+ flt = Q(private=False)
501
+ if issubclass(cls, UserAuthored):
502
+ flt |= Q(user=user)
503
+ if dd.is_installed('groups'):
504
+ flt |= Q(group__private=False)
505
+ flt |= Q(group__members__user=user)
506
+ qs = qs.filter(flt).distinct()
507
+ return qs
508
+
509
+ if dd.is_installed("groups"):
510
+
511
+ def on_create(self, ar):
512
+ # if not ar.is_obvious_field('group'):
513
+ # self.group = ar.get_user().current_group
514
+ super().on_create(ar)
515
+ if not self.group_id:
516
+ self.group = ar.get_user().current_group
517
+ if self.group:
518
+ self.private = self.group.private
519
+
520
+ def get_default_group(self):
521
+ return None
522
+
523
+ def full_clean(self):
524
+ if not self.group_id:
525
+ self.group = self.get_default_group()
526
+ super().full_clean()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: lino
3
- Version: 25.8.0
3
+ Version: 25.8.2
4
4
  Summary: A framework for writing desktop-like web applications using Django and ExtJS or React
5
5
  Project-URL: Homepage, https://www.lino-framework.org
6
6
  Project-URL: Repository, https://gitlab.com/lino-framework/lino
@@ -1,6 +1,6 @@
1
1
  lino/.cvsignore,sha256=1vrrWoP-WD8hPfCszHHIiJEi8KUMRCt5WvoKB9TSB1k,28
2
2
  lino/SciTEDirectory.properties,sha256=rCYi_e-6h8Yx5DwXhAa6MBPlVINcl6Vv9BQDYZV2_go,28
3
- lino/__init__.py,sha256=3LpwRlkMk6xt6IDAzhjZGE8PgM2L4Ypq6yP6kuhqqJs,6176
3
+ lino/__init__.py,sha256=XAN2-cu8FkLMvxRW8zzWpdFV9yvghyfDPxR_7VJFrQM,6176
4
4
  lino/ad.py,sha256=AQ-vJ4scac1mx3xegXezxnxyOQpV-a0q3VFMJSDbj2s,142
5
5
  lino/apps.py,sha256=ECq-dPARDkuhngwNrcipse3b4Irj70HxJs44uWEZFc4,27
6
6
  lino/hello.py,sha256=7-PJg7PnEiznyETqGjOwXcKh8rda0qLetpbS2gvRYy0,532
@@ -172,12 +172,12 @@ lino/modlib/checkdata/fixtures/checkdata.py,sha256=LD-uIzRIDEv4v0lrPTdvpH_cLITND
172
172
  lino/modlib/checkdata/management/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
173
173
  lino/modlib/checkdata/management/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
174
174
  lino/modlib/checkdata/management/commands/checkdata.py,sha256=z-mvg8R0G7-BiWcyeyeMUoaLEhi9n58lockOtPdmhCg,1962
175
- lino/modlib/comments/__init__.py,sha256=XoRLIB-pSsz4EfA2FhsbKQ27fsW_AAvS7SyA0_vhHv8,1678
175
+ lino/modlib/comments/__init__.py,sha256=8BitdJVlryi39ihTYY5gbm4k8DlmFongvKKbceozUkU,1506
176
176
  lino/modlib/comments/choicelists.py,sha256=SIA7P_KwtaayqOJxCkwyZouK0Z23-2v4ZFV9a0Zexnk,3314
177
- lino/modlib/comments/mixins.py,sha256=pDlWCsBmIDlGM5EC7znciY5-GytApn6_KuUelWfp1Lo,4370
178
- lino/modlib/comments/models.py,sha256=adzmBA5MBufTcgEIqAKBowz57yr6qoWkBtVd88DHb5M,15980
177
+ lino/modlib/comments/mixins.py,sha256=XHYUEcL1M5xM_c5HUa7b2_Ot-4vAAqIA_wVawerDxy0,4368
178
+ lino/modlib/comments/models.py,sha256=GdDsnok0y1xAafC_wQ48wndTbxsW6k8oVM5ImVdTpCw,15489
179
179
  lino/modlib/comments/roles.py,sha256=z3gctvlTa_5PAs-D4pounyzNyuEc31jTFq9g33r6Z1w,751
180
- lino/modlib/comments/ui.py,sha256=Ttl-Fgx6AzPbeLA0DWE8xPbcHpAoJC5A4s_7QWNCaI8,9909
180
+ lino/modlib/comments/ui.py,sha256=u46TU1Qn2jz3CN-pCmhV8D2HXezEhGGSTZjuTJ4GWME,9915
181
181
  lino/modlib/comments/config/comments/comments.js,sha256=7oAnNyx_MKM1iWPu-QSp6iKfnOVdgq7EciQPpxTvYU8,242
182
182
  lino/modlib/comments/fixtures/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
183
183
  lino/modlib/comments/fixtures/demo2.py,sha256=DSIqNtGOQlwbg8k43nE2ax1x-H_ifRsozvw6LZM330Y,25407
@@ -3591,7 +3591,7 @@ lino/modlib/printing/config/report/Default.wk.html,sha256=4Ssx2LWm1gVpXf0Q4XoSY1
3591
3591
  lino/modlib/publisher/__init__.py,sha256=9w4cclyodBB3PO5rFzheIkzJs-tfA62PSGx2WI0NL5Q,2303
3592
3592
  lino/modlib/publisher/choicelists.py,sha256=gVzjyp1sJ-XewAW-I_bCrKdTLgygLzh1ZwFI1rKyPdo,9070
3593
3593
  lino/modlib/publisher/mixins.py,sha256=yRxAtFSNe9aVvdY-th_a5wmQ76jBfKYWzeNUn-efJMA,6651
3594
- lino/modlib/publisher/models.py,sha256=BvGv6JxdrKoa1VJITOw5Dlbwj96lRdDkCGcRc3uoxG4,17584
3594
+ lino/modlib/publisher/models.py,sha256=mstncIjj2vjON8YRum2AnA6oGNewBScscSD-eZNBteU,17593
3595
3595
  lino/modlib/publisher/renderer.py,sha256=Rl6fX8PzfX6crmnUh8mdU5Mpe44mSN5lTu_Pv8aVSCk,1845
3596
3596
  lino/modlib/publisher/ui.py,sha256=qWp3JWhO6zN_HSZvSlolmNTgiZgoJeY2_TIDh9nYf3Q,4491
3597
3597
  lino/modlib/publisher/views.py,sha256=l_GomdliB1qCylg7jKKkay3ZgAaOPfWNQQ6ZPDjAUl0,2214
@@ -4407,10 +4407,10 @@ lino/modlib/uploads/fixtures/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NM
4407
4407
  lino/modlib/uploads/fixtures/demo.py,sha256=rhidbKN4vOyzqnRLMXu3gkx4zAtxGj3FoSz0qaJlRMA,1913
4408
4408
  lino/modlib/uploads/fixtures/demo3.py,sha256=q0bwZrx5XtRsRlFpsa33fL0sCl7IdCYaP9E1rhCnJt4,547
4409
4409
  lino/modlib/uploads/fixtures/std.py,sha256=nb5oRcX_WrkTLaGoch6PT7GA0FPKmqbN-BdlPq-hHSc,516
4410
- lino/modlib/users/__init__.py,sha256=P9am0pJURsgCmx9J55q8LFChF8Ga9mody1PtJRXWbvM,4578
4410
+ lino/modlib/users/__init__.py,sha256=Q0yT2eOyGBXLStCEDI4U1Fcif-6EDssjX9VndcZ0m54,4794
4411
4411
  lino/modlib/users/actions.py,sha256=NcJVCfIhP3moN2MvhIonyCKzld7ruUtnCX4tFVMK7_c,18445
4412
4412
  lino/modlib/users/choicelists.py,sha256=-X76C1NxIs5e7rFHp5Z0kjJkA1NlOP2vdLKGkI2wZRU,3876
4413
- lino/modlib/users/mixins.py,sha256=Ukib2jUnDR2MVJrASpmzoPS_eke-Z431U78JDPe8ysk,14275
4413
+ lino/modlib/users/mixins.py,sha256=Gyi0aTDN1YcQn86UmIAJhN3Pzql39sqiemF5oUne-RM,16081
4414
4414
  lino/modlib/users/models.py,sha256=V5r_aY7M7gXfY1wAcIknacwsF8k9vtiMY898-y7GSjE,17842
4415
4415
  lino/modlib/users/roles.py,sha256=yi29ELbWU1VtteGARaxetxmsCkZQHA2oJiD0dXujMiE,320
4416
4416
  lino/modlib/users/ui.py,sha256=GkaOHY3yFAErZydyO-noseXWXF1H7xfGVAjlT2NSwlE,13844
@@ -4636,8 +4636,8 @@ lino/utils/xml.py,sha256=EGDnO1UaREst9fS7KTESdbHnrrVCwKbRQdvut6B6GmQ,1612
4636
4636
  lino/utils/mldbc/__init__.py,sha256=QqWRlzeXaOmFfbCk-vTY3SZMn1-FCf67XnpZdd_Nim0,1134
4637
4637
  lino/utils/mldbc/fields.py,sha256=tAX8G5UKigr9c6g0F3ARIjZZtg406mdaZ--PWSbiH9E,2873
4638
4638
  lino/utils/mldbc/mixins.py,sha256=CkYe5jDa7xp9fJq_V8zcZf8ocxgIjUgHc9KZccvA_Yw,1945
4639
- lino-25.8.0.dist-info/METADATA,sha256=XrP3oqzSF9Mk0zoFtZXTU6oJ77YRw4e-pyhhX469cGg,42534
4640
- lino-25.8.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
4641
- lino-25.8.0.dist-info/licenses/AUTHORS.rst,sha256=8VEm_G4HOmYEa4oi1nVoKKsdo4JanekEJCefWd2E8vk,981
4642
- lino-25.8.0.dist-info/licenses/COPYING,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
4643
- lino-25.8.0.dist-info/RECORD,,
4639
+ lino-25.8.2.dist-info/METADATA,sha256=D8Td-XV_04Y60n7k53f_u30cUu11MFPOyf9xoH8r0II,42534
4640
+ lino-25.8.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
4641
+ lino-25.8.2.dist-info/licenses/AUTHORS.rst,sha256=8VEm_G4HOmYEa4oi1nVoKKsdo4JanekEJCefWd2E8vk,981
4642
+ lino-25.8.2.dist-info/licenses/COPYING,sha256=DZak_2itbUtvHzD3E7GNUYSRK6jdOJ-GqncQ2weavLA,34523
4643
+ lino-25.8.2.dist-info/RECORD,,
File without changes