View | Details | Raw Unified | Return to bug 30719
Collapse All | Expand All

(-)a/Koha/REST/V1/IllbatchStatuses.pm (-3 / +3 lines)
Lines 50-56 Get one batch statuses Link Here
50
sub get {
50
sub get {
51
    my $c = shift->openapi->valid_input;
51
    my $c = shift->openapi->valid_input;
52
52
53
    my $status_code = $c->param('illbatchstatus_code');
53
    my $status_code = $c->param('ill_batchstatus_code');
54
54
55
    my $status = Koha::IllbatchStatuses->find( { code => $status_code } );
55
    my $status = Koha::IllbatchStatuses->find( { code => $status_code } );
56
56
Lines 107-113 Update a batch status Link Here
107
sub update {
107
sub update {
108
    my $c = shift->openapi->valid_input or return;
108
    my $c = shift->openapi->valid_input or return;
109
109
110
    my $status = Koha::IllbatchStatuses->find( { code => $c->param('illbatchstatus_code') } );
110
    my $status = Koha::IllbatchStatuses->find( { code => $c->param('ill_batchstatus_code') } );
111
111
112
    if ( not defined $status ) {
112
    if ( not defined $status ) {
113
        return $c->render(
113
        return $c->render(
Lines 142-148 sub delete { Link Here
142
142
143
    my $c = shift->openapi->valid_input or return;
143
    my $c = shift->openapi->valid_input or return;
144
144
145
    my $status = Koha::IllbatchStatuses->find( { code => $c->param('illbatchstatus_code') } );
145
    my $status = Koha::IllbatchStatuses->find( { code => $c->param('ill_batchstatus_code') } );
146
146
147
    if ( not defined $status ) {
147
    if ( not defined $status ) {
148
        return $c->render( status => 404, openapi => { errors => [ { message => "ILL batch status not found" } ] } );
148
        return $c->render( status => 404, openapi => { errors => [ { message => "ILL batch status not found" } ] } );
(-)a/api/v1/swagger/definitions/illbatchstatuses.yaml (-1 / +1 lines)
Lines 1-5 Link Here
1
---
1
---
2
type: array
2
type: array
3
items:
3
items:
4
  $ref: "illbatchstatus.yaml"
4
  $ref: "ill_batchstatus.yaml"
5
additionalProperties: false
5
additionalProperties: false
(-)a/api/v1/swagger/paths/illbatchstatuses.yaml (-16 / +16 lines)
Lines 1-10 Link Here
1
---
1
---
2
/illbatchstatuses:
2
/ill/batchstatuses:
3
  get:
3
  get:
4
    x-mojo-to: IllbatchStatuses#list
4
    x-mojo-to: IllbatchStatuses#list
5
    operationId: listIllbatchstatuses
5
    operationId: listIllbatchstatuses
6
    tags:
6
    tags:
7
      - illbatchstatuses
7
      - ill_batchstatuses
8
    summary: List ILL batch statuses
8
    summary: List ILL batch statuses
9
    parameters: []
9
    parameters: []
10
    produces:
10
    produces:
Lines 13-19 Link Here
13
      "200":
13
      "200":
14
        description: A list of ILL batch statuses
14
        description: A list of ILL batch statuses
15
        schema:
15
        schema:
16
          $ref: "../swagger.yaml#/definitions/illbatchstatuses"
16
          $ref: "../swagger.yaml#/definitions/ill_batchstatuses"
17
      "401":
17
      "401":
18
        description: Authentication required
18
        description: Authentication required
19
        schema:
19
        schema:
Lines 44-50 Link Here
44
    x-mojo-to: IllbatchStatuses#add
44
    x-mojo-to: IllbatchStatuses#add
45
    operationId: addIllbatchstatus
45
    operationId: addIllbatchstatus
46
    tags:
46
    tags:
47
      - illbatchstatuses
47
      - ill_batchstatuses
48
    summary: Add ILL batch status
48
    summary: Add ILL batch status
49
    parameters:
49
    parameters:
50
      - name: body
50
      - name: body
Lines 52-65 Link Here
52
        description: A JSON object containing informations about the new batch status
52
        description: A JSON object containing informations about the new batch status
53
        required: true
53
        required: true
54
        schema:
54
        schema:
55
          $ref: "../swagger.yaml#/definitions/illbatchstatus"
55
          $ref: "../swagger.yaml#/definitions/ill_batchstatus"
56
    produces:
56
    produces:
57
      - application/json
57
      - application/json
58
    responses:
58
    responses:
59
      "201":
59
      "201":
60
        description: Batch status added
60
        description: Batch status added
61
        schema:
61
        schema:
62
          $ref: "../swagger.yaml#/definitions/illbatchstatus"
62
          $ref: "../swagger.yaml#/definitions/ill_batchstatus"
63
      "400":
63
      "400":
64
        description: Bad request
64
        description: Bad request
65
        schema:
65
        schema:
Lines 90-104 Link Here
90
    x-koha-authorization:
90
    x-koha-authorization:
91
      permissions:
91
      permissions:
92
        ill: "1"
92
        ill: "1"
93
"/illbatchstatuses/{illbatchstatus_code}":
93
"/ill/batchstatuses/{ill_batchstatus_code}":
94
  get:
94
  get:
95
    x-mojo-to: IllbatchStatuses#get
95
    x-mojo-to: IllbatchStatuses#get
96
    operationId: getIllbatchstatuses
96
    operationId: getIllbatchstatuses
97
    tags:
97
    tags:
98
      - illbatchstatuses
98
      - ill_batchstatuses
99
    summary: Get ILL batch status
99
    summary: Get ILL batch status
100
    parameters:
100
    parameters:
101
      - name: illbatchstatus_code
101
      - name: ill_batchstatus_code
102
        in: path
102
        in: path
103
        description: ILL batch status
103
        description: ILL batch status
104
        required: true
104
        required: true
Lines 109-115 Link Here
109
      "200":
109
      "200":
110
        description: An ILL batch status
110
        description: An ILL batch status
111
        schema:
111
        schema:
112
          $ref: "../swagger.yaml#/definitions/illbatchstatus"
112
          $ref: "../swagger.yaml#/definitions/ill_batchstatus"
113
      "401":
113
      "401":
114
        description: Authentication required
114
        description: Authentication required
115
        schema:
115
        schema:
Lines 140-155 Link Here
140
    x-mojo-to: IllbatchStatuses#update
140
    x-mojo-to: IllbatchStatuses#update
141
    operationId: updateIllBatchstatus
141
    operationId: updateIllBatchstatus
142
    tags:
142
    tags:
143
      - illbatchstatuses
143
      - ill_batchstatuses
144
    summary: Update batch status
144
    summary: Update batch status
145
    parameters:
145
    parameters:
146
      - $ref: "../swagger.yaml#/parameters/illbatchstatus_code_pp"
146
      - $ref: "../swagger.yaml#/parameters/ill_batchstatus_code_pp"
147
      - name: body
147
      - name: body
148
        in: body
148
        in: body
149
        description: A JSON object containing information on the batch status
149
        description: A JSON object containing information on the batch status
150
        required: true
150
        required: true
151
        schema:
151
        schema:
152
          $ref: "../swagger.yaml#/definitions/illbatchstatus"
152
          $ref: "../swagger.yaml#/definitions/ill_batchstatus"
153
    consumes:
153
    consumes:
154
      - application/json
154
      - application/json
155
    produces:
155
    produces:
Lines 158-164 Link Here
158
      "200":
158
      "200":
159
        description: An ILL batch status
159
        description: An ILL batch status
160
        schema:
160
        schema:
161
          $ref: "../swagger.yaml#/definitions/illbatchstatus"
161
          $ref: "../swagger.yaml#/definitions/ill_batchstatus"
162
      "400":
162
      "400":
163
        description: Bad request
163
        description: Bad request
164
        schema:
164
        schema:
Lines 193-202 Link Here
193
    x-mojo-to: IllbatchStatuses#delete
193
    x-mojo-to: IllbatchStatuses#delete
194
    operationId: deleteBatchstatus
194
    operationId: deleteBatchstatus
195
    tags:
195
    tags:
196
      - illbatchstatuses
196
      - ill_batchstatuses
197
    summary: Delete ILL batch status
197
    summary: Delete ILL batch status
198
    parameters:
198
    parameters:
199
      - $ref: "../swagger.yaml#/parameters/illbatchstatus_code_pp"
199
      - $ref: "../swagger.yaml#/parameters/ill_batchstatus_code_pp"
200
    produces:
200
    produces:
201
      - application/json
201
      - application/json
202
    responses:
202
    responses:
(-)a/api/v1/swagger/swagger.yaml (-11 / +11 lines)
Lines 68-77 definitions: Link Here
68
    $ref: ./definitions/ill_batch.yaml
68
    $ref: ./definitions/ill_batch.yaml
69
  ill_batches:
69
  ill_batches:
70
    $ref: ./definitions/ill_batches.yaml
70
    $ref: ./definitions/ill_batches.yaml
71
  illbatchstatus:
71
  ill_batchstatus:
72
    $ref: ./definitions/illbatchstatus.yaml
72
    $ref: ./definitions/ill_batchstatus.yaml
73
  illbatchstatuses:
73
  ill_batchstatuses:
74
    $ref: ./definitions/illbatchstatuses.yaml
74
    $ref: ./definitions/ill_batchstatuses.yaml
75
  import_batch_profile:
75
  import_batch_profile:
76
    $ref: ./definitions/import_batch_profile.yaml
76
    $ref: ./definitions/import_batch_profile.yaml
77
  import_batch_profiles:
77
  import_batch_profiles:
Lines 281-290 paths: Link Here
281
    $ref: ./paths/ill_batches.yaml#/~1ill~1batches
281
    $ref: ./paths/ill_batches.yaml#/~1ill~1batches
282
  "/ill/batches/{ill_batch_id}":
282
  "/ill/batches/{ill_batch_id}":
283
    $ref: "./paths/ill_batches.yaml#/~1ill~1batches~1{ill_batch_id}"
283
    $ref: "./paths/ill_batches.yaml#/~1ill~1batches~1{ill_batch_id}"
284
  /illbatchstatuses:
284
  /ill/batchstatuses:
285
    $ref: ./paths/illbatchstatuses.yaml#/~1illbatchstatuses
285
    $ref: ./paths/ill_batchstatuses.yaml#/~1ill~1batchstatuses
286
  "/illbatchstatuses/{illbatchstatus_code}":
286
  "/ill/batchstatuses/{ill_batchstatus_code}":
287
    $ref: "./paths/illbatchstatuses.yaml#/~1illbatchstatuses~1{illbatchstatus_code}"
287
    $ref: "./paths/ill_batchstatuses.yaml#/~1ill~1batchstatuses~1{ill_batchstatus_code}"
288
  "/import_batches/{import_batch_id}/records/{import_record_id}/matches/chosen":
288
  "/import_batches/{import_batch_id}/records/{import_record_id}/matches/chosen":
289
    $ref: "./paths/import_batches.yaml#/~1import_batches~1{import_batch_id}~1records~1{import_record_id}~1matches~1chosen"
289
    $ref: "./paths/import_batches.yaml#/~1import_batches~1{import_batch_id}~1records~1{import_record_id}~1matches~1chosen"
290
  /import_batch_profiles:
290
  /import_batch_profiles:
Lines 543-552 parameters: Link Here
543
    name: ill_batch_id
543
    name: ill_batch_id
544
    required: true
544
    required: true
545
    type: integer
545
    type: integer
546
  illbatchstatus_code_pp:
546
  ill_batchstatus_code_pp:
547
    description: Internal ILL batch status identifier
547
    description: Internal ILL batch status identifier
548
    in: path
548
    in: path
549
    name: illbatchstatus_code
549
    name: ill_batchstatus_code
550
    required: true
550
    required: true
551
    type: string
551
    type: string
552
  import_batch_profile_id_pp:
552
  import_batch_profile_id_pp:
Lines 883-889 tags: Link Here
883
    name: ill_batches
883
    name: ill_batches
884
    x-displayName: ILL batches
884
    x-displayName: ILL batches
885
  - description: "Manage ILL module batch statuses\n"
885
  - description: "Manage ILL module batch statuses\n"
886
    name: illbatchstatuses
886
    name: ill_batchstatuses
887
    x-displayName: ILL batch statuses
887
    x-displayName: ILL batch statuses
888
  - description: "Manage ILL requests\n"
888
  - description: "Manage ILL requests\n"
889
    name: ill_requests
889
    name: ill_requests
(-)a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js (-1 / +1 lines)
Lines 485-491 Link Here
485
485
486
    // Get all batch statuses
486
    // Get all batch statuses
487
    function fetchStatuses() {
487
    function fetchStatuses() {
488
        window.doApiRequest('/api/v1/illbatchstatuses')
488
        window.doApiRequest('/api/v1/ill/batchstatuses')
489
            .then(function (response) {
489
            .then(function (response) {
490
                return response.json();
490
                return response.json();
491
            })
491
            })
(-)a/t/db_dependent/api/v1/illbatchstatuses.t (-19 / +18 lines)
Lines 56-62 subtest 'list() tests' => sub { Link Here
56
56
57
    ## Authorized user tests
57
    ## Authorized user tests
58
    # No statuses, so empty array should be returned
58
    # No statuses, so empty array should be returned
59
    $t->get_ok("//$userid:$password@/api/v1/illbatchstatuses")->status_is(200)->json_is( [] );
59
    $t->get_ok("//$userid:$password@/api/v1/ill/batchstatuses")->status_is(200)->json_is( [] );
60
60
61
    my $status = $builder->build_object(
61
    my $status = $builder->build_object(
62
        {
62
        {
Lines 70-76 subtest 'list() tests' => sub { Link Here
70
    );
70
    );
71
71
72
    # One batch created, should get returned
72
    # One batch created, should get returned
73
    $t->get_ok("//$userid:$password@/api/v1/illbatchstatuses")->status_is(200)->json_has( '/0/id', 'ID' )
73
    $t->get_ok("//$userid:$password@/api/v1/ill/batchstatuses")->status_is(200)->json_has( '/0/id', 'ID' )
74
        ->json_has( '/0/name', 'Name' )->json_has( '/0/code', 'Code' )->json_has( '/0/is_system', 'is_system' );
74
        ->json_has( '/0/name', 'Name' )->json_has( '/0/code', 'Code' )->json_has( '/0/is_system', 'is_system' );
75
75
76
    $schema->storage->txn_rollback;
76
    $schema->storage->txn_rollback;
Lines 113-129 subtest 'get() tests' => sub { Link Here
113
    $patron->set_password( { password => $password, skip_validation => 1 } );
113
    $patron->set_password( { password => $password, skip_validation => 1 } );
114
    my $unauth_userid = $patron->userid;
114
    my $unauth_userid = $patron->userid;
115
115
116
    $t->get_ok( "//$userid:$password@/api/v1/illbatchstatuses/" . $status->code )->status_is(200)
116
    $t->get_ok( "//$userid:$password@/api/v1/ill/batchstatuses/" . $status->code )->status_is(200)
117
        ->json_has( '/id',        'ID' )->json_has( '/name', 'Name' )->json_has( '/code', 'Code' )
117
        ->json_has( '/id',        'ID' )->json_has( '/name', 'Name' )->json_has( '/code', 'Code' )
118
        ->json_has( '/is_system', 'is_system' );
118
        ->json_has( '/is_system', 'is_system' );
119
119
120
    $t->get_ok( "//$unauth_userid:$password@/api/v1/illbatchstatuses/" . $status->id )->status_is(403);
120
    $t->get_ok( "//$unauth_userid:$password@/api/v1/ill/batchstatuses/" . $status->id )->status_is(403);
121
121
122
    my $status_to_delete  = $builder->build_object( { class => 'Koha::IllbatchStatuses' } );
122
    my $status_to_delete  = $builder->build_object( { class => 'Koha::IllbatchStatuses' } );
123
    my $non_existent_code = $status_to_delete->code;
123
    my $non_existent_code = $status_to_delete->code;
124
    $status_to_delete->delete;
124
    $status_to_delete->delete;
125
125
126
    $t->get_ok("//$userid:$password@/api/v1/illbatchstatuses/$non_existent_code")->status_is(404)
126
    $t->get_ok("//$userid:$password@/api/v1/ill/batchstatuses/$non_existent_code")->status_is(404)
127
        ->json_is( '/error' => 'ILL batch status not found' );
127
        ->json_is( '/error' => 'ILL batch status not found' );
128
128
129
    $schema->storage->txn_rollback;
129
    $schema->storage->txn_rollback;
Lines 161-167 subtest 'add() tests' => sub { Link Here
161
    };
161
    };
162
162
163
    # Unauthorized attempt to write
163
    # Unauthorized attempt to write
164
    $t->post_ok( "//$unauth_userid:$password@/api/v1/illbatchstatuses" => json => $status_metadata )->status_is(403);
164
    $t->post_ok( "//$unauth_userid:$password@/api/v1/ill/batchstatuses" => json => $status_metadata )->status_is(403);
165
165
166
    # Authorized attempt to write invalid data
166
    # Authorized attempt to write invalid data
167
    my $status_with_invalid_field = {
167
    my $status_with_invalid_field = {
Lines 169-175 subtest 'add() tests' => sub { Link Here
169
        doh => 1
169
        doh => 1
170
    };
170
    };
171
171
172
    $t->post_ok( "//$userid:$password@/api/v1/illbatchstatuses" => json => $status_with_invalid_field )->status_is(400)
172
    $t->post_ok( "//$userid:$password@/api/v1/ill/batchstatuses" => json => $status_with_invalid_field )->status_is(400)
173
        ->json_is(
173
        ->json_is(
174
        "/errors" => [
174
        "/errors" => [
175
            {
175
            {
Lines 181-193 subtest 'add() tests' => sub { Link Here
181
181
182
    # Authorized attempt to write
182
    # Authorized attempt to write
183
    my $status_id =
183
    my $status_id =
184
        $t->post_ok( "//$userid:$password@/api/v1/illbatchstatuses" => json => $status_metadata )->status_is(201)
184
        $t->post_ok( "//$userid:$password@/api/v1/ill/batchstatuses" => json => $status_metadata )->status_is(201)
185
        ->json_has( '/id',        'ID' )->json_has( '/name', 'Name' )->json_has( '/code', 'Code' )
185
        ->json_has( '/id',        'ID' )->json_has( '/name', 'Name' )->json_has( '/code', 'Code' )
186
        ->json_has( '/is_system', 'is_system' );
186
        ->json_has( '/is_system', 'is_system' );
187
187
188
    # Authorized attempt to create with null id
188
    # Authorized attempt to create with null id
189
    $status_metadata->{id} = undef;
189
    $status_metadata->{id} = undef;
190
    $t->post_ok( "//$userid:$password@/api/v1/illbatchstatuses" => json => $status_metadata )->status_is(400)
190
    $t->post_ok( "//$userid:$password@/api/v1/ill/batchstatuses" => json => $status_metadata )->status_is(400)
191
        ->json_has('/errors');
191
        ->json_has('/errors');
192
192
193
    $schema->storage->txn_rollback;
193
    $schema->storage->txn_rollback;
Lines 221-227 subtest 'update() tests' => sub { Link Here
221
    my $status_code = $builder->build_object( { class => 'Koha::IllbatchStatuses' } )->code;
221
    my $status_code = $builder->build_object( { class => 'Koha::IllbatchStatuses' } )->code;
222
222
223
    # Unauthorized attempt to update
223
    # Unauthorized attempt to update
224
    $t->put_ok( "//$unauth_userid:$password@/api/v1/illbatchstatuses/$status_code" => json =>
224
    $t->put_ok( "//$unauth_userid:$password@/api/v1/ill/batchstatuses/$status_code" => json =>
225
            { name => 'These are not the droids you are looking for' } )->status_is(403);
225
            { name => 'These are not the droids you are looking for' } )->status_is(403);
226
226
227
    # Attempt partial update on a PUT
227
    # Attempt partial update on a PUT
Lines 230-236 subtest 'update() tests' => sub { Link Here
230
        is_system => 0
230
        is_system => 0
231
    };
231
    };
232
232
233
    $t->put_ok( "//$userid:$password@/api/v1/illbatchstatuses/$status_code" => json => $status_with_missing_field )
233
    $t->put_ok( "//$userid:$password@/api/v1/ill/batchstatuses/$status_code" => json => $status_with_missing_field )
234
        ->status_is(400)->json_is( "/errors" => [ { message => "Missing property.", path => "/body/name" } ] );
234
        ->status_is(400)->json_is( "/errors" => [ { message => "Missing property.", path => "/body/name" } ] );
235
235
236
    # Full object update on PUT
236
    # Full object update on PUT
Lines 240-246 subtest 'update() tests' => sub { Link Here
240
        is_system => 0
240
        is_system => 0
241
    };
241
    };
242
242
243
    $t->put_ok( "//$userid:$password@/api/v1/illbatchstatuses/$status_code" => json => $status_with_updated_field )
243
    $t->put_ok( "//$userid:$password@/api/v1/ill/batchstatuses/$status_code" => json => $status_with_updated_field )
244
        ->status_is(200)->json_is( '/name' => 'Master Ploo Koon' );
244
        ->status_is(200)->json_is( '/name' => 'Master Ploo Koon' );
245
245
246
    # Authorized attempt to write invalid data
246
    # Authorized attempt to write invalid data
Lines 250-256 subtest 'update() tests' => sub { Link Here
250
        code => $status_code
250
        code => $status_code
251
    };
251
    };
252
252
253
    $t->put_ok( "//$userid:$password@/api/v1/illbatchstatuses/$status_code" => json => $status_with_invalid_field )
253
    $t->put_ok( "//$userid:$password@/api/v1/ill/batchstatuses/$status_code" => json => $status_with_invalid_field )
254
        ->status_is(400)->json_is(
254
        ->status_is(400)->json_is(
255
        "/errors" => [
255
        "/errors" => [
256
            {
256
            {
Lines 265-271 subtest 'update() tests' => sub { Link Here
265
    $status_to_delete->delete;
265
    $status_to_delete->delete;
266
266
267
    $t->put_ok(
267
    $t->put_ok(
268
        "//$userid:$password@/api/v1/illbatchstatuses/$non_existent_code" => json => $status_with_updated_field )
268
        "//$userid:$password@/api/v1/ill/batchstatuses/$non_existent_code" => json => $status_with_updated_field )
269
        ->status_is(404);
269
        ->status_is(404);
270
270
271
    $schema->storage->txn_rollback;
271
    $schema->storage->txn_rollback;
Lines 312-324 subtest 'delete() tests' => sub { Link Here
312
    );
312
    );
313
313
314
    # Unauthorized attempt to delete
314
    # Unauthorized attempt to delete
315
    $t->delete_ok( "//$unauth_userid:$password@/api/v1/illbatchstatuses/" . $non_system_status->code )->status_is(403);
315
    $t->delete_ok( "//$unauth_userid:$password@/api/v1/ill/batchstatuses/" . $non_system_status->code )->status_is(403);
316
316
317
    $t->delete_ok( "//$userid:$password@/api/v1/illbatchstatuses/" . $non_system_status->code )->status_is(204);
317
    $t->delete_ok( "//$userid:$password@/api/v1/ill/batchstatuses/" . $non_system_status->code )->status_is(204);
318
318
319
    $t->delete_ok( "//$userid:$password@/api/v1/illbatchstatuses/" . $non_system_status->code )->status_is(404);
319
    $t->delete_ok( "//$userid:$password@/api/v1/ill/batchstatuses/" . $non_system_status->code )->status_is(404);
320
320
321
    $t->delete_ok( "//$userid:$password@/api/v1/illbatchstatuses/" . $system_status->code )->status_is(400)
321
    $t->delete_ok( "//$userid:$password@/api/v1/ill/batchstatuses/" . $system_status->code )->status_is(400)
322
        ->json_is( "/errors" => [ { message => "ILL batch status cannot be deleted" } ] );
322
        ->json_is( "/errors" => [ { message => "ILL batch status cannot be deleted" } ] );
323
323
324
    $schema->storage->txn_rollback;
324
    $schema->storage->txn_rollback;
325
- 

Return to bug 30719