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
c4ba6842
Commit
c4ba6842
authored
4 years ago
by
Bastien Abadie
Browse files
Options
Downloads
Plain Diff
Merge branch 'filter-processes-with-workflow' into 'master'
Filter processes with/without workflow Closes
#395
See merge request
!901
parents
7205de3f
606e62e5
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!901
Filter processes with/without workflow
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
arkindex/dataimport/api.py
+13
-1
13 additions, 1 deletion
arkindex/dataimport/api.py
arkindex/dataimport/tests/test_imports.py
+18
-11
18 additions, 11 deletions
arkindex/dataimport/tests/test_imports.py
with
31 additions
and
12 deletions
arkindex/dataimport/api.py
+
13
−
1
View file @
c4ba6842
...
...
@@ -79,13 +79,25 @@ class DataImportsList(CorpusACLMixin, ListAPIView):
'
schema
'
:
{
'
type
'
:
'
string
'
,
},
},
{
'
name
'
:
'
with_workflow
'
,
'
in
'
:
'
query
'
,
'
description
'
:
'
Restrict to or exclude import with workflow
'
,
'
required
'
:
False
,
'
schema
'
:
{
'
type
'
:
'
boolean
'
,
'
default
'
:
True
},
}
]
}
def
get_queryset
(
self
):
with_workflow
=
self
.
request
.
query_params
.
get
(
'
with_workflow
'
)
filters
=
{
'
corpus__in
'
:
Corpus
.
objects
.
readable
(
self
.
request
.
user
)
'
corpus__in
'
:
Corpus
.
objects
.
readable
(
self
.
request
.
user
),
'
workflow__isnull
'
:
bool
(
with_workflow
and
with_workflow
.
lower
()
in
(
'
false
'
,
'
0
'
))
}
if
'
corpus
'
in
self
.
request
.
query_params
:
...
...
This diff is collapsed.
Click to expand it.
arkindex/dataimport/tests/test_imports.py
+
18
−
11
View file @
c4ba6842
...
...
@@ -55,7 +55,7 @@ class TestImports(FixtureAPITestCase):
def
test_list
(
self
):
self
.
client
.
force_login
(
self
.
user
)
response
=
self
.
client
.
get
(
reverse
(
'
api:import-list
'
))
response
=
self
.
client
.
get
(
reverse
(
'
api:import-list
'
)
,
{
'
with_workflow
'
:
False
}
)
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
data
=
response
.
json
()
self
.
assertEqual
(
len
(
data
[
'
results
'
]),
1
)
...
...
@@ -81,15 +81,9 @@ class TestImports(FixtureAPITestCase):
response
=
self
.
client
.
get
(
reverse
(
'
api:import-list
'
))
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
data
=
response
.
json
()
self
.
assertEqual
(
len
(
data
[
'
results
'
]),
2
)
self
.
assertEqual
(
len
(
data
[
'
results
'
]),
1
)
results
=
data
[
'
results
'
]
self
.
assertListEqual
(
results
,
[{
'
id
'
:
str
(
self
.
dataimport
.
id
),
'
state
'
:
State
.
Unscheduled
.
value
,
'
mode
'
:
DataImportMode
.
Images
.
value
,
'
corpus
'
:
str
(
self
.
corpus
.
id
),
'
workflow
'
:
None
,
},
{
'
id
'
:
str
(
dataimport2
.
id
),
'
state
'
:
State
.
Unscheduled
.
value
,
'
mode
'
:
DataImportMode
.
Workers
.
value
,
...
...
@@ -97,12 +91,25 @@ class TestImports(FixtureAPITestCase):
'
workflow
'
:
f
"
http://testserver/ponos/v1/workflow/
{
dataimport2
.
workflow
.
id
}
/
"
,
}])
response
=
self
.
client
.
get
(
reverse
(
'
api:import-list
'
),
{
'
with_workflow
'
:
False
})
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
data
=
response
.
json
()
self
.
assertEqual
(
len
(
data
[
'
results
'
]),
1
)
results
=
data
[
'
results
'
]
self
.
assertListEqual
(
results
,
[{
'
id
'
:
str
(
self
.
dataimport
.
id
),
'
state
'
:
State
.
Unscheduled
.
value
,
'
mode
'
:
DataImportMode
.
Images
.
value
,
'
corpus
'
:
str
(
self
.
corpus
.
id
),
'
workflow
'
:
None
,
}])
def
test_list_filter_corpus
(
self
):
self
.
client
.
force_login
(
self
.
superuser
)
corpus2
=
Corpus
.
objects
.
create
(
name
=
'
Another corpus
'
,
description
=
'
something
'
)
dataimport2
=
corpus2
.
imports
.
create
(
creator
=
self
.
user
,
mode
=
DataImportMode
.
Images
)
response
=
self
.
client
.
get
(
reverse
(
'
api:import-list
'
),
{
'
corpus
'
:
str
(
corpus2
.
id
)})
response
=
self
.
client
.
get
(
reverse
(
'
api:import-list
'
),
{
'
corpus
'
:
str
(
corpus2
.
id
)
,
'
with_workflow
'
:
False
})
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
data
=
response
.
json
()
self
.
assertEqual
(
len
(
data
[
'
results
'
]),
1
)
...
...
@@ -120,7 +127,7 @@ class TestImports(FixtureAPITestCase):
creator
=
self
.
user
,
mode
=
DataImportMode
.
PDF
,
)
response
=
self
.
client
.
get
(
reverse
(
'
api:import-list
'
),
{
'
mode
'
:
DataImportMode
.
PDF
.
value
})
response
=
self
.
client
.
get
(
reverse
(
'
api:import-list
'
),
{
'
mode
'
:
DataImportMode
.
PDF
.
value
,
'
with_workflow
'
:
False
})
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
data
=
response
.
json
()
self
.
assertEqual
(
len
(
data
[
'
results
'
]),
1
)
...
...
@@ -145,7 +152,7 @@ class TestImports(FixtureAPITestCase):
creator
=
self
.
user
,
mode
=
DataImportMode
.
Images
,
)
response
=
self
.
client
.
get
(
reverse
(
'
api:import-list
'
),
{
'
id
'
:
dataimport_id
[:
10
]})
response
=
self
.
client
.
get
(
reverse
(
'
api:import-list
'
),
{
'
id
'
:
dataimport_id
[:
10
]
,
'
with_workflow
'
:
False
})
self
.
assertEqual
(
response
.
status_code
,
status
.
HTTP_200_OK
)
data
=
response
.
json
()
self
.
assertEqual
(
len
(
data
[
'
results
'
]),
1
)
...
...
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