Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Arkindex
Backend
Commits
2ffcc2c7
Commit
2ffcc2c7
authored
3 years ago
by
Yoann Schneider
Committed by
Bastien Abadie
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
ignore configuration filter when mode is set to template
parent
d59cfa6e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!1582
ignore configuration filter when mode is set to template
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/dataimport/api.py
+10
-5
10 additions, 5 deletions
arkindex/dataimport/api.py
arkindex/dataimport/tests/test_templates.py
+13
-0
13 additions, 0 deletions
arkindex/dataimport/tests/test_templates.py
with
23 additions
and
5 deletions
arkindex/dataimport/api.py
+
10
−
5
View file @
2ffcc2c7
...
...
@@ -153,10 +153,6 @@ class DataImportsList(ProcessACLMixin, ListAPIView):
def
get_queryset
(
self
):
filters
=
Q
()
if
'
with_workflow
'
in
self
.
request
.
query_params
:
with_workflow
=
self
.
request
.
query_params
[
'
with_workflow
'
]
filters
&=
Q
(
workflow__isnull
=
bool
(
with_workflow
and
with_workflow
.
lower
()
in
(
'
false
'
,
'
0
'
)))
if
'
corpus
'
in
self
.
request
.
query_params
:
corpus_id
=
self
.
request
.
query_params
[
'
corpus
'
]
try
:
...
...
@@ -166,14 +162,23 @@ class DataImportsList(ProcessACLMixin, ListAPIView):
# No supplementary validation is required on the corpus ID filter
filters
&=
Q
(
corpus
=
corpus_id
)
# Default import_mode variable for compatibility later
import_mode
=
None
if
'
mode
'
in
self
.
request
.
query_params
:
try
:
filters
&=
Q
(
mode
=
DataImportMode
(
self
.
request
.
query_params
[
'
mode
'
]))
import_mode
=
DataImportMode
(
self
.
request
.
query_params
[
'
mode
'
])
filters
&=
Q
(
mode
=
import_mode
)
except
ValueError
:
raise
ValidationError
({
'
mode
'
:
[
"
Mode
'
{}
'
does not exist
"
.
format
(
self
.
request
.
query_params
[
'
mode
'
])]
})
# When listing template processes, the configuration filters makes no sense
if
import_mode
!=
DataImportMode
.
Template
:
if
'
with_workflow
'
in
self
.
request
.
query_params
:
with_workflow
=
self
.
request
.
query_params
[
'
with_workflow
'
]
filters
&=
Q
(
workflow__isnull
=
bool
(
with_workflow
and
with_workflow
.
lower
()
in
(
'
false
'
,
'
0
'
)))
if
'
created
'
in
self
.
request
.
query_params
:
created
=
self
.
request
.
query_params
[
'
created
'
]
creator_filter
=
Q
(
creator_id
=
self
.
request
.
user
.
id
)
...
...
This diff is collapsed.
Click to expand it.
arkindex/dataimport/tests/test_templates.py
+
13
−
0
View file @
2ffcc2c7
...
...
@@ -299,3 +299,16 @@ class TestTemplates(FixtureAPITestCase):
# Check that every new worker_run is the same as one of the template's
self
.
assertTrue
(
self
.
template
.
worker_runs
.
filter
(
version
=
parent_run
.
version
).
exists
())
self
.
assertTrue
(
self
.
template
.
worker_runs
.
filter
(
version
=
child_run
.
version
).
exists
())
def
test_list_templates_ignores_configuration_filter
(
self
):
self
.
client
.
force_login
(
self
.
user
)
with
self
.
assertNumQueries
(
7
):
response
=
self
.
client
.
get
(
reverse
(
'
api:import-list
'
),
data
=
{
"
mode
"
:
'
template
'
,
"
with_workflow
"
:
True
},
content_type
=
'
application/json
'
,
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
# The 'with_workflow' filter should be ignored and some templates should be returned
# If it wasn't, no template are returned because none are configured
self
.
assertTrue
(
len
(
response
.
json
())
>
0
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment