Skip to content

Commit 64ddd90

Browse files
committed
Merge branch 'master' of github.com:dmm-com/airone into feature/spanner
2 parents 1de90f7 + 62698a3 commit 64ddd90

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1715
-321
lines changed

.github/workflows/build-frontend.yml

+2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ jobs:
5151
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
5252
- name: build
5353
run: npm run build:development
54+
- name: build(library)
55+
run: npm run build:lib
5456
test:
5557
runs-on: ubuntu-latest
5658
permissions:
+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Release pagoda-core npm package for custom views to GitHub npm Registry
2+
3+
on:
4+
push:
5+
tags:
6+
# NOTE it should be pagoda-core-<major>.<minor>.<patch>
7+
- 'pagoda-core-*'
8+
9+
jobs:
10+
release:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
packages: write
15+
steps:
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
18+
with:
19+
node-version: 16
20+
registry-url: https://npm.pkg.github.com/
21+
scope: "@dmm-com"
22+
- name: Get tag name
23+
id: get_tag
24+
run: echo "tag=${GITHUB_REF#refs/tags/pagoda-core-}" >> $GITHUB_OUTPUT
25+
- name: Set version
26+
run: |
27+
npm version "${GITHUB_REF#refs/tags/pagoda-core-}" --no-git-tag-version
28+
- name: Install dependencies
29+
run: npm ci
30+
env:
31+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
32+
- name: Build library
33+
run: npm run build:lib
34+
- name: Publish package
35+
run: npm publish
36+
env:
37+
NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ static_root
172172
node_modules
173173
static/js/ui.js*
174174
coverage
175+
frontend/dist
175176

176177
# local django configuration
177178
airone/settings.py

CHANGELOG.md

+29-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,40 @@
33
## In development
44

55
### Added
6-
* Enable to pass general external parameters(`extendedGeneralParameters`) to React-UI
7-
implementation via Django template.
8-
Contributed by @userlocalhost, @hinashi
6+
* Introduced a new feature to identify Item using another names that are related with
7+
specific Item (it is named as Alias).
8+
Contributed by @hinashi, @userlocalhost
99

1010
### Changed
1111

1212
### Fixed
1313

14+
## v3.114.0
15+
16+
### Fixed
17+
* Fixed not being able to cancel a job from the Job menu.
18+
Contributed by @hinashi
19+
20+
## v3.113.0
21+
22+
### Fixed
23+
* Fix Elasticsearch update on entry deletion.
24+
Contributed by @tsunoda-takahiro
25+
26+
## v3.112.0
27+
28+
### Fixed
29+
* Fixed problem that might raise ElasticsearchException depends on context by
30+
SearchChain processing.
31+
Contributed by @hinashi, @userlocalhost
32+
33+
## v3.111.0
34+
35+
### Added
36+
* Enable to pass general external parameters(`extendedGeneralParameters`) to React-UI
37+
implementation via Django template.
38+
Contributed by @userlocalhost, @hinashi
39+
1440
## v3.110.0
1541

1642
### Added

airone/lib/test.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -148,13 +148,6 @@ def add_entry(self, user: User, name: str, schema: Entity, values={}, is_public=
148148

149149
return entry
150150

151-
152-
class AironeViewTest(AironeTestCase):
153-
def setUp(self):
154-
super(AironeViewTest, self).setUp()
155-
156-
self.client = Client()
157-
158151
def _do_login(self, uname, is_superuser=False) -> User:
159152
# create test user to authenticate
160153
user = User(username=uname, is_superuser=is_superuser)
@@ -171,6 +164,13 @@ def admin_login(self) -> User:
171164
def guest_login(self, uname="guest") -> User:
172165
return self._do_login(uname)
173166

167+
168+
class AironeViewTest(AironeTestCase):
169+
def setUp(self):
170+
super(AironeViewTest, self).setUp()
171+
172+
self.client = Client()
173+
174174
def open_fixture_file(self, fname):
175175
test_file_path = inspect.getfile(self.__class__)
176176
test_base_path = os.path.dirname(test_file_path)

airone/settings_common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ class Common(Configuration):
276276

277277
try:
278278
proc = subprocess.Popen(
279-
"cd %s && git describe --tags" % BASE_DIR,
279+
"cd %s && git tag --points-at | grep -v pagoda-core- | head -1" % BASE_DIR,
280280
shell=True,
281281
stdout=subprocess.PIPE,
282282
stderr=subprocess.PIPE,

api_v1/entry/serializer.py

+9-2
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,22 @@ def _do_forward_search(sub_query, sub_query_result):
302302
]
303303

304304
# get Entry informations from result
305+
# NOTE: small limit(=1000) is workaround to prevent overload
305306
try:
306307
search_result = AdvancedSearchService.search_entries(
307-
user, entity_id_list, hint_attrs, limit=99999
308+
user,
309+
entity_id_list,
310+
hint_attrs,
311+
limit=CONFIG.SEARCH_CHAIN_ACCEPTABLE_RESULT_COUNT,
308312
)
309313
except Exception as e:
310314
Logger.warning("Search Chain API error:%s" % e)
311315
raise ElasticsearchException()
312316

313-
if search_result.ret_count > CONFIG.SEARCH_CHAIN_ACCEPTABLE_RESULT_COUNT:
317+
# All results of this request would be joined and pass to next request. It might be
318+
# huge request and leads to glitch of Elasticsearch by just a single request.
319+
# This is our original curcit breaker to prevent overload because of them.
320+
if len(search_result.ret_values) > CONFIG.SEARCH_CHAIN_ACCEPTABLE_RESULT_COUNT:
314321
Logger.warning("Search Chain API error: SEARCH_CHAIN_ACCEPTABLE_RESULT_COUNT")
315322
raise ElasticsearchException()
316323

api_v1/tests/entry/test_api_search_chain.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import copy
22
import json
3-
from unittest import mock
3+
from unittest import mock, skip
44

55
from airone.lib.test import AironeViewTest
66
from airone.lib.types import AttrType
@@ -1326,6 +1326,10 @@ def test_search_backward_chain_exceeding_search_limit(self):
13261326
),
13271327
)
13281328

1329+
@skip("""
1330+
A situation that raises ElasticsearchException because of exceeding search count because of
1331+
installing workaround limitation cap won't be happened.
1332+
""")
13291333
def test_search_chain_when_result_exceeds_acceptable_count(self):
13301334
# Change configuration to test processing for acceptable result from elasticsearch
13311335
ENTRY_CONFIG.conf["SEARCH_CHAIN_ACCEPTABLE_RESULT_COUNT"] = 2

api_v1/tests/test_api.py

+18
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,23 @@ def side_effect():
338338
# checking that CREATING flag is unset after finishing this processing
339339
self.assertFalse(entry.get_status(Entry.STATUS_CREATING))
340340

341+
def test_create_entry_when_duplicated_alias_exists(self):
342+
user = self.guest_login()
343+
344+
model = self.create_entity(user, "Mountain")
345+
item = self.add_entry(user, "Everest", model)
346+
item.add_alias("Chomolungma")
347+
348+
# send request to try to create Item that has duplicated name with another Alias
349+
params = {
350+
"entity": model.name,
351+
"name": "Chomolungma",
352+
"attrs": {},
353+
}
354+
resp = self.client.post("/api/v1/entry", json.dumps(params), "application/json")
355+
self.assertEqual(resp.status_code, 400)
356+
self.assertEqual(resp.json(), {"result": "Duplicate named Alias is existed"})
357+
341358
def test_post_entry_with_invalid_params(self):
342359
admin = self.admin_login()
343360

@@ -395,6 +412,7 @@ def test_post_entry_with_invalid_params(self):
395412
# is created at the last request to create 'valid-entry'.
396413
params = {"name": "valid-entry", "entity": entity.name, "attrs": {"ref": "r-1"}}
397414
resp = self.client.post("/api/v1/entry", json.dumps(params), "application/json")
415+
print("[onix-test] resp: %s" % str(resp.content.decode("utf-8")))
398416
self.assertEqual(resp.status_code, 200)
399417

400418
entry = Entry.objects.get(schema=entity, name="valid-entry")

api_v1/views.py

+21
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,30 @@ def _update_entry_name(entry):
7777
status=status.HTTP_400_BAD_REQUEST,
7878
)
7979

80+
# Get target Item from ID
8081
entry = Entry.objects.get(id=sel.validated_data["id"])
82+
83+
# Check user has permission to update this Item
8184
if not request.user.has_permission(entry, ACLType.Writable):
8285
return Response(
8386
{"result": "Permission denied to update entry"},
8487
status=status.HTTP_400_BAD_REQUEST,
8588
)
89+
90+
# Abort updating processing when duplicated named Alias exists
91+
if not sel.validated_data["entity"].is_available(
92+
sel.validated_data["name"], [entry.id]
93+
):
94+
return Response(
95+
{"result": "Duplicate named Alias is existed"},
96+
status=status.HTTP_400_BAD_REQUEST,
97+
)
98+
8699
will_notify_update_entry = _update_entry_name(entry)
87100

88101
elif Entry.objects.filter(**entry_condition).exists():
89102
entry = Entry.objects.get(**entry_condition)
103+
90104
if not request.user.has_permission(entry, ACLType.Writable):
91105
return Response(
92106
{"result": "Permission denied to update entry"},
@@ -95,6 +109,13 @@ def _update_entry_name(entry):
95109
will_notify_update_entry = _update_entry_name(entry)
96110

97111
else:
112+
# Abort creating Item when duplicated named Alias exists
113+
if not sel.validated_data["entity"].is_available(entry_condition["name"]):
114+
return Response(
115+
{"result": "Duplicate named Alias is existed"},
116+
status=status.HTTP_400_BAD_REQUEST,
117+
)
118+
98119
# This is the processing just in case for safety not to create duplicate Entries
99120
# when multiple requests passed through existance check. Even through multiple
100121
# requests coming here, Django prevents from creating multiple Entries.

apiclient/typescript-fetch/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@dmm-com/airone-apiclient-typescript-fetch",
3-
"version": "0.1.0",
3+
"version": "0.2.1",
44
"description": "AirOne APIv2 client in TypeScript",
55
"main": "src/autogenerated/index.ts",
66
"scripts": {

dmm-com-pagoda-core-1.0.2.tgz

1.04 MB
Binary file not shown.

0 commit comments

Comments
 (0)