Skip to content

Commit

Permalink
Compatibility with core#2567 (AnalysisCategory to DX)
Browse files Browse the repository at this point in the history
  • Loading branch information
xispa committed Jun 15, 2024
1 parent ccf6f7e commit 7886a7e
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 103 deletions.
98 changes: 1 addition & 97 deletions buildout.cfg
Original file line number Diff line number Diff line change
@@ -1,99 +1,3 @@
[buildout]
index = https://pypi.org/simple/
extends = https://dist.plone.org/release/5.2-latest/versions.cfg
find-links =
https://dist.plone.org/release/5.2-latest/
https://dist.plone.org/thirdparty/

parts =
instance
test
omelette
i18ndude
zopepy
update_sources
write_code_headers

eggs =
senaite.core
senaite.app.listing
senaite.app.spotlight
senaite.app.supermodel
senaite.impress
senaite.jsonapi
senaite.lims
plone.reload

extensions = mr.developer

extends = https://raw.githubusercontent.com/senaite/senaite.core/2.x/buildout.base.cfg
package-name = senaite.jsonapi

versions = versions
show-picked-versions = true

plone-user = admin:admin

develop = .
sources = sources
auto-checkout = *

[sources]
senaite.core = git https://github.com/senaite/senaite.core.git pushurl=git@github.com:senaite/senaite.core.git branch=2.x
senaite.app.listing = git https://github.com/senaite/senaite.app.listing.git pushurl=git@github.com:senaite/senaite.app.listing.git branch=2.x
senaite.app.supermodel = git https://github.com/senaite/senaite.app.supermodel.git pushurl=git@github.com:senaite/senaite.app.supermodel.git branch=2.x
senaite.app.spotlight = git https://github.com/senaite/senaite.app.spotlight.git pushurl=git@github.com:senaite/senaite.app.spotlight.git branch=2.x
senaite.impress = git https://github.com/senaite/senaite.impress.git pushurl=git@github.com:senaite/senaite.impress.git branch=2.x
senaite.lims = git https://github.com/senaite/senaite.lims.git pushurl=git@github.com:senaite/senaite.lims.git branch=2.x

[instance]
recipe = plone.recipe.zope2instance
http-address = 127.0.0.1:8080
user = ${buildout:plone-user}
wsgi = on
eggs =
Plone
${buildout:package-name}
${buildout:eggs}
deprecation-warnings = on
environment-vars =
zope_i18n_compile_mo_files true
zcml =

[i18ndude]
unzip = true
recipe = zc.recipe.egg
eggs = i18ndude

[write_code_headers]
recipe = collective.recipe.template
output = ${buildout:directory}/bin/write_code_headers
input = ${buildout:directory}/templates/write_code_headers.py.in
mode = 755

[update_sources]
recipe = collective.recipe.template
output = ${buildout:directory}/bin/update_sources
input = ${buildout:directory}/templates/update_sources.in
mode = 755

[test]
recipe = zc.recipe.testrunner
defaults = ['--auto-color', '--auto-progress']
eggs =
senaite.jsonapi [test]

[omelette]
recipe = collective.recipe.omelette
eggs = ${buildout:eggs}

[zopepy]
recipe = zc.recipe.egg
eggs = ${instance:eggs}
interpreter = zopepy
scripts = zopepy

[versions]
# versions need to match the versions in requirements.txt
# https://github.com/collective/buildout.plonetest/#testing-in-travis-ci-with-multiple-versions-of-plone-and-python
setuptools = 44.1.1
zc.buildout = 2.13.3
3 changes: 2 additions & 1 deletion docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ Changelog
2.6.0 (unreleased)
------------------

- #61 Compatibility with senaite.core#2471
- #61 Compatibility with senaite.core#2567 (AnalysisCategory to DX)
- #61 Compatibility with senaite.core#2471 (Department to DX)


2.5.0 (2024-01-03)
Expand Down
9 changes: 9 additions & 0 deletions src/senaite/jsonapi/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ def update_items(portal_type=None, uid=None, endpoint=None, **kw):
# no uid -> go through the record items
results = []
for record in records:
title = record.get("title") or ""
obj = get_object_by_record(record)

# no object found for this record
Expand Down Expand Up @@ -1087,6 +1088,10 @@ def is_creation_allowed(portal_type, container):
if container == api.get_setup():
return False

# Do not allow the update of objects that belong to senaite_setup folder
if container == api.get_senaite_setup():
return False

# Check if the portal_type is allowed in the container
container_info = container.getTypeInfo()
if container_info.filter_content_types:
Expand Down Expand Up @@ -1122,6 +1127,10 @@ def is_update_allowed(obj):
if parent == api.get_setup():
return False

# Do not allow the update of objects that belong to senaite_setup folder
if parent == api.get_senaite_setup():
return False

# Look for an update-specific adapter for this object
adapter = queryAdapter(obj, IUpdate)
if adapter:
Expand Down
8 changes: 4 additions & 4 deletions src/senaite/jsonapi/tests/doctests/create.rst
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,14 @@ Create an Analysis Category
~~~~~~~~~~~~~~~~~~~~~~~~~~~

>>> data = {"portal_type": "AnalysisCategory",
... "parent_path": api.get_path(setup.bika_analysiscategories),
... "parent_path": api.get_path(portal.setup.analysiscategories),
... "title": "Microbiology identification",
... "Department": api.get_uid(department)}
>>> category = create(data)
>>> category.Title()
'Microbiology identification'
>>> api.get_parent(category)
<AnalysisCategories at /plone/bika_setup/bika_analysiscategories>
<AnalysisCategories at /plone/setup/analysiscategories>
>>> category.getDepartment()
<Department at /plone/setup/departments/department-1>

Expand All @@ -257,7 +257,7 @@ Create an Analysis Service
>>> sal.getAccredited()
True
>>> sal.getCategory()
<AnalysisCategory at /plone/bika_setup/bika_analysiscategories/analysiscategory-1>
<AnalysisCategory at /plone/setup/analysiscategories/analysiscategory-1>

>>> data = {"portal_type": "AnalysisService",
... "parent_path": api.get_path(setup.bika_analysisservices),
Expand All @@ -276,7 +276,7 @@ Create an Analysis Service
>>> ecoli.getPrice()
'15.00'
>>> ecoli.getCategory()
<AnalysisCategory at /plone/bika_setup/bika_analysiscategories/analysiscategory-1>
<AnalysisCategory at /plone/setup/analysiscategories/analysiscategory-1>

Creating a Sample
~~~~~~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion src/senaite/jsonapi/tests/doctests/update.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ We get a 401 error if we try to update an object from inside portal root:

We get a 401 error if we try to update an object from inside setup folder:

>>> cats_uid = api.get_uid(api.get_setup().bika_analysiscategories)
>>> cats_uid = api.get_uid(portal.setup.analysiscategories)
>>> data = {"title": "My Analysis Categories folder",
... "uid": cats_uid,}
>>> post("update", data)
Expand Down

0 comments on commit 7886a7e

Please sign in to comment.