Skip to content

Commit

Permalink
Merge branch 'develop' into uat
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkLark86 committed Aug 21, 2024
2 parents a0a0e5a + 7fca110 commit fb0f19d
Show file tree
Hide file tree
Showing 9 changed files with 478 additions and 349 deletions.
2 changes: 1 addition & 1 deletion client/extensions/tga-sign-off/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function getListAuthorIds(item: IArticle): Array<IUser['_id']> {
const {notNullOrUndefined} = superdesk.helpers;

return (item.authors ?? [])
.filter(author => author.role === 'editor')
.filter(author => author.role !== 'editor')
.map((author) => author.parent)
.filter(notNullOrUndefined);
}
Expand Down
50 changes: 28 additions & 22 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions server/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ flask-wtf==1.2.1
# via -r requirements.in
future==1.0.0
# via python-twitter
gunicorn==22.0.0
gunicorn==23.0.0
# via -r requirements.in
hachoir==3.0a3
# via superdesk-core
Expand Down Expand Up @@ -164,7 +164,7 @@ markupsafe==2.0.1
# jinja2
# superdesk-core
# wtforms
mongolock==1.3.4
mongolock @ git+https://github.com/superdesk/mongolock.git@v1
# via superdesk-core
oauth2client==4.1.3
# via flask-oidc-ex
Expand Down Expand Up @@ -274,7 +274,7 @@ tzlocal==2.1
# via superdesk-core
unidecode==1.3.8
# via superdesk-core
urllib3==1.25.11
urllib3==1.26.19
# via
# botocore
# elastic-apm
Expand Down
43 changes: 40 additions & 3 deletions server/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

from pathlib import Path
from superdesk.default_settings import strtobool, env
from superdesk.resource import not_analyzed, text_with_keyword, string_with_analyzer
from content_api.app.settings import CONTENTAPI_INSTALLED_APPS

ABS_PATH = str(Path(__file__).resolve().parent)
Expand Down Expand Up @@ -204,13 +205,49 @@
# Disable purging of publish queue
PUBLISH_QUEUE_EXPIRY_MINUTES = 0

es_text = {"type": "string"}
cv_item = {
"type": "object",
"properties": {
"name": text_with_keyword,
"qcode": not_analyzed,
},
}

SCHEMA_UPDATE = {
"archive": {
"extra": {
"type": "dict",
"schema": {},
"mapping": {"type": "object", "dynamic": False, "properties": {"university": {"type": "string"}}},
"mapping": {
"type": "object",
"dynamic": False,
"properties": {
"profile_id": not_analyzed,
"profile_first_name": es_text,
"profile_last_name": es_text,
"profile_title": cv_item,
"profile_job_title": cv_item,
"profile_email": es_text,
"profile_university": cv_item,
"profile_project": cv_item,
"profile_country": {
"type": "object",
"properties": {
"name": text_with_keyword,
"qcode": not_analyzed,
"region": text_with_keyword,
},
},
"profile_biography": string_with_analyzer,
"profile_gender": cv_item,
"profile_age_group": cv_item,
"profile_orcid_id": es_text,
"profile_sdg": cv_item,
"profile_sdgs": cv_item,
},
},
"allow_unknown": True,
}
}
},
},
}
85 changes: 85 additions & 0 deletions server/tests/author_profile_search_test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
from eve.utils import ParsedRequest

from superdesk.metadata.item import CONTENT_STATE, ITEM_STATE
from superdesk.tests import TestCase, json
from apps.search import init_app

from tga.author_profiles import AUTHOR_PROFILE_ROLE
from .fixtures.vocabularies import VOCABULARIES, CONTENT_TYPES, TEST_USER


class AuthorProfileSearchTest(TestCase):
def setUp(self) -> None:
init_app(self.app)
self.app.data.insert("vocabularies", VOCABULARIES)
self.app.data.insert("content_types", CONTENT_TYPES)
self.app.data.insert("users", [TEST_USER])

def test_search_author_profile(self):
self.app.data.insert(
"archive",
[
{
"_id": "ap_1",
"task": {"desk": 1},
ITEM_STATE: CONTENT_STATE.PROGRESS,
"authors": [
{
"code": [TEST_USER["_id"], "Author Profile"],
"role": AUTHOR_PROFILE_ROLE,
"name": TEST_USER["display_name"],
"parent": TEST_USER["_id"],
"sub_label": TEST_USER["display_name"],
}
],
"extra": {
"profile_id": TEST_USER["_id"],
"profile_first_name": "Fooey",
"profile_last_name": "Barey",
"profile_job_title": {
"qcode": "DIRECTOR",
"name": "Director of Photography",
"is_active": True,
},
},
},
],
)

def _perform_search(query_string):
req = ParsedRequest()
req.args = {
"repo": "archive",
"source": json.dumps(
{
"query": {
"bool": {
"must": [
{
"query_string": {
"query": query_string,
"lenient": True,
"default_operator": "AND",
},
},
],
},
},
"from": 0,
"size": 25,
}
),
}

return self.app.data.find("search", req, None)[0]

self.assertEqual(_perform_search("Fooey").count(), 1)
self.assertEqual(_perform_search("Barey").count(), 1)
self.assertEqual(_perform_search("Fooey AND Barey").count(), 1)
self.assertEqual(_perform_search("Director").count(), 1)
self.assertEqual(_perform_search("Director AND Photography").count(), 1)
self.assertEqual(_perform_search("Director AND NOT Development").count(), 1)
self.assertEqual(_perform_search(TEST_USER["_id"]).count(), 1)

self.assertEqual(_perform_search("Director AND Development").count(), 0)
self.assertEqual(_perform_search("NOT Director").count(), 0)
12 changes: 1 addition & 11 deletions server/tests/author_profiles_capi_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,9 @@
from content_api.publish import MONGO_PREFIX

from settings import CONTENTAPI_INSTALLED_APPS
from .author_profiles_test import VOCABULARIES, CONTENT_TYPES, SDGS
from .fixtures.vocabularies import VOCABULARIES, CONTENT_TYPES, SDGS, TEST_USER
from tga.author_profiles import AUTHOR_PROFILE_ROLE

TEST_USER = {
"_id": "abcd123",
"username": "foobar",
"first_name": "Foo",
"last_name": "Bar",
"user_type": "user",
"display_name": "Foo Bar",
"is_enabled": True,
"is_active": True,
}

TEST_SUBSCRIBER = {"_id": "sub1"}

Expand Down
Loading

0 comments on commit fb0f19d

Please sign in to comment.