Bugzilla – Attachment 165788 Details for
Bug 35657
Add ability to assign tickets to librarians for catalog concerns
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35657: Add support for assignee_id to ticket_updates endpoint
Bug-35657-Add-support-for-assigneeid-to-ticketupda.patch (text/plain), 6.50 KB, created by
Martin Renvoize (ashimema)
on 2024-04-29 17:56:15 UTC
(
hide
)
Description:
Bug 35657: Add support for assignee_id to ticket_updates endpoint
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2024-04-29 17:56:15 UTC
Size:
6.50 KB
patch
obsolete
>From 2876a3d2386ddedf86602b0fd331184abbbd469d Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 28 Dec 2023 15:03:36 +0000 >Subject: [PATCH] Bug 35657: Add support for assignee_id to ticket_updates > endpoint > >This patch adds support for cross-synced ticket.assignee_id updates. > >The API allows you to set assignee directly on a ticket or via a >ticket_update. In both cases we store a ticket_update with the fine >details of when and who set the assigee. > >Signed-off-by: Paul Derscheid <paulderscheid@gmail.com> >--- > Koha/REST/V1/Tickets.pm | 27 ++++++++++++++++--- > Koha/Ticket.pm | 13 +++++++++ > Koha/Ticket/Update.pm | 13 +++++++++ > api/v1/swagger/definitions/ticket.yaml | 8 ++++++ > api/v1/swagger/definitions/ticket_update.yaml | 8 ++++++ > api/v1/swagger/paths/tickets.yaml | 2 ++ > .../prog/en/modules/cataloguing/concerns.tt | 3 ++- > 7 files changed, 69 insertions(+), 5 deletions(-) > >diff --git a/Koha/REST/V1/Tickets.pm b/Koha/REST/V1/Tickets.pm >index 17512a86d4a..5fca8e443b1 100644 >--- a/Koha/REST/V1/Tickets.pm >+++ b/Koha/REST/V1/Tickets.pm >@@ -108,12 +108,25 @@ sub update { > return $c->render_resource_not_found("Ticket") > unless $ticket; > >+ my $assignee_before = $ticket->assignee_id; > return try { > $ticket->set_from_api( $c->req->json ); > $ticket->store(); >- return $c->render( status => 200, openapi => $c->objects->to_api($ticket), ); >- } >- catch { >+ >+ # Create update if assignee changed >+ if ( $assignee_before ne $ticket->assignee_id ) { >+ my $patron = $c->stash('koha.user'); >+ my $update = { >+ user_id => $patron->id, >+ ticket_id => $ticket->id, >+ public => 0, >+ assignee_id => $ticket->assignee_id, >+ message => '' >+ }; >+ Koha::Ticket::Update->new($update)->store(); >+ } >+ return $c->render( status => 200, openapi => $c->objects->to_api($ticket) ); >+ } catch { > $c->unhandled_exception($_); > }; > } >@@ -179,7 +192,7 @@ sub add_update { > ); > } > >- # Set reporter from session >+ # Set user from session > $ticket_update->{user_id} = $patron->id; > # FIXME: We should allow impersonation at a later date to > # allow an API user to submit on behalf of a user >@@ -208,6 +221,12 @@ sub add_update { > $ticket->set( { status => $ticket_update->{status} } )->store; > } > >+ # Update ticket assignee if needed >+ if ( $ticket_update->{assignee_id} ) { >+ my $ticket = $update->ticket; >+ $ticket->set( { assignee_id => $ticket_update->{assignee_id} } )->store; >+ } >+ > # Optionally add to message_queue here to notify reporter > if ( $update->public ) { > my $notice = >diff --git a/Koha/Ticket.pm b/Koha/Ticket.pm >index 59792e24bfc..836259485a0 100644 >--- a/Koha/Ticket.pm >+++ b/Koha/Ticket.pm >@@ -47,6 +47,19 @@ sub reporter { > return Koha::Patron->_new_from_dbic($rs); > } > >+=head3 assignee >+ >+Return the patron who submitted this ticket >+ >+=cut >+ >+sub assignee { >+ my ($self) = @_; >+ my $rs = $self->_result->assignee; >+ return unless $rs; >+ return Koha::Patron->_new_from_dbic($rs); >+} >+ > =head3 resolver > > Return the user who resolved this ticket >diff --git a/Koha/Ticket/Update.pm b/Koha/Ticket/Update.pm >index dad68226f0a..6ea262997aa 100644 >--- a/Koha/Ticket/Update.pm >+++ b/Koha/Ticket/Update.pm >@@ -55,6 +55,19 @@ sub user { > return Koha::Patron->_new_from_dbic($rs); > } > >+=head3 assignee >+ >+Return the patron who is assigned at this update >+ >+=cut >+ >+sub assignee { >+ my ($self) = @_; >+ my $rs = $self->_result->assignee; >+ return unless $rs; >+ return Koha::Patron->_new_from_dbic($rs); >+} >+ > =head2 Internal methods > > =head3 to_api_mapping >diff --git a/api/v1/swagger/definitions/ticket.yaml b/api/v1/swagger/definitions/ticket.yaml >index 651a12a6e74..47c366bb784 100644 >--- a/api/v1/swagger/definitions/ticket.yaml >+++ b/api/v1/swagger/definitions/ticket.yaml >@@ -46,6 +46,14 @@ properties: > reporter_id: > type: integer > description: Internal identifier for the patron who reported the ticket >+ assignee: >+ type: >+ - object >+ - "null" >+ assignee_id: >+ type: >+ - integer >+ - "null" > resolver: > type: > - object >diff --git a/api/v1/swagger/definitions/ticket_update.yaml b/api/v1/swagger/definitions/ticket_update.yaml >index 7e956643123..7851b4a69df 100644 >--- a/api/v1/swagger/definitions/ticket_update.yaml >+++ b/api/v1/swagger/definitions/ticket_update.yaml >@@ -18,6 +18,14 @@ properties: > user_id: > type: integer > description: Internal identifier for the patron who added the update >+ assignee: >+ type: >+ - object >+ - "null" >+ assignee_id: >+ type: >+ - integer >+ - "null" > date: > type: > - string >diff --git a/api/v1/swagger/paths/tickets.yaml b/api/v1/swagger/paths/tickets.yaml >index b28dc4fca01..a76239c66f4 100644 >--- a/api/v1/swagger/paths/tickets.yaml >+++ b/api/v1/swagger/paths/tickets.yaml >@@ -24,6 +24,7 @@ > items: > type: string > enum: >+ - assignee > - reporter > - resolver > - biblio >@@ -237,6 +238,7 @@ > items: > type: string > enum: >+ - assignee > - user > - +strings > collectionFormat: csv >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt >index 5b3068d7854..556f827ec06 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt >@@ -104,6 +104,7 @@ > "url": tickets_url > }, > "embed": [ >+ "assignee", > "reporter", > "resolver", > "biblio", >@@ -162,7 +163,7 @@ > "orderable": true > }, > { >- "data": "resolver.firstname:resolver.surname:resolved_date:status", >+ "data": "assignee.firstname:assignee.surname:resolver.firstname:resolver.surname:resolved_date:status", > "render": function(data, type, row, meta) { > let result = ''; > if (row.resolved_date) { >-- >2.44.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35657
:
160365
|
160366
|
160367
|
160368
|
160369
|
160372
|
160373
|
160374
|
160375
|
160376
|
160377
|
164923
|
164924
|
164925
|
164926
|
164927
|
164928
|
164932
|
164933
|
164934
|
164935
|
164974
|
164975
|
164976
|
164977
|
165666
|
165667
|
165668
|
165669
|
165670
|
165671
|
165672
|
165673
|
165674
|
165675
|
165676
|
165677
|
165678
|
165679
|
165786
|
165787
|
165788
|
165789
|
165790
|
165791
|
165792
|
165878
|
165879
|
165880
|
165881
|
165882
|
165883
|
165884
|
165885
|
165886
|
166067