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

Release/4.2.0 #43

Merged
merged 3 commits into from
Mar 24, 2023
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 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.

Expand Down
24 changes: 23 additions & 1 deletion docs/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
17 changes: 16 additions & 1 deletion docs/RESOURCES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)? | |
Expand Down Expand Up @@ -137,16 +138,19 @@ 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 | |
|3.5-inch floppy | |
|5.25-inch floppy | |
|Other disc | |
|Other floppy | |
|External drive | |
|None | |

### Allowed types for _status_
Expand All @@ -163,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 |
Expand Down
2 changes: 1 addition & 1 deletion docs/SETUP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!

Expand Down
1 change: 1 addition & 0 deletions games_empty.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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`),
Expand Down
1 change: 1 addition & 0 deletions migrations/4.2.0.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE copies ADD region varchar(255) NOT NULL DEFAULT "PAL" AFTER type;
23 changes: 23 additions & 0 deletions src/entity/copy.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,19 @@ 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',
'3.5-inch floppy',
'5.25-inch floppy',
'Other disc',
'Other floppy',
'External drive',
'None'
}
},
Expand Down Expand Up @@ -97,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',
Expand Down Expand Up @@ -137,6 +152,7 @@ def __init__(
has_manual,
status,
type,
region,
comments,
is_rom = None,
platform_name = None,
Expand All @@ -155,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
Expand Down Expand Up @@ -200,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

Expand Down Expand Up @@ -239,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

Expand Down
4 changes: 4 additions & 0 deletions test/functional/test_copies.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 5 additions & 2 deletions test/functional/test_transactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ def test_copy_status_toggle(self):
"hasManual": False,
"status": "In",
'type': 'Physical',
'region': 'PAL',
"comments": "Well well well..."
}

Expand Down Expand Up @@ -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..."
}

Expand Down Expand Up @@ -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..."
}

Expand Down
3 changes: 2 additions & 1 deletion test/games_test.sql
Original file line number Diff line number Diff line change
Expand Up @@ -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`),
Expand All @@ -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;

Expand Down