lino 25.3.0__py3-none-any.whl → 25.3.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 +6 -7
- lino/api/dd.py +1 -0
- lino/api/doctest.py +35 -102
- lino/api/rt.py +2 -4
- lino/core/actors.py +22 -16
- lino/core/boundaction.py +17 -7
- lino/core/dashboard.py +5 -4
- lino/core/dbtables.py +15 -16
- lino/core/fields.py +3 -3
- lino/core/inject.py +7 -6
- lino/core/kernel.py +0 -46
- lino/core/menus.py +1 -1
- lino/core/model.py +18 -16
- lino/core/plugin.py +4 -4
- lino/core/renderer.py +10 -11
- lino/core/requests.py +11 -7
- lino/core/site.py +84 -30
- lino/core/tables.py +2 -2
- lino/core/utils.py +3 -3
- lino/core/views.py +3 -3
- lino/help_texts.py +1 -0
- lino/management/commands/buildsite.py +57 -0
- lino/management/commands/initdb.py +12 -14
- lino/management/commands/prep.py +1 -1
- lino/mixins/sequenced.py +1 -1
- lino/modlib/comments/models.py +1 -1
- lino/modlib/comments/ui.py +2 -2
- lino/modlib/extjs/ext_renderer.py +2 -2
- lino/modlib/extjs/views.py +50 -48
- lino/modlib/help/config/makehelp/model.tpl.rst +1 -1
- lino/modlib/help/management/commands/makehelp.py +11 -7
- lino/modlib/jinja/mixins.py +2 -2
- lino/modlib/jinja/renderer.py +2 -2
- lino/modlib/linod/management/commands/linod.py +5 -2
- lino/modlib/linod/mixins.py +3 -0
- lino/modlib/memo/__init__.py +1 -1
- lino/modlib/printing/mixins.py +3 -0
- lino/modlib/publisher/choicelists.py +3 -3
- lino/modlib/publisher/views.py +2 -2
- lino/modlib/search/models.py +5 -5
- lino/modlib/system/choicelists.py +6 -3
- lino/modlib/tinymce/views.py +1 -1
- lino/modlib/uploads/models.py +7 -6
- lino/modlib/users/ui.py +2 -3
- lino/utils/__init__.py +4 -1
- lino/utils/diag.py +1 -1
- lino/utils/fieldutils.py +79 -0
- {lino-25.3.0.dist-info → lino-25.3.2.dist-info}/METADATA +1 -1
- {lino-25.3.0.dist-info → lino-25.3.2.dist-info}/RECORD +52 -71
- lino/sandbox/bcss/PerformInvestigation.py +0 -2260
- lino/sandbox/bcss/SSDNReply.py +0 -3924
- lino/sandbox/bcss/SSDNRequest.py +0 -3723
- lino/sandbox/bcss/__init__.py +0 -0
- lino/sandbox/bcss/readme.txt +0 -1
- lino/sandbox/bcss/test.py +0 -92
- lino/sandbox/bcss/test2.py +0 -128
- lino/sandbox/bcss/test3.py +0 -161
- lino/sandbox/bcss/test4.py +0 -167
- lino/sandbox/contacts/__init__.py +0 -0
- lino/sandbox/contacts/fixtures/__init__.py +0 -0
- lino/sandbox/contacts/fixtures/demo.py +0 -365
- lino/sandbox/contacts/manage.py +0 -10
- lino/sandbox/contacts/models.py +0 -395
- lino/sandbox/contacts/settings.py +0 -67
- lino/sandbox/tx25/XSD/RetrieveTIGroupsV3.wsdl +0 -65
- lino/sandbox/tx25/XSD/RetrieveTIGroupsV3.xsd +0 -286
- lino/sandbox/tx25/XSD/rn25_Release201104.xsd +0 -2855
- lino/sandbox/tx25/xsd2py1.py +0 -68
- lino/sandbox/tx25/xsd2py2.py +0 -62
- lino/sandbox/tx25/xsd2py3.py +0 -56
- {lino-25.3.0.dist-info → lino-25.3.2.dist-info}/WHEEL +0 -0
- {lino-25.3.0.dist-info → lino-25.3.2.dist-info}/licenses/AUTHORS.rst +0 -0
- {lino-25.3.0.dist-info → lino-25.3.2.dist-info}/licenses/COPYING +0 -0
lino/__init__.py
CHANGED
@@ -26,7 +26,12 @@ defines no models, some template files, a series of :term:`django-admin commands
|
|
26
26
|
|
27
27
|
"""
|
28
28
|
|
29
|
-
|
29
|
+
from django.utils.translation import gettext_lazy as _
|
30
|
+
from django import VERSION
|
31
|
+
from django.apps import AppConfig
|
32
|
+
from django.conf import settings
|
33
|
+
import warnings
|
34
|
+
__version__ = '25.3.2'
|
30
35
|
|
31
36
|
# import setuptools # avoid UserWarning "Distutils was imported before Setuptools"?
|
32
37
|
|
@@ -60,7 +65,6 @@ elif sys.version_info[0] == 2 and sys.version_info[1] > 6:
|
|
60
65
|
else:
|
61
66
|
PYAFTER26 = False
|
62
67
|
|
63
|
-
import warnings
|
64
68
|
|
65
69
|
warnings.filterwarnings(
|
66
70
|
"error",
|
@@ -92,8 +96,6 @@ warnings.filterwarnings(
|
|
92
96
|
# TODO: get everything to work even when ResourceWarning gives an error
|
93
97
|
# warnings.filterwarnings("error", category=ResourceWarning)
|
94
98
|
|
95
|
-
from django.conf import settings
|
96
|
-
from django.apps import AppConfig
|
97
99
|
|
98
100
|
# def setup_project(settings_module):
|
99
101
|
# os.environ['DJANGO_SETTINGS_MODULE'] = settings_module
|
@@ -110,8 +112,6 @@ def assert_django_code(django_code):
|
|
110
112
|
)
|
111
113
|
|
112
114
|
|
113
|
-
from django import VERSION
|
114
|
-
|
115
115
|
AFTER17 = True
|
116
116
|
AFTER18 = True
|
117
117
|
DJANGO2 = True
|
@@ -197,4 +197,3 @@ class AppConfig(AppConfig):
|
|
197
197
|
default_app_config = "lino.AppConfig"
|
198
198
|
|
199
199
|
# deprecated use, only for backwards compat:
|
200
|
-
from django.utils.translation import gettext_lazy as _
|
lino/api/dd.py
CHANGED
@@ -10,6 +10,7 @@ from lino.modlib.system.choicelists import Genders, PeriodEvents, YesNo
|
|
10
10
|
from lino.utils.mldbc.fields import BabelCharField, LanguageField
|
11
11
|
from lino.utils.mldbc.fields import BabelTextField
|
12
12
|
from lino.utils.format_date import fdl as dtosl
|
13
|
+
from lino.utils.fieldutils import get_fields, fields_help
|
13
14
|
from lino import logger
|
14
15
|
|
15
16
|
# import logging ; logger = logging.getLogger(__name__)
|
lino/api/doctest.py
CHANGED
@@ -14,6 +14,37 @@ tested document. It includes
|
|
14
14
|
|
15
15
|
"""
|
16
16
|
|
17
|
+
from lino.utils.fieldutils import get_fields, fields_help
|
18
|
+
from lino.core.boundaction import BoundAction
|
19
|
+
from lino.core.tables import AbstractTable
|
20
|
+
from lino.core.actions import Action
|
21
|
+
from django.db.models import Model
|
22
|
+
from lino.core.actions import ShowTable
|
23
|
+
from lino.core.menus import Menu
|
24
|
+
from lino.utils.html import html2text
|
25
|
+
from lino.core.utils import full_model_name, get_models
|
26
|
+
from lino.utils.diag import visible_for
|
27
|
+
from lino.sphinxcontrib.actordoc import menuselection_text
|
28
|
+
from lino import logger
|
29
|
+
from lino.core.menus import find_menu_item
|
30
|
+
from lino.core import constants
|
31
|
+
from lino.core import actors, kernel
|
32
|
+
from lino.utils.sql import sql_summary
|
33
|
+
from lino.utils import diag
|
34
|
+
from lino.utils.diag import analyzer
|
35
|
+
from lino.utils.html import E, tostring, to_rst
|
36
|
+
from lino.utils import i2d
|
37
|
+
from lino.utils import AttrDict
|
38
|
+
from rstgen.utils import unindent, rmu, sixprint
|
39
|
+
from rstgen import attrtable
|
40
|
+
import rstgen
|
41
|
+
import pytest
|
42
|
+
from django.db import connection, reset_queries as reset_sql_queries
|
43
|
+
from django.test import Client
|
44
|
+
from django.utils.encoding import force_str
|
45
|
+
from django.utils import translation
|
46
|
+
from lino.api.shell import *
|
47
|
+
from lino.core.constants import *
|
17
48
|
import os
|
18
49
|
import sys
|
19
50
|
import datetime
|
@@ -31,39 +62,11 @@ from urllib.parse import urlencode
|
|
31
62
|
import django
|
32
63
|
django.setup()
|
33
64
|
|
34
|
-
from lino.core.constants import *
|
35
|
-
from lino.api.shell import *
|
36
|
-
from django.utils import translation
|
37
|
-
from django.utils.encoding import force_str
|
38
|
-
from django.test import Client
|
39
|
-
from django.db import connection, reset_queries as reset_sql_queries
|
40
65
|
|
41
|
-
import pytest
|
42
66
|
# from rstgen import table, ul
|
43
|
-
import rstgen
|
44
|
-
from rstgen import attrtable
|
45
|
-
from rstgen.utils import unindent, rmu, sixprint
|
46
67
|
|
47
|
-
from lino.utils import AttrDict
|
48
|
-
from lino.utils import i2d
|
49
|
-
from lino.utils.html import E, tostring, to_rst
|
50
|
-
from lino.utils.diag import analyzer
|
51
|
-
from lino.utils import diag
|
52
|
-
from lino.utils.sql import sql_summary
|
53
|
-
from lino.core import actors, kernel
|
54
|
-
from lino.core import constants
|
55
|
-
from lino.core.menus import find_menu_item
|
56
|
-
from lino import logger
|
57
|
-
from lino.sphinxcontrib.actordoc import menuselection_text
|
58
|
-
from lino.utils.diag import visible_for
|
59
|
-
from lino.core.utils import full_model_name, get_models
|
60
68
|
|
61
69
|
# from lino.core.utils import PseudoRequest
|
62
|
-
from lino.utils.html import html2text
|
63
|
-
from lino.core.menus import Menu
|
64
|
-
from lino.core.actions import ShowTable
|
65
|
-
from lino.core.actions import register_params
|
66
|
-
from lino.core.layouts import BaseLayout
|
67
70
|
|
68
71
|
test_client = Client()
|
69
72
|
"""An instance of :class:`django.test.Client`.
|
@@ -88,7 +91,8 @@ def get_json_dict(username, uri, an="detail", **kwargs):
|
|
88
91
|
# url += "&{}={}".format(k, v)
|
89
92
|
test_client.force_login(rt.login(username).user)
|
90
93
|
res = test_client.get(url, REMOTE_USER=username)
|
91
|
-
|
94
|
+
if res.status_code != 200:
|
95
|
+
raise Exception(f"GET {url} got status code {res.status_code}")
|
92
96
|
s = res.content.decode()
|
93
97
|
try:
|
94
98
|
return json.loads(s)
|
@@ -275,12 +279,6 @@ def show_choices(username, url, show_count=False):
|
|
275
279
|
print("{} rows".format(result["count"]))
|
276
280
|
|
277
281
|
|
278
|
-
from django.db.models import Model
|
279
|
-
from lino.core.actions import Action
|
280
|
-
from lino.core.tables import AbstractTable
|
281
|
-
from lino.core.boundaction import BoundAction
|
282
|
-
|
283
|
-
|
284
282
|
def show_workflow(actions, all=False, language=None):
|
285
283
|
"""
|
286
284
|
Show the given actions as a table. Usage example in
|
@@ -320,71 +318,6 @@ def show_workflow(actions, all=False, language=None):
|
|
320
318
|
return doit()
|
321
319
|
|
322
320
|
|
323
|
-
def get_fields(model, fieldnames=None, columns=None):
|
324
|
-
if isinstance(model, BoundAction):
|
325
|
-
get_field = model.action.parameters.get
|
326
|
-
if fieldnames is None:
|
327
|
-
fieldnames = model.action.params_layout
|
328
|
-
elif isinstance(model, Action):
|
329
|
-
get_field = model.parameters.get
|
330
|
-
if fieldnames is None:
|
331
|
-
fieldnames = model.params_layout.main
|
332
|
-
elif issubclass(model, Model):
|
333
|
-
get_field = model._meta.get_field
|
334
|
-
# get_field = model.get_data_elem
|
335
|
-
if fieldnames is None:
|
336
|
-
fieldnames = [f.name for f in model._meta.get_fields()]
|
337
|
-
elif issubclass(model, AbstractTable):
|
338
|
-
if columns:
|
339
|
-
get_field = model.get_data_elem
|
340
|
-
if fieldnames is None:
|
341
|
-
fieldnames = model.column_names
|
342
|
-
# get_handle().grid_layout.main.columns
|
343
|
-
else:
|
344
|
-
get_field = model.parameters.get
|
345
|
-
if fieldnames is None:
|
346
|
-
if not isinstance(model.params_layout, BaseLayout):
|
347
|
-
register_params(model)
|
348
|
-
fieldnames = model.params_layout.main
|
349
|
-
if fieldnames is None:
|
350
|
-
return
|
351
|
-
if isinstance(fieldnames, str):
|
352
|
-
fieldnames = fieldnames.split()
|
353
|
-
for n in fieldnames:
|
354
|
-
yield get_field(n)
|
355
|
-
|
356
|
-
|
357
|
-
def fields_help(model, fieldnames=None, columns=False, all=None):
|
358
|
-
"""
|
359
|
-
Print an overview description of the specified fields of the
|
360
|
-
specified model.
|
361
|
-
|
362
|
-
If model is an action or table, print the parameter fields of that
|
363
|
-
action or table.
|
364
|
-
|
365
|
-
If model is a table and you want the columns instead of the
|
366
|
-
parameter fields, then specify `columns=True`.
|
367
|
-
|
368
|
-
By default this shows only fields that have a help text. If you
|
369
|
-
specify `all=True`, then also fields that have no help text will
|
370
|
-
be shown.
|
371
|
-
"""
|
372
|
-
if all is None:
|
373
|
-
all = fieldnames is not None
|
374
|
-
|
375
|
-
cells = []
|
376
|
-
# cols = ["Internal name", "Verbose name", "Help text"]
|
377
|
-
for fld in get_fields(model, fieldnames, columns):
|
378
|
-
if fld is not None and hasattr(fld, "verbose_name"):
|
379
|
-
ht = fld.help_text or ""
|
380
|
-
if ht or all:
|
381
|
-
cells.append([fld.name, fld.verbose_name, unindent(ht)])
|
382
|
-
|
383
|
-
# return table(cols, cells).strip()
|
384
|
-
items = ["{} ({}) : {}".format(row[1], row[0], row[2]) for row in cells]
|
385
|
-
return rstgen.ul(items).strip()
|
386
|
-
|
387
|
-
|
388
321
|
def show_fields(*args, **kwargs):
|
389
322
|
print(fields_help(*args, **kwargs))
|
390
323
|
|
@@ -768,7 +701,6 @@ def walk_store_fields(only_detail_fields=False):
|
|
768
701
|
yield a, sf
|
769
702
|
|
770
703
|
|
771
|
-
# settings.SITE.kernel.check_virgin()
|
772
704
|
def set_log_level(level):
|
773
705
|
logger.setLevel(level)
|
774
706
|
for handler in logger.handlers:
|
@@ -800,6 +732,7 @@ def show_change_watchers():
|
|
800
732
|
)
|
801
733
|
print(rstgen.table(headers, rows, max_width=40))
|
802
734
|
|
735
|
+
|
803
736
|
def show_display_modes():
|
804
737
|
"""
|
805
738
|
Show the availble display modes per actor.
|
@@ -813,7 +746,7 @@ def show_display_modes():
|
|
813
746
|
rows.append(
|
814
747
|
[str(a)] + [
|
815
748
|
("x" if dm in a.extra_display_modes else "")
|
816
|
-
|
749
|
+
for dm in dml]
|
817
750
|
)
|
818
751
|
print(rstgen.table(headers, rows))
|
819
752
|
|
lino/api/rt.py
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
# Copyright 2014-2018 Rumma & Ko Ltd
|
2
2
|
# License: GNU Affero General Public License v3 (see file COPYING for details)
|
3
3
|
|
4
|
+
from lino.core.utils import login, show, shows
|
5
|
+
from lino.core.exceptions import ChangedAPI
|
4
6
|
from django.conf import settings
|
5
7
|
|
6
8
|
from lino.core.utils import models_by_base
|
@@ -9,7 +11,6 @@ models = settings.SITE.models
|
|
9
11
|
"""
|
10
12
|
"""
|
11
13
|
|
12
|
-
from lino.core.exceptions import ChangedAPI
|
13
14
|
# actors = modules = ChangedAPI(
|
14
15
|
# "Replace rt.modules and rt.actors by rt.models")
|
15
16
|
|
@@ -32,9 +33,6 @@ def get_template(*args, **kw):
|
|
32
33
|
return settings.SITE.plugins.jinja.renderer.jinja_env.get_template(*args, **kw)
|
33
34
|
|
34
35
|
|
35
|
-
from lino.core.utils import login, show, shows
|
36
|
-
|
37
|
-
|
38
36
|
# def send_email(*args, **kw):
|
39
37
|
# "Shortcut to :meth:`lino.core.site.Site.send_email`."
|
40
38
|
# return settings.SITE.send_email(*args, **kw)
|
lino/core/actors.py
CHANGED
@@ -8,11 +8,8 @@ See :doc:`/dev/actors`.
|
|
8
8
|
|
9
9
|
"""
|
10
10
|
|
11
|
-
from lino import logger
|
12
|
-
|
13
11
|
import copy
|
14
|
-
import
|
15
|
-
import html
|
12
|
+
import warnings
|
16
13
|
from types import GeneratorType
|
17
14
|
from inspect import getmro
|
18
15
|
|
@@ -22,6 +19,7 @@ from django.utils.translation import gettext_lazy as _
|
|
22
19
|
from django.utils.html import format_html, mark_safe, SafeString
|
23
20
|
from django.core.exceptions import BadRequest
|
24
21
|
|
22
|
+
from lino import logger
|
25
23
|
from lino.utils import isiterable
|
26
24
|
from lino.utils import MissingRow
|
27
25
|
from lino.core import fields
|
@@ -38,8 +36,7 @@ from lino.core.utils import qs2summary
|
|
38
36
|
from lino.core.utils import ParameterPanel
|
39
37
|
from lino.core.utils import navinfo, dbfield2params_field
|
40
38
|
from lino.utils import curry, AttrDict, is_string
|
41
|
-
|
42
|
-
from lino.utils.html import E, forcetext, tostring, Grouper, SAFE_EMPTY
|
39
|
+
from lino.utils.html import E, tostring, Grouper, SAFE_EMPTY
|
43
40
|
# from lino.utils.html import assert_safe
|
44
41
|
|
45
42
|
from .roles import SiteUser
|
@@ -656,7 +653,6 @@ class Actor(actions.Parametrizable, Permittable, metaclass=ActorMetaClass):
|
|
656
653
|
try:
|
657
654
|
settings.SITE.kernel.setup_handle(h, ar)
|
658
655
|
except Exception as e:
|
659
|
-
# traceback.print_exc()
|
660
656
|
logger.warning(
|
661
657
|
"%s setup_handle failed with %s (change actors.py to see more)",
|
662
658
|
self,
|
@@ -1841,7 +1837,17 @@ class Actor(actions.Parametrizable, Permittable, metaclass=ActorMetaClass):
|
|
1841
1837
|
return kw
|
1842
1838
|
|
1843
1839
|
@classmethod
|
1844
|
-
def request(cls,
|
1840
|
+
def request(cls, *args, **kwargs):
|
1841
|
+
"""
|
1842
|
+
Old name for :meth:`create_request`. Still does the same but with a
|
1843
|
+
deprecation warning.
|
1844
|
+
"""
|
1845
|
+
warnings.warn(
|
1846
|
+
"Please call create_request() instead of request()", DeprecationWarning)
|
1847
|
+
return cls.create_request(*args, **kwargs)
|
1848
|
+
|
1849
|
+
@classmethod
|
1850
|
+
def create_request(cls, master_instance=None, **kwargs):
|
1845
1851
|
"""Return a new :class:`ActionRequest
|
1846
1852
|
<lino.core.requests.ActionRequest>` on this actor.
|
1847
1853
|
|
@@ -1867,7 +1873,7 @@ class Actor(actions.Parametrizable, Permittable, metaclass=ActorMetaClass):
|
|
1867
1873
|
|
1868
1874
|
@classmethod
|
1869
1875
|
def to_html(self, **kw):
|
1870
|
-
return tostring(self.
|
1876
|
+
return tostring(self.create_request(**kw).table2xhtml())
|
1871
1877
|
|
1872
1878
|
@classmethod
|
1873
1879
|
def get_screenshot_requests(self, language):
|
@@ -1896,7 +1902,7 @@ class Actor(actions.Parametrizable, Permittable, metaclass=ActorMetaClass):
|
|
1896
1902
|
kwargs.update(parent=ar)
|
1897
1903
|
kwargs.update(renderer=settings.SITE.kernel.default_renderer)
|
1898
1904
|
try:
|
1899
|
-
ar = cls.
|
1905
|
+
ar = cls.create_request(master_instance=master, **kwargs)
|
1900
1906
|
el = cls.table_as_html(ar)
|
1901
1907
|
except Exception as e:
|
1902
1908
|
msg = f"20241004 Error in {repr(ar)}: {e}"
|
@@ -1911,8 +1917,8 @@ class Actor(actions.Parametrizable, Permittable, metaclass=ActorMetaClass):
|
|
1911
1917
|
@classmethod
|
1912
1918
|
def get_table_as_list(cls, obj, ar):
|
1913
1919
|
# raise Exception("20240316")
|
1914
|
-
sar = cls.
|
1915
|
-
|
1920
|
+
sar = cls.create_request(parent=ar, master_instance=obj,
|
1921
|
+
is_on_main_actor=False)
|
1916
1922
|
grp = Grouper(sar)
|
1917
1923
|
html_text = grp.begin()
|
1918
1924
|
for i, obj in enumerate(sar.data_iterator):
|
@@ -1946,8 +1952,8 @@ class Actor(actions.Parametrizable, Permittable, metaclass=ActorMetaClass):
|
|
1946
1952
|
|
1947
1953
|
@classmethod
|
1948
1954
|
def get_table_story(cls, obj, ar):
|
1949
|
-
sar = cls.
|
1950
|
-
|
1955
|
+
sar = cls.create_request(parent=ar, master_instance=obj,
|
1956
|
+
is_on_main_actor=False)
|
1951
1957
|
html = SAFE_EMPTY
|
1952
1958
|
for i, obj in enumerate(sar.data_iterator):
|
1953
1959
|
if i == cls.preview_limit:
|
@@ -1973,8 +1979,8 @@ class Actor(actions.Parametrizable, Permittable, metaclass=ActorMetaClass):
|
|
1973
1979
|
"""
|
1974
1980
|
if ar is None:
|
1975
1981
|
return ''
|
1976
|
-
sar = cls.
|
1977
|
-
|
1982
|
+
sar = cls.create_request(parent=ar, master_instance=obj,
|
1983
|
+
is_on_main_actor=False)
|
1978
1984
|
return cls.get_table_summary(sar)
|
1979
1985
|
|
1980
1986
|
@classmethod
|
lino/core/boundaction.py
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
# -*- coding: UTF-8 -*-
|
2
|
-
# Copyright 2009-
|
2
|
+
# Copyright 2009-2025 Rumma & Ko Ltd
|
3
3
|
# License: GNU Affero General Public License v3 (see file COPYING for details)
|
4
4
|
"""
|
5
5
|
.. autosummary::
|
6
6
|
|
7
7
|
"""
|
8
8
|
|
9
|
-
from lino import logger
|
10
9
|
import os
|
10
|
+
import warnings
|
11
11
|
|
12
12
|
from django.conf import settings
|
13
13
|
|
14
|
+
from lino import logger
|
14
15
|
from lino.utils import curry
|
15
16
|
# from .actions import Action
|
16
17
|
|
@@ -21,7 +22,7 @@ from lino.core.permissions import (
|
|
21
22
|
|
22
23
|
|
23
24
|
class BoundAction(object):
|
24
|
-
"""An
|
25
|
+
"""An action that is bound to an actor. If an actor has subclasses,
|
25
26
|
each subclass "inherits" its actions.
|
26
27
|
|
27
28
|
"""
|
@@ -94,15 +95,24 @@ class BoundAction(object):
|
|
94
95
|
def full_name(self):
|
95
96
|
return self.action.full_name(self.actor)
|
96
97
|
|
97
|
-
def
|
98
|
-
# print("20170116 BoundAction.
|
98
|
+
def create_request(self, *args, **kw):
|
99
|
+
# print("20170116 BoundAction.create_request()", args, kw)
|
99
100
|
kw.update(action=self)
|
100
|
-
return self.actor.
|
101
|
+
return self.actor.create_request(*args, **kw)
|
102
|
+
|
103
|
+
def request(self, *args, **kwargs):
|
104
|
+
"""
|
105
|
+
Old name for :meth:`create_request`. Still does the same but with a
|
106
|
+
deprecation warning.
|
107
|
+
"""
|
108
|
+
warnings.warn(
|
109
|
+
"Please call create_request() instead of request()", DeprecationWarning)
|
110
|
+
return self.create_request(*args, **kwargs)
|
101
111
|
|
102
112
|
def request_from(self, ar, *args, **kw):
|
103
113
|
"""Create a request of this action from parent request `ar`."""
|
104
114
|
kw.update(parent=ar)
|
105
|
-
return self.
|
115
|
+
return self.create_request(*args, **kw)
|
106
116
|
|
107
117
|
def run_from_session(self, ses, **kw):
|
108
118
|
ar = self.request_from(ses, **kw)
|
lino/core/dashboard.py
CHANGED
@@ -5,8 +5,8 @@
|
|
5
5
|
|
6
6
|
"""
|
7
7
|
|
8
|
-
from django.conf import settings
|
9
|
-
from lino.api import _
|
8
|
+
# from django.conf import settings
|
9
|
+
# from lino.api import _
|
10
10
|
from lino.core.permissions import Permittable
|
11
11
|
from lino.core.requests import ActionRequest
|
12
12
|
from lino.core.tables import AbstractTable
|
@@ -78,7 +78,7 @@ class DashboardItem(Permittable):
|
|
78
78
|
# TODO 20220930 until now, dashboard was always acting as if
|
79
79
|
# display_mode was DISPLAY_MODE_GRID
|
80
80
|
if issubclass(sar.actor, AbstractTable):
|
81
|
-
|
81
|
+
# if isinstance(sar.bound_action.action, ShowTable):
|
82
82
|
for e in sar.renderer.table2story(sar, **kwargs):
|
83
83
|
# assert_safe(tostring(e))
|
84
84
|
yield tostring(e)
|
@@ -149,7 +149,8 @@ class ActorItem(DashboardItem):
|
|
149
149
|
# from lino.core.tables import AbstractTable
|
150
150
|
T = self.actor
|
151
151
|
# if isinstance(T, AbstractTable):
|
152
|
-
|
152
|
+
# , renderer=settings.SITE.kernel.default_renderer)
|
153
|
+
sar = T.create_request(limit=T.preview_limit, parent=ar)
|
153
154
|
# sar = ar.spawn(T, limit=T.preview_limit)
|
154
155
|
# sar = ar.spawn_request(actor=T, limit=T.preview_limit)
|
155
156
|
# raise Exception("20230331 {}".format(ar.subst_user))
|
lino/core/dbtables.py
CHANGED
@@ -4,6 +4,17 @@
|
|
4
4
|
This defines the :class:`Table` class.
|
5
5
|
"""
|
6
6
|
|
7
|
+
from lino.core.gfks import ContentType, GenericForeignKey
|
8
|
+
from lino.core.tables import AbstractTable
|
9
|
+
from lino.core.utils import resolve_model, get_field, UnresolvedModel
|
10
|
+
from .utils import models_by_base
|
11
|
+
from lino.core.choicelists import ChoiceListField
|
12
|
+
from lino.core import constants
|
13
|
+
from lino.core import actors
|
14
|
+
from lino.core.model import Model
|
15
|
+
from lino.core import actions
|
16
|
+
from lino.core import fields
|
17
|
+
from lino.utils.html import tostring, assert_safe
|
7
18
|
from lino import logger
|
8
19
|
|
9
20
|
import datetime
|
@@ -21,21 +32,9 @@ from django.apps import apps
|
|
21
32
|
|
22
33
|
get_models = apps.get_models
|
23
34
|
|
24
|
-
from lino.utils.html import tostring, assert_safe
|
25
35
|
|
26
|
-
from lino.core import fields
|
27
|
-
from lino.core import actions
|
28
|
-
from lino.core.model import Model
|
29
|
-
from lino.core import actors
|
30
|
-
from lino.core import constants
|
31
|
-
|
32
|
-
from lino.core.choicelists import ChoiceListField
|
33
|
-
from .utils import models_by_base
|
34
36
|
# from .fields import get_data_elem_from_model
|
35
37
|
|
36
|
-
from lino.core.utils import resolve_model, get_field, UnresolvedModel
|
37
|
-
from lino.core.tables import AbstractTable
|
38
|
-
from lino.core.gfks import ContentType, GenericForeignKey
|
39
38
|
|
40
39
|
INVALID_MK = "Invalid master_key '{0}' in {1} : {2}"
|
41
40
|
|
@@ -260,10 +259,10 @@ class Table(AbstractTable):
|
|
260
259
|
profiles2user[u.user_type] = u
|
261
260
|
for user in list(profiles2user.values()):
|
262
261
|
# if user.profile.name != 'admin': return
|
263
|
-
# yield self.default_action.
|
262
|
+
# yield self.default_action.create_request(user=user)
|
264
263
|
# and self.default_action is not self.detail_action:
|
265
264
|
if self.detail_action:
|
266
|
-
yield self.detail_action.
|
265
|
+
yield self.detail_action.create_request(user=user)
|
267
266
|
|
268
267
|
# @classmethod
|
269
268
|
# def elem_get_printable_target_stem(cls,elem):
|
@@ -589,7 +588,7 @@ class Table(AbstractTable):
|
|
589
588
|
if self.delete_action is None:
|
590
589
|
return "No delete_action"
|
591
590
|
if not self.get_row_permission(
|
592
|
-
|
591
|
+
obj, ar, self.get_row_state(obj), self.delete_action):
|
593
592
|
# print "20130222 ar is %r" % ar
|
594
593
|
# logger.info("20130225 dbtables.disable_delete no permission")
|
595
594
|
return _("You have no permission to delete this row.")
|
@@ -601,7 +600,7 @@ class Table(AbstractTable):
|
|
601
600
|
|
602
601
|
# raise Exception("20240321 get_request_queryset", self)
|
603
602
|
# if not isinstance(ar, TableRequest):
|
604
|
-
# ar = self.
|
603
|
+
# ar = self.create_request(parent=ar)
|
605
604
|
|
606
605
|
def apply(qs):
|
607
606
|
# print("20160329 {}".format(qs.query))
|
lino/core/fields.py
CHANGED
@@ -1663,7 +1663,7 @@ def make_remote_field(model, name):
|
|
1663
1663
|
# fld.related_model, rkw))
|
1664
1664
|
reltarget = fld.related_model(**rkw)
|
1665
1665
|
reltarget.save_new_instance(
|
1666
|
-
fld.related_model.get_default_table().
|
1666
|
+
fld.related_model.get_default_table().create_request()
|
1667
1667
|
)
|
1668
1668
|
|
1669
1669
|
setattr(target, fld.name, reltarget)
|
@@ -1774,8 +1774,8 @@ def choices_for_field(ar, holder, field):
|
|
1774
1774
|
if isinstance(field, models.ForeignKey):
|
1775
1775
|
m = field.remote_field.model
|
1776
1776
|
t = m.get_default_table()
|
1777
|
-
# qs = t.
|
1778
|
-
qs = t.
|
1777
|
+
# qs = t.create_request(request=ar.request).data_iterator
|
1778
|
+
qs = t.create_request(parent=ar).data_iterator
|
1779
1779
|
|
1780
1780
|
# logger.info('20120710 choices_view(FK) %s --> %s', t, qs.query)
|
1781
1781
|
|
lino/core/inject.py
CHANGED
@@ -132,9 +132,9 @@ def check_pending_injects(sender, models_list=None, **kw):
|
|
132
132
|
# ~ logger.info("20131110 no pending injects")
|
133
133
|
"""
|
134
134
|
20130106
|
135
|
-
now we loop a last time over each model and fill
|
136
|
-
otherwise if some
|
137
|
-
has subclasses,
|
135
|
+
now we loop a last time over each model and fill its _meta._field_cache
|
136
|
+
otherwise if some plugin used inject_field() on a model that
|
137
|
+
has subclasses, the new field would not be seen by subclasses
|
138
138
|
"""
|
139
139
|
for model in models_list:
|
140
140
|
model._meta._expire_cache()
|
@@ -225,7 +225,8 @@ def update_model(model_spec, **actions):
|
|
225
225
|
def todo(model):
|
226
226
|
for k, v in actions.items():
|
227
227
|
if not hasattr(model, k):
|
228
|
-
raise Exception(
|
228
|
+
raise Exception(
|
229
|
+
"%s has no attribute %s to update." % (model, k))
|
229
230
|
setattr(model, k, v)
|
230
231
|
|
231
232
|
if isinstance(model_spec, models.Model):
|
@@ -389,8 +390,8 @@ def inject_quick_add_buttons(model, name, target):
|
|
389
390
|
inject_field(
|
390
391
|
model,
|
391
392
|
name,
|
392
|
-
fields.VirtualField(fields.DisplayField(
|
393
|
-
|
393
|
+
fields.VirtualField(fields.DisplayField(
|
394
|
+
tm._meta.verbose_name_plural), fn))
|
394
395
|
|
395
396
|
|
396
397
|
# def django_patch():
|
lino/core/kernel.py
CHANGED
@@ -26,7 +26,6 @@ import atexit
|
|
26
26
|
import signal
|
27
27
|
import threading
|
28
28
|
from importlib import import_module
|
29
|
-
import json
|
30
29
|
|
31
30
|
# from django.apps import AppConfig
|
32
31
|
from django.apps import apps
|
@@ -953,51 +952,6 @@ class Kernel(object):
|
|
953
952
|
# def setup_static_link(self, urlpatterns, short_name,
|
954
953
|
# attr_name=None, source=None):
|
955
954
|
|
956
|
-
def mark_virgin(self):
|
957
|
-
dbhash = self.get_dbhash()
|
958
|
-
fn = self.site.site_dir / "dbhash.json"
|
959
|
-
with fn.open("w") as fp:
|
960
|
-
json.dump(dbhash, fp)
|
961
|
-
|
962
|
-
def check_virgin(self):
|
963
|
-
new = self.get_dbhash()
|
964
|
-
fn = self.site.site_dir / "dbhash.json"
|
965
|
-
if not fn.exists():
|
966
|
-
raise Exception(
|
967
|
-
"No `dbhash.json` in {} " "(did you run `django-admin prep`?)".format(
|
968
|
-
self.site.site_dir
|
969
|
-
)
|
970
|
-
)
|
971
|
-
with fn.open("r") as fp:
|
972
|
-
old = json.load(fp)
|
973
|
-
|
974
|
-
# noi1r has noi1e as master_site, but the react front end removes the
|
975
|
-
# tinymce plugin, i.e. noi1r doesn't care about
|
976
|
-
# tinymce.TextFieldTemplate model.
|
977
|
-
|
978
|
-
diffs = {}
|
979
|
-
for k, v in new.items():
|
980
|
-
oldv = old.get(k, None)
|
981
|
-
if oldv != v:
|
982
|
-
diffs[k] = (oldv, v)
|
983
|
-
# diff = set(old.items()) ^ set(new.items())
|
984
|
-
if diffs:
|
985
|
-
# db = self.site.django_settings.get('SETTINGS_MODULE')
|
986
|
-
db = self.site.site_dir
|
987
|
-
raise Exception("Database {} isn't virgin: {}".format(db, diffs))
|
988
|
-
|
989
|
-
# logger.info("Database certified as virgin")
|
990
|
-
|
991
|
-
def get_dbhash(self):
|
992
|
-
# TODO: we currently check only the number of rows per model. That's
|
993
|
-
# very naive.
|
994
|
-
rv = dict()
|
995
|
-
for m in get_models(include_auto_created=True):
|
996
|
-
k = fmn(m)
|
997
|
-
if k != "sessions.Session":
|
998
|
-
rv[k] = m.objects.count()
|
999
|
-
return rv
|
1000
|
-
|
1001
955
|
|
1002
956
|
def site_startup(self):
|
1003
957
|
"""This is being imported and called from
|
lino/core/menus.py
CHANGED
@@ -160,7 +160,7 @@ class MenuItem(object):
|
|
160
160
|
# return False
|
161
161
|
|
162
162
|
def openui5Render(self):
|
163
|
-
ar = self.bound_action.
|
163
|
+
ar = self.bound_action.create_request(**self.params)
|
164
164
|
js = settings.SITE.kernel.default_renderer.request_handler(ar)
|
165
165
|
return js
|
166
166
|
|