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

(-)a/Koha/REST/V1/Biblios.pm (-1 / +46 lines)
Lines 22-27 use Mojo::Base 'Mojolicious::Controller'; Link Here
22
use Koha::Biblios;
22
use Koha::Biblios;
23
use Koha::DateUtils;
23
use Koha::DateUtils;
24
use Koha::Ratings;
24
use Koha::Ratings;
25
use Koha::RecordSources;
25
use C4::Biblio qw( DelBiblio AddBiblio ModBiblio );
26
use C4::Biblio qw( DelBiblio AddBiblio ModBiblio );
26
use C4::Search qw( FindDuplicate );
27
use C4::Search qw( FindDuplicate );
27
28
Lines 762-768 sub update { Link Here
762
            );
763
            );
763
        }
764
        }
764
765
765
        ModBiblio( $record, $biblio->id, $frameworkcode );
766
        my $record_source_id = $headers->header('x-record-source-id');
767
768
        my $options = {};
769
770
        if ($record_source_id) {
771
772
            # We've been passed a record source. Verify they are allowed to
773
            unless (
774
                haspermission(
775
                    $c->stash('koha.user')->userid,
776
                    { editcatalogue => 'set_record_sources' }
777
                )
778
              )
779
            {
780
                return $c->render(
781
                    status  => 403,
782
                    openapi => {
783
                        error =>
784
                          'You do not have permission to set the record source'
785
                    }
786
                );
787
            }
788
789
            # find record source name to given id
790
            my $record_source = Koha::RecordSources->search(
791
                { record_source_id => $record_source_id } )->single;
792
793
            unless ($record_source) {
794
                return $c->render(
795
                    status  => 409,
796
                    openapi =>
797
                      { error => 'Given record_source_id does not exist' }
798
                );
799
            }
800
801
            $options->{'overlay_context'}  = { source => $record_source->name };
802
            $options->{'record_source_id'} = $record_source_id;
803
        }
804
805
        unless ( $options->{'overlay_context'}->{'source'} ) {
806
            $options->{'overlay_context'} = { source => '*' };
807
        }
808
809
        ModBiblio( $record, $biblio->id, $frameworkcode, $options );
810
766
811
767
        $c->render(
812
        $c->render(
768
            status  => 200,
813
            status  => 200,
(-)a/api/v1/swagger/paths/biblios.yaml (-1 / +5 lines)
Lines 248-253 Link Here
248
      - $ref: "../swagger.yaml#/parameters/framework_id_header"
248
      - $ref: "../swagger.yaml#/parameters/framework_id_header"
249
      - $ref: "../swagger.yaml#/parameters/marc_schema_header"
249
      - $ref: "../swagger.yaml#/parameters/marc_schema_header"
250
      - $ref: "../swagger.yaml#/parameters/confirm_not_duplicate_header"
250
      - $ref: "../swagger.yaml#/parameters/confirm_not_duplicate_header"
251
      - $ref: "../swagger.yaml#/parameters/record_source_id_header"
251
    produces:
252
    produces:
252
      - application/json
253
      - application/json
253
    responses:
254
    responses:
Lines 276-281 Link Here
276
          description: Accepted content-types
277
          description: Accepted content-types
277
          items:
278
          items:
278
            type: string
279
            type: string
280
      "409":
281
        description: Conflict
282
        schema:
283
          $ref: "../swagger.yaml#/definitions/error"
279
      "500":
284
      "500":
280
        description: |
285
        description: |
281
          Internal server error. Possible `error_code` attribute values:
286
          Internal server error. Possible `error_code` attribute values:
282
- 

Return to bug 35380