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

(-)a/Koha/REST/V1/RecordSources.pm (+38 lines)
Lines 81-86 sub add { Link Here
81
            openapi => $c->objects->to_api($source)
81
            openapi => $c->objects->to_api($source)
82
        );
82
        );
83
    } catch {
83
    } catch {
84
        if ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
85
            return $c->render(
86
                status  => 409,
87
                openapi => { error => 'Duplicate name.' }
88
            );
89
        } elsif ( blessed $_ and $_->isa('Koha::Exceptions::BadParameter') ) {
90
            return $c->render(
91
                status  => 409,
92
                openapi => { error => 'Name not allowed.' }
93
            );
94
        }
84
        $c->unhandled_exception($_);
95
        $c->unhandled_exception($_);
85
    };
96
    };
86
}
97
}
Lines 97-107 sub update { Link Here
97
    return $c->render_resource_not_found("Record source")
108
    return $c->render_resource_not_found("Record source")
98
        unless $source;
109
        unless $source;
99
110
111
    if ( $source->is_system ) {
112
        return $c->render(
113
            status  => 409,
114
            openapi => { error => 'Cannot edit system defined value.' }
115
        );
116
    }
117
100
    return try {
118
    return try {
101
        $source->set_from_api( $c->req->json )->store;
119
        $source->set_from_api( $c->req->json )->store;
102
        $source->discard_changes;
120
        $source->discard_changes;
103
        return $c->render( status => 200, openapi => $c->objects->to_api($source) );
121
        return $c->render( status => 200, openapi => $c->objects->to_api($source) );
104
    } catch {
122
    } catch {
123
        if ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
124
            return $c->render(
125
                status  => 409,
126
                openapi => { error => 'Duplicate name.' }
127
            );
128
        } elsif ( blessed $_ and $_->isa('Koha::Exceptions::BadParameter') ) {
129
            return $c->render(
130
                status  => 409,
131
                openapi => { error => 'Name not allowed.' }
132
            );
133
        }
105
        $c->unhandled_exception($_);
134
        $c->unhandled_exception($_);
106
    };
135
    };
107
}
136
}
Lines 131-136 sub delete { Link Here
131
                }
160
                }
132
            );
161
            );
133
        }
162
        }
163
        elsif ( blessed $_ and $_->isa('Koha::Exceptions::CannotDeleteDefault') ) {
164
            return $c->render(
165
                status  => 409,
166
                openapi => {
167
                    error => 'Cannot delete system defined record source',
168
                    error_code => 'cannot_delete_is_system',
169
                }
170
            );
171
        }
134
        $c->unhandled_exception($_);
172
        $c->unhandled_exception($_);
135
    };
173
    };
136
}
174
}
(-)a/Koha/RecordSource.pm (+11 lines)
Lines 46-51 sub usage_count { Link Here
46
    return $self->_result->biblio_metadatas->count();
46
    return $self->_result->biblio_metadatas->count();
47
}
47
}
48
48
49
=head3 store
50
51
=cut
52
53
sub store {
54
    my ($self) = @_;
55
    Koha::Exceptions::BadParameter->throw( '* not allowed' ) if $self->name eq '*';
56
57
    return $self->SUPER::store;
58
}
59
49
=head3 delete
60
=head3 delete
50
61
51
Overridden delete method to prevent system default deletions
62
Overridden delete method to prevent system default deletions
(-)a/admin/marc-overlay-rules.pl (+5 lines)
Lines 26-31 use C4::Output qw( output_html_with_http_headers ); Link Here
26
use C4::ImportBatch;
26
use C4::ImportBatch;
27
use Koha::MarcOverlayRules;
27
use Koha::MarcOverlayRules;
28
use Koha::Patron::Categories;
28
use Koha::Patron::Categories;
29
use Koha::RecordSources;
29
30
30
my $input = CGI->new;
31
my $input = CGI->new;
31
my $op = $input->param('op') || '';
32
my $op = $input->param('op') || '';
Lines 124-132 elsif ($op eq 'cud-edit' || $op eq 'cud-add') { Link Here
124
my $categories = Koha::Patron::Categories->search_with_library_limits( {},
125
my $categories = Koha::Patron::Categories->search_with_library_limits( {},
125
    { order_by => ['description'], columns => [ 'categorycode', 'description' ] } )->unblessed;
126
    { order_by => ['description'], columns => [ 'categorycode', 'description' ] } )->unblessed;
126
127
128
my @record_sources =
129
  map { $_->{name} } @{ Koha::RecordSources->search->unblessed };
130
127
$template->param(
131
$template->param(
128
    rules      => $rules,
132
    rules      => $rules,
129
    categories => $categories,
133
    categories => $categories,
134
    record_sources => \@record_sources,
130
    messages   => $errors
135
    messages   => $errors
131
);
136
);
132
137
(-)a/api/v1/swagger/definitions/record_source.yaml (-1 lines)
Lines 17-23 properties: Link Here
17
  is_system:
17
  is_system:
18
    description: Is this record source system or not
18
    description: Is this record source system or not
19
    type: boolean
19
    type: boolean
20
    readOnly: true
21
additionalProperties: false
20
additionalProperties: false
22
required:
21
required:
23
  - name
22
  - name
(-)a/api/v1/swagger/paths/record_sources.yaml (+15 lines)
Lines 97-102 Link Here
97
        description: Not allowed
97
        description: Not allowed
98
        schema:
98
        schema:
99
          $ref: "../swagger.yaml#/definitions/error"
99
          $ref: "../swagger.yaml#/definitions/error"
100
      "409":
101
        description: |
102
          Conflict creating the resource. Possible `error_code` attribute values:
103
104
          * `duplicate`
105
        schema:
106
          $ref: "../swagger.yaml#/definitions/error"
100
      "500":
107
      "500":
101
        description: |
108
        description: |
102
          Internal server error. Possible `error_code` attribute values:
109
          Internal server error. Possible `error_code` attribute values:
Lines 198-203 Link Here
198
        description: Not found
205
        description: Not found
199
        schema:
206
        schema:
200
          $ref: "../swagger.yaml#/definitions/error"
207
          $ref: "../swagger.yaml#/definitions/error"
208
      "409":
209
        description: |
210
          Conflict creating the resource. Possible `error_code` attribute values:
211
212
          * `duplicate`
213
        schema:
214
          $ref: "../swagger.yaml#/definitions/error"
201
      "500":
215
      "500":
202
        description: |
216
        description: |
203
          Internal server error. Possible `error_code` attribute values:
217
          Internal server error. Possible `error_code` attribute values:
Lines 248-253 Link Here
248
          Conflict in deleting resource. Possible `error_code` attribute values:
262
          Conflict in deleting resource. Possible `error_code` attribute values:
249
263
250
          * `cannot_delete_used`: record source linked to a record cannot be deleted.
264
          * `cannot_delete_used`: record source linked to a record cannot be deleted.
265
          * `cannot_delete_is_system`: record source is system defined and cannot be deleted.
251
        schema:
266
        schema:
252
          $ref: "../swagger.yaml#/definitions/error"
267
          $ref: "../swagger.yaml#/definitions/error"
253
      "500":
268
      "500":
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/marc-overlay-rules.tt (-7 / +11 lines)
Lines 474-485 Link Here
474
        var module_filter_options = {
474
        var module_filter_options = {
475
        source: {
475
        source: {
476
            '*': '*',
476
            '*': '*',
477
            batchmod: _("Batch record modification"),
477
            [% FOREACH record_source IN record_sources %]
478
            intranet: _("Staff interface MARC editor"),
478
                [% SWITCH record_source %]
479
            batchimport: _("Staged MARC import"),
479
                  [% CASE 'batchmod' %]'[% record_source %]': _("Batch record modification"),
480
            z3950: _("Z39.50"),
480
                  [% CASE 'intranet' %]'[% record_source %]':_("Staff interface MARC editor"),
481
            bulkmarcimport: _("bulkmarcimport.pl"),
481
                  [% CASE 'batchimport' %]'[% record_source %]': _("Staged MARC import"),
482
            import_lexile: _("import_lexile.pl")
482
                  [% CASE 'z3950' %]'[% record_source %]': _("Z39.50"),
483
                  [% CASE 'bulkmarkimport' %]'[% record_source %]': _("bulkmarcimport.pl"),
484
                  [% CASE 'import_lexile' %]'[% record_source %]':  _("import_lexile.pl"),
485
                  [% CASE %] '[% record_source %]' : '[% record_source | html %]',
486
                [% END %]
487
            [% END %]
483
        },
488
        },
484
489
485
            categorycode: categories,
490
            categorycode: categories,
486
- 

Return to bug 35380