Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(BB-806): add validation for float values in width, height, depth fields #1137

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
/reports
/config/config.json
/config/config.local.json
/config.json

# Directory designated to store local compose overrides and related files
/local/
Expand Down
49 changes: 0 additions & 49 deletions config/config.json.example

This file was deleted.

92 changes: 92 additions & 0 deletions sql/migrations/2024-02-07-credit-section/up.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,98 @@
------------------------------------------------------------------------


---------------------- ****** NOTICE ****** ----------------------
-- Don't forget to run the create_trigger.sql script afterwards --
------------------------------------------------------------------

BEGIN TRANSACTION;

-- Adding credit_section column in edition_data and edition_group_data table and intitalizing it with true
ALTER TABLE bookbrainz.edition_data ADD COLUMN credit_section BOOLEAN DEFAULT TRUE;
ALTER TABLE bookbrainz.edition_group_data ADD COLUMN credit_section BOOLEAN DEFAULT TRUE;

DROP VIEW IF EXISTS
bookbrainz.edition,
bookbrainz.edition_group;

-- Recreate the view with the new definition
-- Adding credit_section column in edition view and edition_group view
CREATE VIEW bookbrainz.edition AS
SELECT e.bbid,
edd.id AS data_id,
edr.id AS revision_id,
edr.id = edh.master_revision_id AS master,
edd.annotation_id,
edd.disambiguation_id,
dis.comment AS disambiguation,
als.default_alias_id,
al.name,
al.sort_name,
edd.edition_group_bbid,
edd.author_credit_id,
edd.width,
edd.height,
edd.depth,
edd.weight,
edd.pages,
edd.format_id,
edd.status_id,
edd.alias_set_id,
edd.identifier_set_id,
edd.relationship_set_id,
edd.language_set_id,
edd.release_event_set_id,
edd.publisher_set_id,
edd.credit_section,
e.type
FROM bookbrainz.edition_revision edr
LEFT JOIN bookbrainz.entity e ON e.bbid = edr.bbid
LEFT JOIN bookbrainz.edition_header edh ON edh.bbid = e.bbid
LEFT JOIN bookbrainz.edition_data edd ON edr.data_id = edd.id
LEFT JOIN bookbrainz.alias_set als ON edd.alias_set_id = als.id
LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id
LEFT JOIN bookbrainz.disambiguation dis ON dis.id = edd.disambiguation_id
WHERE e.type = 'Edition';

CREATE VIEW bookbrainz.edition_group AS
SELECT e.bbid,
egd.id AS data_id,
pcr.id AS revision_id,
pcr.id = egh.master_revision_id AS master,
egd.annotation_id,
egd.disambiguation_id,
dis.comment AS disambiguation,
als.default_alias_id,
al.name,
al.sort_name,
egd.type_id,
egtype.label AS edition_group_type,
egd.author_credit_id,
egd.alias_set_id,
egd.identifier_set_id,
egd.relationship_set_id,
egd.credit_section,
e.type
FROM bookbrainz.edition_group_revision pcr
LEFT JOIN bookbrainz.entity e ON e.bbid = pcr.bbid
LEFT JOIN bookbrainz.edition_group_header egh ON egh.bbid = e.bbid
LEFT JOIN bookbrainz.edition_group_data egd ON pcr.data_id = egd.id
LEFT JOIN bookbrainz.alias_set als ON egd.alias_set_id = als.id
LEFT JOIN bookbrainz.alias al ON al.id = als.default_alias_id
LEFT JOIN bookbrainz.disambiguation dis ON dis.id = egd.disambiguation_id
LEFT JOIN bookbrainz.edition_group_type egtype ON egtype.id = egd.type_id
WHERE e.type = 'EditionGroup';

---------------------- ****** NOTICE ****** ----------------------
-- Don't forget to run the create_trigger.sql script afterwards --
------------------------------------------------------------------

COMMIT TRANSACTION;
-----------------------------------------------------------------------
-- Adds a credit_section boolean column to edition_data and edition_group_data to make author credits optional --
------------------------------------------------------------------------


---------------------- ****** NOTICE ****** ----------------------
-- Don't forget to run the create_trigger.sql script afterwards --
------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,13 @@ function mapDispatchToProps(dispatch: Dispatch<Action>): DispatchProps {
dispatch(updateAuthorCredit(selectedAuthorCredit));
},
onDepthChange: (event) => dispatch(debouncedUpdateDepth(
event.target.value ? parseInt(event.target.value, 10) : null
event.target.value ? parseFloat(event.target.value) : null
)),
onEditionGroupChange: (value) => dispatch(updateEditionGroup(value)),
onFormatChange: (value: number) =>
dispatch(updateFormat(value)),
onHeightChange: (event) => dispatch(debouncedUpdateHeight(
event.target.value ? parseInt(event.target.value, 10) : null
event.target.value ? parseFloat(event.target.value) : null
)),
onPagesChange: (event) => dispatch(debouncedUpdatePages(
event.target.value ? parseInt(event.target.value, 10) : null
Expand All @@ -353,7 +353,7 @@ function mapDispatchToProps(dispatch: Dispatch<Action>): DispatchProps {
event.target.value ? parseInt(event.target.value, 10) : null
)),
onWidthChange: (event) => dispatch(debouncedUpdateWidth(
event.target.value ? parseInt(event.target.value, 10) : null
event.target.value ? parseFloat(event.target.value) : null
))
};
}
Expand Down
6 changes: 3 additions & 3 deletions src/client/entity-editor/edition-section/edition-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -513,7 +513,7 @@ function mapStateToProps(rootState: RootState): StateProps {
function mapDispatchToProps(dispatch: Dispatch<Action>): DispatchProps {
return {
onDepthChange: (event) => dispatch(debouncedUpdateDepth(
event.target.value ? parseInt(event.target.value, 10) : null
event.target.value ? parseFloat(event.target.value) : null
)),
onEditionGroupChange: (value, action) => {
// If the user selected a new edition group, we need to clear the old one
Expand All @@ -532,7 +532,7 @@ function mapDispatchToProps(dispatch: Dispatch<Action>): DispatchProps {
}
},
onHeightChange: (event) => dispatch(debouncedUpdateHeight(
event.target.value ? parseInt(event.target.value, 10) : null
event.target.value ? parseFloat(event.target.value) : null
)),
onLanguagesChange: (values: Array<LanguageOption>) =>
dispatch(updateLanguages(values)),
Expand All @@ -554,7 +554,7 @@ function mapDispatchToProps(dispatch: Dispatch<Action>): DispatchProps {
event.target.value ? parseInt(event.target.value, 10) : null
)),
onWidthChange: (event) => dispatch(debouncedUpdateWidth(
event.target.value ? parseInt(event.target.value, 10) : null
event.target.value ? parseFloat(event.target.value) : null
))
};
}
Expand Down
1 change: 0 additions & 1 deletion src/client/entity-editor/submission-section/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import _ from 'lodash';
import {filterObject} from '../../../common/helpers/utils';
import request from 'superagent';


export const SET_SUBMIT_ERROR = 'SET_SUBMIT_ERROR';
export const UPDATE_REVISION_NOTE = 'UPDATE_REVISION_NOTE';
export const SET_SUBMITTED = 'SET_SUBMITTED';
Expand Down
Loading