From 14d0f55fa8ea655163b6c8915b2c6e2580119438 Mon Sep 17 00:00:00 2001 From: ecourtial Date: Wed, 22 Mar 2023 20:11:08 +0100 Subject: [PATCH 1/3] Added new support types: Blu-ray, MINI-Blu-ray and External drive --- CHANGELOG.md | 3 +++ docs/RESOURCES.md | 3 +++ docs/SETUP.md | 2 +- src/entity/copy.py | 3 +++ 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 75640e9..b8accee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## 4.2.0 +* Added new support types: Blu-ray, MINI-Blu-ray, External drive. + ## 4.1.1 * Security updates. diff --git a/docs/RESOURCES.md b/docs/RESOURCES.md index ae5d377..aa00024 100644 --- a/docs/RESOURCES.md +++ b/docs/RESOURCES.md @@ -137,9 +137,11 @@ The application relies on 6 resources (not including the users). | Value | Meaning | |----------------------|------------------------------------------------| +|Blu-ray | | |DVD-ROM | | |CD-ROM | | |GD-ROM | | +|MINI-Blu-ray | | |MINI-DVD-ROM | | |MINI-CD-ROM | | |Cartridge | | @@ -147,6 +149,7 @@ The application relies on 6 resources (not including the users). |5.25-inch floppy | | |Other disc | | |Other floppy | | +|External drive | | |None | | ### Allowed types for _status_ diff --git a/docs/SETUP.md b/docs/SETUP.md index fa1a090..ed5ec93 100644 --- a/docs/SETUP.md +++ b/docs/SETUP.md @@ -2,7 +2,7 @@ ## Locally (DEV) -In the root folder, copy the file _configuration.json.dist_ to _configuration.json_ and fill it with your values (the Google Captcha values are mandatory). The MySQL credentials are visible in the _docker-compose.yml_ in the root folder. +In the root folder, copy the file _configuration.json.dist_ to _configuration.json_ and fill it with your values. The MySQL credentials are visible in the _docker-compose.yml_ in the root folder. Next, just do a __make start__, and then run __make test__ to run the tests and import the local DB with test features. You're good to go! diff --git a/src/entity/copy.py b/src/entity/copy.py index c4e1708..fab8223 100644 --- a/src/entity/copy.py +++ b/src/entity/copy.py @@ -50,9 +50,11 @@ class Copy(AbstractEntity): 'required': True, 'type': 'strict-text', 'allowed_values': { + 'Blu-ray', 'DVD-ROM', 'CD-ROM', 'GD-ROM', + 'MINI-Blu-ray' 'MINI-DVD-ROM', 'MINI-CD-ROM', 'Cartridge', @@ -60,6 +62,7 @@ class Copy(AbstractEntity): '5.25-inch floppy', 'Other disc', 'Other floppy', + 'External drive', 'None' } }, From e55db15159af9e90c808bc67c6ea18865fad4726 Mon Sep 17 00:00:00 2001 From: ecourtial Date: Wed, 22 Mar 2023 21:14:28 +0100 Subject: [PATCH 2/3] Added a new field for copies: region (PAL, NTSC...) --- CHANGELOG.md | 1 + docs/API.md | 24 +++++++++++++++++++++++- docs/RESOURCES.md | 14 +++++++++++++- games_empty.sql | 1 + migrations/4.2.0.sql | 1 + src/entity/copy.py | 20 ++++++++++++++++++++ test/functional/test_copies.py | 4 ++++ test/functional/test_transactions.py | 7 +++++-- test/games_test.sql | 3 ++- 9 files changed, 70 insertions(+), 5 deletions(-) create mode 100644 migrations/4.2.0.sql diff --git a/CHANGELOG.md b/CHANGELOG.md index b8accee..ff1dab3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ ## 4.2.0 * Added new support types: Blu-ray, MINI-Blu-ray, External drive. +* Added region type for a copy: PAL, JAP... The migration is included, setting the default value to PAL. ## 4.1.1 * Security updates. diff --git a/docs/API.md b/docs/API.md index 22d7fe0..74cc5f5 100644 --- a/docs/API.md +++ b/docs/API.md @@ -78,9 +78,31 @@ A numeric field can also be used for sorting. Let's look at the following exampl Here you want to get all the versions (with the defaut pagination: first page, max result limit set to 30) but only the ones who have copies (hence the > 0 operator). -| API syntax | Signification | Example | +| API syntax | Meaning | Example | |------------|---------------|--------------------------------| |lt |Lesser than |```versions?copyCount[]=lt-2``` | |gt |Greater than |```versions?copyCount[]=gt-1``` | |eq |Equal |```versions?copyCount[]=eq-1``` | |neq |Not equal |```versions?copyCount[]=neq-1```| + +### 4- API error codes + +When something goes wrong, we try to handle it with a specific exception and a specific error code so you can act properly on your side. These exception are located in the _src/exception_ folder. Below are the error codes. + +| Code | Title | Meaning | +|-------|------------------------------------|------------------------------------------------------------------------------------------------------| +| 1 | Resource not found | | +| 2 | Invalid credentials | | +| 3 | Inactive user | | +| 4 | Inconsistant transaction operation | Raised when you try, for instance, to sold a copy you don't have | +| 5 | Invalid input | Raised when the expected value is not good, inconsistent... | +| 6 | Missing mandatory field value | | +| 7 | Missing mandatory header | | +| 8 | Resource already exists | | +| 9 | Resource has children | Raised when the resource has children, for instance a version of a game has stories | +| 10 | Unsupported filter | | +| 11 | Unsupported value | | +| 12 | Missing authentication token | | +| 13 | Authentication token is invalid | | +| 14 | Inconsistant version and copy | Raised when you try to create a transaction for which version_id and the copy version_id don't match | +| 15 | Duplicate consecutive operation | Raised when you try, for instance, to create two consecutive inbound transaction | diff --git a/docs/RESOURCES.md b/docs/RESOURCES.md index aa00024..c287f36 100644 --- a/docs/RESOURCES.md +++ b/docs/RESOURCES.md @@ -102,7 +102,8 @@ The application relies on 6 resources (not including the users). | boxType | string| Yes | No | Type of the box (See allowed types below). | | | casingType | string| Yes | No | Casing type of the box (See allowed types below). | | | supportType | string| Yes | No | The game support type (See allowed types below). | | -| onCompilation | bool | Yes | No | Is the copy of the game on a compilation? | | +| onCompilation | bool | Yes | No | Is the copy of the game on a compilation? | +| region | string | Yes | No | Region lock of the game? (See allowed types below). | | | reedition | bool | Yes | No | Is the copy of the game on a reedition, like a platinum, a classic one? | | | hasManual | bool | Yes | No | Does the copy has a manual? | | | status | string| Yes | No | Do you currently have this copy (See allowed types below)? | | @@ -166,6 +167,17 @@ The application relies on 6 resources (not including the users). |Physical | The copy is physical. | |Virtual | The copy is virtual (ex: bought on _Steam_). | + +### Allowed types for _region_ + +| Value | Meaning | +|----------------------|------------------------------------------------| +|PAL | Europe, New Zealand, Australia, Middle East, India, South Africa | +|JAP | Japan and Asia (NTSC-J) | +|NTSC | North America and South America (NTSC-U) | +|CHINA | China (NTSC-C) | + + ## Transaction | Field | Type | Editable | Unique | Role | Notes | diff --git a/games_empty.sql b/games_empty.sql index 9ada2d4..5ebfbf8 100644 --- a/games_empty.sql +++ b/games_empty.sql @@ -35,6 +35,7 @@ CREATE TABLE `copies` ( `has_manual` tinyint unsigned NOT NULL, `status` varchar(255) NOT NULL DEFAULT 'In', `type` varchar(255) NOT NULL, + `region` varchar(255) NOT NULL, `comments` text, PRIMARY KEY (`copy_id`), KEY `version_id` (`version_id`), diff --git a/migrations/4.2.0.sql b/migrations/4.2.0.sql new file mode 100644 index 0000000..5a75b83 --- /dev/null +++ b/migrations/4.2.0.sql @@ -0,0 +1 @@ +ALTER TABLE copies ADD region varchar(255) NOT NULL DEFAULT "PAL" AFTER type; diff --git a/src/entity/copy.py b/src/entity/copy.py index fab8223..ee0c28a 100644 --- a/src/entity/copy.py +++ b/src/entity/copy.py @@ -100,6 +100,18 @@ class Copy(AbstractEntity): 'Virtual', } }, + 'region': { + 'field': 'region', + 'method': '_region', + 'required': True, + 'type': 'strict-text', + 'allowed_values': { + 'PAL', + 'JAP', + 'NTSC', + 'CHINA' + } + }, 'comments': { 'field': 'comments', 'method': '_comments', @@ -140,6 +152,7 @@ def __init__( has_manual, status, type, + region, comments, is_rom = None, platform_name = None, @@ -158,6 +171,7 @@ def __init__( self.has_manual = bool(has_manual) self.status = status self.type = type + self.region = region self.is_rom = bool(is_rom) self.comments = comments self.platform_name = platform_name @@ -203,6 +217,9 @@ def get_type(self): def get_is_rom(self): return self.is_rom + def get_region(self): + return self.region + def get_comments(self): return self.comments @@ -242,6 +259,9 @@ def set_type(self, type): def set_is_rom(self, is_rom): self.is_rom = bool(is_rom) + def set_region(self, region): + self.region = region + def set_comments(self, comments): self.comments = comments diff --git a/test/functional/test_copies.py b/test/functional/test_copies.py index 3908319..2d99574 100644 --- a/test/functional/test_copies.py +++ b/test/functional/test_copies.py @@ -34,6 +34,7 @@ def test_create_fails_version_not_found(self): "hasManual": False, "status": "In", 'type': 'Physical', + 'region': 'PAL', "comments": "Found it somewhere" } resp = self.api_call('post', 'copy', payload, True) @@ -105,6 +106,7 @@ def test_get_copy(self): "hasManual": True, "status": "In", 'type': 'Physical', + 'region': 'PAL', "comments": "Bought it in 2004", 'isROM': False, 'gameTitle': 'Tonic Trouble', @@ -129,6 +131,7 @@ def test_create_update_delete_success(self): "hasManual": False, "status": "In", 'type': 'Virtual', + 'region': 'PAL', "comments": "Found it somewhere", 'gameTitle': 'Tonic Trouble', 'platformName': 'PC', @@ -164,6 +167,7 @@ def test_create_update_delete_success(self): 'gameTitle': 'Tonic Trouble', 'transactionCount': 0, 'type': 'Physical', + 'region': 'PAL', } resp = self.api_call('patch', 'copy/' + copy_id, payload, True) diff --git a/test/functional/test_transactions.py b/test/functional/test_transactions.py index 6414829..d668d70 100644 --- a/test/functional/test_transactions.py +++ b/test/functional/test_transactions.py @@ -247,6 +247,7 @@ def test_copy_status_toggle(self): "hasManual": False, "status": "In", 'type': 'Physical', + 'region': 'PAL', "comments": "Well well well..." } @@ -338,8 +339,9 @@ def test_inconsistent_status_operation(self): "onCompilation": True, "reedition": True, "hasManual": False, + 'status': 'Out', 'type': 'Physical', - "status": "Out", + 'region': 'PAL', "comments": "Well well well..." } @@ -418,8 +420,9 @@ def test_cannot_create_two_inbound_transaction_in_a_row(self): "onCompilation": True, "reedition": True, "hasManual": False, - 'type': 'Physical', "status": "In", + 'type': 'Physical', + 'region': 'PAL', "comments": "Well well well..." } diff --git a/test/games_test.sql b/test/games_test.sql index 4fa6391..e5018a3 100644 --- a/test/games_test.sql +++ b/test/games_test.sql @@ -35,6 +35,7 @@ CREATE TABLE `copies` ( `has_manual` tinyint unsigned NOT NULL, `status` varchar(255) NOT NULL DEFAULT 'In', `type` varchar(255) NOT NULL, + `region` varchar(255) NOT NULL, `is_rom` tinyint unsigned NOT NULL DEFAULT '0', `comments` text, PRIMARY KEY (`copy_id`), @@ -49,7 +50,7 @@ CREATE TABLE `copies` ( LOCK TABLES `copies` WRITE; /*!40000 ALTER TABLE `copies` DISABLE KEYS */; -INSERT INTO `copies` VALUES (1,348,1,'fr','Big box','CD-like','CD-ROM',0,0,1,'In','Physical',0,'Bought it in 2004'),(2,349,1,'fr','none','Cardboard sleeve','CD-ROM',1,1,0,'In','Physical',0,'Got it with my cereals'),(3,245,1,'fr','None','CD-like','CD-ROM',1,1,0,'In','Physical',0,'pues'); +INSERT INTO `copies` VALUES (1,348,1,'fr','Big box','CD-like','CD-ROM',0,0,1,'In','Physical','PAL',0,'Bought it in 2004'),(2,349,1,'fr','none','Cardboard sleeve','CD-ROM',1,1,0,'In','Physical','PAL',0,'Got it with my cereals'),(3,245,1,'fr','None','CD-like','CD-ROM',1,1,0,'In','Physical','PAL',0,'pues'); /*!40000 ALTER TABLE `copies` ENABLE KEYS */; UNLOCK TABLES; From 9f0875b08800c7b9511facd6a66853276924920a Mon Sep 17 00:00:00 2001 From: ecourtial Date: Thu, 23 Mar 2023 20:13:42 +0100 Subject: [PATCH 3/3] Fix mini blu-ray authorized type --- src/entity/copy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/entity/copy.py b/src/entity/copy.py index ee0c28a..5929d8f 100644 --- a/src/entity/copy.py +++ b/src/entity/copy.py @@ -54,7 +54,7 @@ class Copy(AbstractEntity): 'DVD-ROM', 'CD-ROM', 'GD-ROM', - 'MINI-Blu-ray' + 'MINI-Blu-ray', 'MINI-DVD-ROM', 'MINI-CD-ROM', 'Cartridge',