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

(-)a/Koha/REST/V1/Tickets.pm (-4 / +23 lines)
Lines 108-119 sub update { Link Here
108
    return $c->render_resource_not_found("Ticket")
108
    return $c->render_resource_not_found("Ticket")
109
        unless $ticket;
109
        unless $ticket;
110
110
111
    my $assignee_before = $ticket->assignee_id;
111
    return try {
112
    return try {
112
        $ticket->set_from_api( $c->req->json );
113
        $ticket->set_from_api( $c->req->json );
113
        $ticket->store();
114
        $ticket->store();
114
        return $c->render( status => 200, openapi => $c->objects->to_api($ticket), );
115
115
    }
116
        # Create update if assignee changed
116
    catch {
117
        if ( $assignee_before ne $ticket->assignee_id ) {
118
            my $patron = $c->stash('koha.user');
119
            my $update = {
120
                user_id     => $patron->id,
121
                ticket_id   => $ticket->id,
122
                public      => 0,
123
                assignee_id => $ticket->assignee_id,
124
                message     => ''
125
            };
126
            Koha::Ticket::Update->new($update)->store();
127
        }
128
        return $c->render( status => 200, openapi => $c->objects->to_api($ticket) );
129
    } catch {
117
        $c->unhandled_exception($_);
130
        $c->unhandled_exception($_);
118
    };
131
    };
119
}
132
}
Lines 179-185 sub add_update { Link Here
179
        );
192
        );
180
    }
193
    }
181
194
182
     # Set reporter from session
195
     # Set user from session
183
     $ticket_update->{user_id} = $patron->id;
196
     $ticket_update->{user_id} = $patron->id;
184
     # FIXME: We should allow impersonation at a later date to
197
     # FIXME: We should allow impersonation at a later date to
185
     # allow an API user to submit on behalf of a user
198
     # allow an API user to submit on behalf of a user
Lines 208-213 sub add_update { Link Here
208
            $ticket->set( { status => $ticket_update->{status} } )->store;
221
            $ticket->set( { status => $ticket_update->{status} } )->store;
209
        }
222
        }
210
223
224
        # Update ticket assignee if needed
225
        if ( $ticket_update->{assignee_id} ) {
226
            my $ticket = $update->ticket;
227
            $ticket->set( { assignee_id => $ticket_update->{assignee_id} } )->store;
228
        }
229
211
        # Optionally add to message_queue here to notify reporter
230
        # Optionally add to message_queue here to notify reporter
212
        if ( $update->public ) {
231
        if ( $update->public ) {
213
            my $notice =
232
            my $notice =
(-)a/Koha/Ticket.pm (+13 lines)
Lines 47-52 sub reporter { Link Here
47
    return Koha::Patron->_new_from_dbic($rs);
47
    return Koha::Patron->_new_from_dbic($rs);
48
}
48
}
49
49
50
=head3 assignee
51
52
Return the patron who submitted this ticket
53
54
=cut
55
56
sub assignee {
57
    my ($self) = @_;
58
    my $rs = $self->_result->assignee;
59
    return unless $rs;
60
    return Koha::Patron->_new_from_dbic($rs);
61
}
62
50
=head3 resolver
63
=head3 resolver
51
64
52
Return the user who resolved this ticket
65
Return the user who resolved this ticket
(-)a/Koha/Ticket/Update.pm (+13 lines)
Lines 55-60 sub user { Link Here
55
    return Koha::Patron->_new_from_dbic($rs);
55
    return Koha::Patron->_new_from_dbic($rs);
56
}
56
}
57
57
58
=head3 assignee
59
60
Return the patron who is assigned at this update
61
62
=cut
63
64
sub assignee {
65
    my ($self) = @_;
66
    my $rs = $self->_result->assignee;
67
    return unless $rs;
68
    return Koha::Patron->_new_from_dbic($rs);
69
}
70
58
=head2 Internal methods
71
=head2 Internal methods
59
72
60
=head3 to_api_mapping
73
=head3 to_api_mapping
(-)a/api/v1/swagger/definitions/ticket.yaml (+8 lines)
Lines 46-51 properties: Link Here
46
  reporter_id:
46
  reporter_id:
47
    type: integer
47
    type: integer
48
    description: Internal identifier for the patron who reported the ticket
48
    description: Internal identifier for the patron who reported the ticket
49
  assignee:
50
    type:
51
      - object
52
      - "null"
53
  assignee_id:
54
    type:
55
      - integer
56
      - "null"
49
  resolver:
57
  resolver:
50
    type:
58
    type:
51
      - object
59
      - object
(-)a/api/v1/swagger/definitions/ticket_update.yaml (+8 lines)
Lines 18-23 properties: Link Here
18
  user_id:
18
  user_id:
19
    type: integer
19
    type: integer
20
    description: Internal identifier for the patron who added the update
20
    description: Internal identifier for the patron who added the update
21
  assignee:
22
    type:
23
      - object
24
      - "null"
25
  assignee_id:
26
    type:
27
      - integer
28
      - "null"
21
  date:
29
  date:
22
    type:
30
    type:
23
      - string
31
      - string
(-)a/api/v1/swagger/paths/tickets.yaml (+2 lines)
Lines 24-29 Link Here
24
        items:
24
        items:
25
          type: string
25
          type: string
26
          enum:
26
          enum:
27
            - assignee
27
            - reporter
28
            - reporter
28
            - resolver
29
            - resolver
29
            - biblio
30
            - biblio
Lines 237-242 Link Here
237
        items:
238
        items:
238
          type: string
239
          type: string
239
          enum:
240
          enum:
241
            - assignee
240
            - user
242
            - user
241
            - +strings
243
            - +strings
242
        collectionFormat: csv
244
        collectionFormat: csv
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt (-2 / +2 lines)
Lines 104-109 Link Here
104
                    "url": tickets_url
104
                    "url": tickets_url
105
                },
105
                },
106
                "embed": [
106
                "embed": [
107
                    "assignee",
107
                    "reporter",
108
                    "reporter",
108
                    "resolver",
109
                    "resolver",
109
                    "biblio",
110
                    "biblio",
Lines 162-168 Link Here
162
                        "orderable": true
163
                        "orderable": true
163
                    },
164
                    },
164
                    {
165
                    {
165
                        "data": "resolver.firstname:resolver.surname:resolved_date:status",
166
                        "data": "assignee.firstname:assignee.surname:resolver.firstname:resolver.surname:resolved_date:status",
166
                        "render": function(data, type, row, meta) {
167
                        "render": function(data, type, row, meta) {
167
                            let result = '';
168
                            let result = '';
168
                            if (row.resolved_date) {
169
                            if (row.resolved_date) {
169
- 

Return to bug 35657