Skip to content

Commit

Permalink
Add is_active field in UserFilter (#3235)
Browse files Browse the repository at this point in the history
* Add is_active field in UserFilter

* Update changelog

* Add is_active as a default searchParam to get user list

* Fix url search query

* Update CHANGELOG.md

Co-authored-by: Nikita Manovich <[email protected]>
  • Loading branch information
Jooong and Nikita Manovich authored Jun 1, 2021
1 parent e0fe9c1 commit 573bdbe
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added

- Support of context images for 2D image tasks (<https://github.com/openvinotoolkit/cvat/pull/3122>)
- Filter `is_active` for user list (<https://github.com/openvinotoolkit/cvat/pull/3235>)

### Changed

Expand Down
6 changes: 5 additions & 1 deletion cvat-core/src/api-implementation.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@
cvat.users.get.implementation = async (filter) => {
checkFilter(filter, {
id: isInteger,
is_active: isBoolean,
self: isBoolean,
search: isString,
limit: isInteger,
Expand All @@ -125,7 +126,10 @@
users = await serverProxy.users.self();
users = [users];
} else {
const searchParams = {};
// get list of active users as default
const searchParams = {
is_active: true,
};
for (const key in filter) {
if (filter[key] && key !== 'self') {
searchParams[key] = filter[key];
Expand Down
3 changes: 2 additions & 1 deletion cvat/apps/engine/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -921,11 +921,12 @@ def get_permissions(self):
class UserFilter(filters.FilterSet):
class Meta:
model = User
fields = ("id",)
fields = ("id", "is_active")

@method_decorator(name='list', decorator=swagger_auto_schema(
manual_parameters=[
openapi.Parameter('id',openapi.IN_QUERY,description="A unique number value identifying this user",type=openapi.TYPE_NUMBER),
openapi.Parameter('is_active',openapi.IN_QUERY,description="Returns only active users",type=openapi.TYPE_BOOLEAN),
],
operation_summary='Method provides a paginated list of users registered on the server'))
@method_decorator(name='retrieve', decorator=swagger_auto_schema(
Expand Down
2 changes: 1 addition & 1 deletion tests/cypress/support/commands_review_pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ Cypress.Commands.add('submitReview', (decision, user) => {
cy.get('.cvat-submit-review-dialog').within(() => {
cy.contains(new RegExp(`^${decision}$`, 'g')).click();
if (decision === 'Review next') {
cy.intercept('GET', `/api/v1/users?search=${user}&limit=10`).as('searchUsers');
cy.intercept('GET', `/api/v1/users?is_active=true&search=${user}&limit=10`).as('searchUsers');
cy.get('.cvat-user-search-field').within(() => {
cy.get('input[type="search"]').clear().type(`${user}`);
cy.wait('@searchUsers').its('response.statusCode').should('equal', 200);
Expand Down

0 comments on commit 573bdbe

Please sign in to comment.