Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/3850 link editor groups by name #2380

Open
wants to merge 71 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 70 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
bf48bbb
add typing
philipkcl Apr 17, 2024
7369c2c
add typing
philipkcl Apr 17, 2024
185be05
update typing
philipkcl Apr 18, 2024
1536b79
update typing
philipkcl Apr 18, 2024
77d1ec8
rm editor_group
philipkcl Apr 19, 2024
5f2bc8b
add migrate
philipkcl Apr 19, 2024
cb604f6
add TODO
philipkcl Apr 19, 2024
caa91b5
Merge remote-tracking branch 'origin/develop' into feature/3850_link_…
philipkcl May 7, 2024
bc49722
extract find_editor_role_by_id
philipkcl May 7, 2024
2e4371d
extract find_group_stats
philipkcl May 7, 2024
6e30c1b
editor group no longer need since no email need to be sent
philipkcl May 7, 2024
a4a2eb2
remove no longer used suggestions_and_journals.js
philipkcl May 8, 2024
52a06b7
add autocomplete_pair, support different value in id and text
philipkcl May 8, 2024
332dbc2
extract select2Param
philipkcl May 8, 2024
3c30ebf
Revert "extract select2Param"
philipkcl May 8, 2024
6745be5
extract select2Param
philipkcl May 8, 2024
e23f944
remove if else no longer meaningful
philipkcl May 8, 2024
cab9743
Revert "remove if else no longer meaningful"
philipkcl May 8, 2024
2c07353
add autocomplete_text_mapping
philipkcl May 9, 2024
6039909
avoid unnecessary text value requests
philipkcl May 9, 2024
2ca2746
find editor_group by pull id
philipkcl May 9, 2024
590d128
migrate group_exists_by_name usage
philipkcl May 9, 2024
d93fa51
add comments
philipkcl May 9, 2024
36877e5
fix test cases for editor_group.id
philipkcl May 9, 2024
c3d8fdf
add test cases for autocomplete_pair
philipkcl May 13, 2024
38d8616
reformat
philipkcl May 13, 2024
6266955
fix test cases
philipkcl May 13, 2024
999e4c6
add doc
philipkcl May 13, 2024
9febfcf
remove useless parameter `field_name`
philipkcl May 13, 2024
82336dd
template should use editor group name
philipkcl May 13, 2024
71dc225
avoid return None
philipkcl May 13, 2024
9b74a04
add TYPE_CHECKING if
philipkcl May 13, 2024
9dfbd0c
fix for editor group name in todo
philipkcl May 14, 2024
9d5c078
use editor_group.id
philipkcl May 14, 2024
8785a8b
fix test data
philipkcl May 14, 2024
f00abe0
fix doc
philipkcl May 14, 2024
09adc04
query for editor group name
philipkcl May 14, 2024
244db40
cleanup KTODO
philipkcl May 14, 2024
78237d7
update test cases
philipkcl May 14, 2024
bfa984a
Merge remote-tracking branch 'origin/develop' into feature/3850_link_…
philipkcl May 14, 2024
fd4bff1
avoid globally replace module, it will affect globally and broken unr…
philipkcl May 14, 2024
0942200
Merge remote-tracking branch 'origin/develop' into feature/3850_link_…
philipkcl May 16, 2024
041e9f5
fix editor_group ids displayed
philipkcl Jun 6, 2024
392cee1
fix display name in newSelectedFilters
philipkcl Jun 6, 2024
a60d662
add _translatePrepare SelectedFilters
philipkcl Jun 6, 2024
ef713f6
implement editorGroupName callback for selectedFilters, Result, leftMenu
philipkcl Jun 17, 2024
2cfcb28
remove useless import
philipkcl Jun 28, 2024
18d0a1e
fix empty editorGroupName
philipkcl Jun 28, 2024
6ea4c73
merge develop 240628
philipkcl Jun 28, 2024
3faac57
remove escape because some editor group name contain `&`
philipkcl Jul 1, 2024
7a2cc34
add editor_group_name to index
philipkcl Jul 10, 2024
318ca1c
use editor_group_name
philipkcl Jul 10, 2024
e9de8f0
clean up
philipkcl Jul 10, 2024
9104f39
show name by index
philipkcl Jul 10, 2024
bc16017
rename mange-bgjobs.md
philipkcl Jul 10, 2024
a50f3fa
add renew_editor_group_name
philipkcl Jul 11, 2024
b1420e9
use huey_helper function
philipkcl Jul 11, 2024
80e06ac
cleanup
philipkcl Jul 11, 2024
4c97808
apply renew_editor_group_name
philipkcl Jul 11, 2024
8f1c387
use index.editor_group_name instead of callback
philipkcl Jul 12, 2024
692e909
merge develop 240712
philipkcl Jul 12, 2024
4714392
update documents
philipkcl Jul 12, 2024
d4c2215
typing cleanup
philipkcl Jul 12, 2024
eb98e39
rename new_name
philipkcl Jul 12, 2024
7f1d46e
add editor_group_name
philipkcl Jul 12, 2024
160bbf4
add test_renew_editor_group_name
philipkcl Jul 12, 2024
5f488ca
remove duplicate editor_group_name
philipkcl Jul 12, 2024
2570fac
change format for `test_openapi_schema`
philipkcl Jul 12, 2024
ba6c358
update test cases for allow update edit group name now
philipkcl Jul 12, 2024
69c06b5
update migrate for update mapping
philipkcl Jul 23, 2024
79641fa
migrate template changes to new template structure
richard-jones Oct 23, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions doajtest/fixtures/editor_groups.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
from portality import models


def create_editor_group_en():
eg = models.EditorGroup()
eg.set_name("English")
eg.set_id('egid')
return eg


def create_editor_group_cn():
eg = models.EditorGroup()
eg.set_name("Chinese")
eg.set_id('egid2')
return eg


def create_editor_group_jp():
eg = models.EditorGroup()
eg.set_name("Japanese")
eg.set_id('egid3')
return eg

12 changes: 6 additions & 6 deletions doajtest/fixtures/v2/journals.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

class JournalFixtureFactory(object):
@staticmethod
def make_journal_source(in_doaj=False):
def make_journal_source(in_doaj=False) -> dict:
template = deepcopy(JOURNAL_SOURCE)
template['admin']['in_doaj'] = in_doaj
return template
Expand All @@ -37,23 +37,23 @@ def make_many_journal_sources(count=2, in_doaj=False) -> Iterable[dict]:
return journal_sources

@staticmethod
def make_journal_form():
def make_journal_form() -> dict:
return deepcopy(JOURNAL_FORM)

@staticmethod
def make_journal_form_info():
def make_journal_form_info() -> dict:
return deepcopy(JOURNAL_FORM_EXPANDED)

@staticmethod
def make_bulk_edit_data():
def make_bulk_edit_data() -> dict:
return deepcopy(JOURNAL_BULK_EDIT)

@staticmethod
def csv_headers():
def csv_headers() -> dict:
return deepcopy(CSV_HEADERS)

@staticmethod
def question_answers():
def question_answers() -> dict:
return deepcopy(JOURNAL_QUESTION_ANSWERS)


Expand Down
11 changes: 5 additions & 6 deletions doajtest/testdrive/todo_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,37 +68,37 @@ def build_application(title, lmu_diff, cd_diff, status, editor=None, editor_grou
return ap


def build_applications(un, eg):
def build_applications(un: str, eg: models.Application):
w = 7 * 24 * 60 * 60

apps = {}

app = build_application(un + " Stalled Application", 6 * w, 7 * w, constants.APPLICATION_STATUS_IN_PROGRESS,
editor_group=eg.name)
editor_group=eg.id)
app.save()
apps["stalled"] = [{
"id": app.id,
"title": un + " Stalled Application"
}]

app = build_application(un + " Old Application", 8 * w, 8 * w, constants.APPLICATION_STATUS_IN_PROGRESS,
editor_group=eg.name)
editor_group=eg.id)
app.save()
apps["old"] = [{
"id": app.id,
"title": un + " Old Application"
}]

app = build_application(un + " Completed Application", 1 * w, 1 * w, constants.APPLICATION_STATUS_COMPLETED,
editor_group=eg.name)
editor_group=eg.id)
app.save()
apps["completed"] = [{
"id": app.id,
"title": un + " Completed Application"
}]

app = build_application(un + " Pending Application", 1 * w, 1 * w, constants.APPLICATION_STATUS_PENDING,
editor_group=eg.name)
editor_group=eg.id)
app.remove_editor()
app.save()
apps["pending"] = [{
Expand All @@ -107,4 +107,3 @@ def build_applications(un, eg):
}]

return apps

33 changes: 19 additions & 14 deletions doajtest/testdrive/todo_maned_editor_associate.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class TodoManedEditorAssociate(TestDrive):
def setup(self) -> dict:
un = self.create_random_str()
pw = self.create_random_str()
admin = models.Account.make_account(un + "@example.com", un, "TodoManedEditorAssociate " + un, ["admin", "editor", constants.ROLE_ASSOCIATE_EDITOR])
admin = models.Account.make_account(un + "@example.com", un, "TodoManedEditorAssociate " + un,
["admin", "editor", constants.ROLE_ASSOCIATE_EDITOR])
admin.set_password(pw)
admin.save()

Expand Down Expand Up @@ -53,7 +54,6 @@ def setup(self) -> dict:
eapps = build_editor_applications(un, eg2)
mapps = build_maned_applications(un, eg1, owner.id, eg3)


return {
"account": {
"username": admin.id,
Expand Down Expand Up @@ -96,45 +96,47 @@ def teardown(self, params) -> dict:
return {"status": "success"}


def build_maned_applications(un, eg, owner, eponymous_group):
def build_maned_applications(un: str,
eg: models.EditorGroup, owner,
eponymous_group: models.EditorGroup):
w = 7 * 24 * 60 * 60

apps = {}

app = build_application(un + " Maned Stalled Application", 8 * w, 9 * w, constants.APPLICATION_STATUS_IN_PROGRESS,
editor_group=eg.name, owner=owner)
editor_group=eg.id, owner=owner)
app.save()
apps["stalled"] = [{
"id": app.id,
"title": un + " Maned Stalled Application"
}]

app = build_application(un + " Maned Old Application", 10 * w, 10 * w, constants.APPLICATION_STATUS_IN_PROGRESS,
editor_group=eg.name, owner=owner)
editor_group=eg.id, owner=owner)
app.save()
apps["old"] = [{
"id": app.id,
"title": un + " Maned Old Application"
}]

app = build_application(un + " Maned Ready Application", 1 * w, 1 * w, constants.APPLICATION_STATUS_READY,
editor_group=eg.name, owner=owner)
editor_group=eg.id, owner=owner)
app.save()
apps["ready"] = [{
"id": app.id,
"title": un + " Maned Completed Application"
}]

app = build_application(un + " Maned Completed Application", 2 * w, 2 * w, constants.APPLICATION_STATUS_COMPLETED,
editor_group=eg.name, owner=owner)
editor_group=eg.id, owner=owner)
app.save()
apps["completed"] = [{
"id": app.id,
"title": un + " Maned Completed Application"
}]

app = build_application(un + " Maned Pending Application", 2 * w, 2 * w, constants.APPLICATION_STATUS_PENDING,
editor_group=eg.name, owner=owner)
editor_group=eg.id, owner=owner)
app.remove_editor()
app.save()
apps["pending"] = [{
Expand All @@ -144,20 +146,22 @@ def build_maned_applications(un, eg, owner, eponymous_group):

app = build_application(un + " Maned Low Priority Pending Application", 1 * w, 1 * w,
constants.APPLICATION_STATUS_PENDING,
editor_group=eponymous_group.name, owner=owner)
editor_group=eponymous_group.id, owner=owner)
app.remove_editor()
app.save()
apps["low_priority_pending"] = [{
"id": app.id,
"title": un + " Maned Low Priority Pending Application"
}]

lmur = build_application(un + " Last Month Maned Update Request", 5 * w, 5 * w, constants.APPLICATION_STATUS_UPDATE_REQUEST,
editor_group=eponymous_group.name, owner=owner, update_request=True)
lmur = build_application(un + " Last Month Maned Update Request", 5 * w, 5 * w,
constants.APPLICATION_STATUS_UPDATE_REQUEST,
editor_group=eponymous_group.id, owner=owner, update_request=True)
lmur.save()

tmur = build_application(un + " This Month Maned Update Request", 0, 0, constants.APPLICATION_STATUS_UPDATE_REQUEST,
editor_group=eponymous_group.name, owner=owner, update_request=True)
tmur = build_application(un + " This Month Maned Update Request", 0, 0,
constants.APPLICATION_STATUS_UPDATE_REQUEST,
editor_group=eponymous_group.id, owner=owner, update_request=True)
tmur.save()

apps["update_request"] = [
Expand All @@ -174,7 +178,8 @@ def build_maned_applications(un, eg, owner, eponymous_group):
return apps


def build_application(title, lmu_diff, cd_diff, status, editor=None, editor_group=None, owner=None, update_request=False):
def build_application(title, lmu_diff, cd_diff, status, editor=None, editor_group=None, owner=None,
update_request=False):
source = ApplicationFixtureFactory.make_application_source()
ap = models.Application(**source)
ap.bibjson().title = title
Expand Down
20 changes: 5 additions & 15 deletions doajtest/unit/application_processors/test_editor_journal_review.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest.mock import patch

from doajtest.helpers import DoajTestCase

from portality import models
Expand All @@ -13,7 +15,7 @@
#####################################################################

@classmethod
def editor_group_pull(cls, field, value):
def editor_group_pull(cls, value):
eg = models.EditorGroup()
eg.set_editor("eddie")
eg.set_associates(["associate", "assan"])
Expand All @@ -36,25 +38,13 @@ def mock_lookup_code(code):

class TestEditorJournalReview(DoajTestCase):

def setUp(self):
super(TestEditorJournalReview, self).setUp()

self.editor_group_pull = models.EditorGroup.pull_by_key
models.EditorGroup.pull_by_key = editor_group_pull

self.old_lookup_code = lcc.lookup_code
lcc.lookup_code = mock_lookup_code

def tearDown(self):
super(TestEditorJournalReview, self).tearDown()
models.EditorGroup.pull_by_key = self.editor_group_pull
lcc.lookup_code = self.old_lookup_code


###########################################################
# Tests on the publisher's re-journal form
###########################################################

@patch('portality.models.EditorGroup.pull', editor_group_pull)
@patch('portality.lcc.lookup_code', mock_lookup_code)
def test_01_editor_review_success(self):
"""Give the editor's journal form a full workout"""

Expand Down
20 changes: 5 additions & 15 deletions doajtest/unit/application_processors/test_maned_journal_review.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from unittest.mock import patch

from doajtest.helpers import DoajTestCase

from portality import models
Expand All @@ -17,7 +19,7 @@
#####################################################################

@classmethod
def editor_group_pull(cls, field, value):
def editor_group_pull(cls, value):
eg = models.EditorGroup()
eg.set_editor("eddie")
eg.set_associates(["associate", "assan"])
Expand All @@ -32,20 +34,8 @@ def mock_lookup_code(code):

class TestManEdJournalReview(DoajTestCase):

def setUp(self):
super(TestManEdJournalReview, self).setUp()

self.editor_group_pull = models.EditorGroup.pull_by_key
models.EditorGroup.pull_by_key = editor_group_pull

self.old_lookup_code = lcc.lookup_code
lcc.lookup_code = mock_lookup_code

def tearDown(self):
super(TestManEdJournalReview, self).tearDown()
models.EditorGroup.pull_by_key = self.editor_group_pull
lcc.lookup_code = self.old_lookup_code

@patch('portality.models.EditorGroup.pull', editor_group_pull)
@patch('portality.lcc.lookup_code', mock_lookup_code)
def test_01_maned_review_success(self):
"""Give the Managing Editor's journal form a full workout"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def test_consume_success(self):
acc.save()

eg = models.EditorGroup()
eg.set_id(app.editor_group)
eg.set_name(app.editor_group)
eg.set_maned(acc.id)
eg.save(blocking=True)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def test_consume_success(self):
acc.save()

eg = models.EditorGroup()
eg.set_name(app.editor_group)
eg.set_name("test group")
eg.set_id(app.editor_group)
eg.set_editor(acc.id)
eg.save(blocking=True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ def test_consume_success(self):
acc.save()

eg = models.EditorGroup()
eg.set_name(app.editor_group)
eg.set_name("test group")
eg.set_id(app.editor_group)
eg.set_editor("editor")
eg.save(blocking=True)

Expand Down Expand Up @@ -67,7 +68,8 @@ def test_consume_fail(self):
# app.save(blocking=True)

eg = models.EditorGroup()
eg.set_name(app.editor_group)
eg.set_name('test group')
eg.set_id(app.editor_group)
eg.save(blocking=True)

event = models.Event(constants.EVENT_APPLICATION_EDITOR_GROUP_ASSIGNED, context={"application": app.data})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def test_consume_success(self):
acc.save()

eg = models.EditorGroup()
eg.set_name(app.editor_group)
eg.set_name('test group')
eg.set_id(app.editor_group)
eg.set_editor(acc.id)
eg.save(blocking=True)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ def test_consume_success(self):
acc.save()

eg = models.EditorGroup()
eg.set_name(app.editor_group)
eg.set_name("test group")
eg.set_id(app.editor_group)
eg.set_maned(acc.id)
eg.save(blocking=True)

Expand Down
Loading
Loading