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

(-)a/Koha/Catalog/Concern.pm (+36 lines)
Lines 69-74 sub biblio { Link Here
69
    return Koha::Biblio->_new_from_dbic( $rs );
69
    return Koha::Biblio->_new_from_dbic( $rs );
70
}
70
}
71
71
72
=head3 resolve
73
74
  $concern = $concern->resolve(
75
    {
76
        resolver => $user,
77
        notify   => $boolean,
78
        message  => $message
79
    }
80
  );
81
82
Method to mark a concern as resolved
83
84
=cut
85
86
sub resolve {
87
    my ( $self, $params ) = @_;
88
89
    my $resolver = $params->{resolver};
90
    my $message = $params->{message};
91
92
    $self->set(
93
        {
94
            resolved_date      => \'NOW()',
95
            resolver_id        => $resolver->borrowernumber,
96
            resolution_message => $message
97
        }
98
    )->store();
99
100
    # Optionally add to message_queue here to notify reporter
101
    if ( $params->{notify} ) {
102
103
    }
104
105
    return $self;
106
}
107
72
=head2 Internal methods
108
=head2 Internal methods
73
109
74
=cut
110
=cut
(-)a/Koha/REST/V1/Catalog/Concerns.pm (-2 / +45 lines)
Lines 99-106 sub update { Link Here
99
    my $concern = Koha::Catalog::Concerns->find( $c->validation->param('concern_id') );
99
    my $concern = Koha::Catalog::Concerns->find( $c->validation->param('concern_id') );
100
100
101
    if ( not defined $concern ) {
101
    if ( not defined $concern ) {
102
        return $c->render( status  => 404,
102
        return $c->render(
103
                           openapi => { error => "Object not found" } );
103
            status  => 404,
104
            openapi => { error => "Object not found" }
105
        );
104
    }
106
    }
105
107
106
    return try {
108
    return try {
Lines 138-141 sub delete { Link Here
138
    };
140
    };
139
}
141
}
140
142
143
=head3 resolve
144
145
Resolve action, sets the catalog concern to resolved and optionally sends the submitter a notification.
146
147
=cut
148
149
sub resolve {
150
    my $c = shift->openapi->valid_input or return;
151
152
    my $concern =
153
      Koha::Catalog::Concerns->find( $c->validation->param('concern_id') );
154
155
    if ( not defined $concern ) {
156
        return $c->render(
157
            status  => 404,
158
            openapi => { error => "Object not found" }
159
        );
160
    }
161
162
    my $resolver = $c->stash('koha.user');
163
    my $body     = $c->validation->param('body');
164
    my $notify   = $body->{notify};
165
    my $message  = $body->{message};
166
    return try {
167
        $concern->resolve(
168
            {
169
                resolver => $resolver,
170
                notify   => $notify,
171
                message  => $message
172
            }
173
        );
174
        return $c->render(
175
            status  => 204,
176
            openapi => q{}
177
        );
178
    }
179
    catch {
180
        $c->unhandled_exception($_);
181
    }
182
}
183
141
1;
184
1;
(-)a/api/v1/swagger/definitions/resolution.yaml (+10 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  message:
5
    description: Resolution message
6
    type: string
7
  notify:
8
    description: Signal to notify the user
9
    type: boolean
10
additionalProperties: true
(-)a/api/v1/swagger/paths/catalog_concerns.yaml (+43 lines)
Lines 210-215 Link Here
210
    x-koha-authorization:
210
    x-koha-authorization:
211
      permissions:
211
      permissions:
212
        editcatalogue: edit_catalogue
212
        editcatalogue: edit_catalogue
213
"/catalog/concerns/{concern_id}/resolve":
214
  post:
215
    x-mojo-to: Catalog::Concerns#resolve
216
    operationId: resolveConcern
217
    tags:
218
      - concerns
219
    summary: Resolve the concern
220
    parameters:
221
      - $ref: "../swagger.yaml#/parameters/concern_id_pp"
222
      - name: body
223
        in: body
224
        description: A resolution object
225
        required: true
226
        schema:
227
          $ref: "../swagger.yaml#/definitions/resolution"
228
    produces:
229
      - application/json
230
    responses:
231
      "204":
232
        description: Concern resolved
233
      "401":
234
        description: Authentication required
235
        schema:
236
          $ref: "../swagger.yaml#/definitions/error"
237
      "403":
238
        description: Access forbidden
239
        schema:
240
          $ref: "../swagger.yaml#/definitions/error"
241
      "404":
242
        description: Concern not found
243
        schema:
244
          $ref: "../swagger.yaml#/definitions/error"
245
      "500":
246
        description: Internal error
247
        schema:
248
          $ref: "../swagger.yaml#/definitions/error"
249
      "503":
250
        description: Under maintenance
251
        schema:
252
          $ref: "../swagger.yaml#/definitions/error"
253
    x-koha-authorization:
254
      permissions:
255
        editcatalogue: edit_catalogue
213
/public/catalog/concerns:
256
/public/catalog/concerns:
214
  post:
257
  post:
215
    x-mojo-to: Catalog::Concerns#add
258
    x-mojo-to: Catalog::Concerns#add
(-)a/api/v1/swagger/swagger.yaml (-1 / +4 lines)
Lines 66-71 definitions: Link Here
66
    $ref: ./definitions/renewal.yaml
66
    $ref: ./definitions/renewal.yaml
67
  renewals:
67
  renewals:
68
    $ref: ./definitions/renewals.yaml
68
    $ref: ./definitions/renewals.yaml
69
  resolution:
70
    $ref: ./definitions/resolution.yaml
69
  return_claim:
71
  return_claim:
70
    $ref: ./definitions/return_claim.yaml
72
    $ref: ./definitions/return_claim.yaml
71
  smtp_server:
73
  smtp_server:
Lines 129-134 paths: Link Here
129
    $ref: "./paths/catalog_concerns.yaml#/~1catalog~1concerns"
131
    $ref: "./paths/catalog_concerns.yaml#/~1catalog~1concerns"
130
  "/catalog/concerns/{concern_id}":
132
  "/catalog/concerns/{concern_id}":
131
    $ref: "./paths/catalog_concerns.yaml#/~1catalog~1concerns~1{concern_id}"
133
    $ref: "./paths/catalog_concerns.yaml#/~1catalog~1concerns~1{concern_id}"
134
  "/catalog/concerns/{concern_id}/resolve":
135
    $ref: "./paths/catalog_concerns.yaml#/~1catalog~1concerns~1{concern_id}~1resolve"
132
  /checkouts:
136
  /checkouts:
133
    $ref: ./paths/checkouts.yaml#/~1checkouts
137
    $ref: ./paths/checkouts.yaml#/~1checkouts
134
  "/checkouts/{checkout_id}":
138
  "/checkouts/{checkout_id}":
135
- 

Return to bug 31028