Skip to content
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
10 changes: 10 additions & 0 deletions migrations/20241229232706_no_level_id_ref.down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
UPDATE demons
SET level_id = NULL
WHERE level_id IS NOT NULL
AND level_id NOT IN (
SELECT level_id
FROM gj_level
);
-- if a demon was added when the constraint was dropped but had an invalid level_id (didn't appear in gj_level), it will be set to null
ALTER TABLE demons
ADD CONSTRAINT demons_level_id_fkey FOREIGN KEY (level_id) REFERENCES gj_level(level_id);
1 change: 1 addition & 0 deletions migrations/20241229232706_no_level_id_ref.up.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE demons DROP CONSTRAINT IF EXISTS demons_level_id_fkey;
2 changes: 1 addition & 1 deletion pointercrate-demonlist-pages/src/account/demons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
label for = "level_id" {
"Geometry Dash Level ID:"
}
input type = "number" name = "level_id" required min = "1";
input type = "number" name = "level_id" min = "1";

Check warning on line 349 in pointercrate-demonlist-pages/src/account/demons.rs

View check run for this annotation

Codecov / codecov/patch

pointercrate-demonlist-pages/src/account/demons.rs#L349

Added line #L349 was not covered by tests
p.error {}
}
span.form-input.flex.col #demon-add-position {
Expand Down
1 change: 0 additions & 1 deletion pointercrate-demonlist-pages/static/js/account/demon.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,6 @@ function setupDemonAdditionForm() {
form.addValidators({
"demon-add-name": { "Please specify a name": valueMissing },
"demon-add-level-id": {
"Please specify a Geometry Dash level ID": valueMissing,
"Level ID must be positive": rangeUnderflow,
},
"demon-add-position": {
Expand Down
2 changes: 1 addition & 1 deletion pointercrate-test/tests/demonlist/demon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async fn test_add_demon_ratelimits(pool: Pool<Postgres>) {

let user = pointercrate_test::user::system_user_with_perms(LIST_MODERATOR, &mut *connection).await;

let demon = serde_json::json! {{"name": "Bloodbath", "requirement": 90, "position": 1, "verifier": "Riot", "publisher": "Riot", "creators": []}};
let demon = serde_json::json! {{"name": "Bloodbath", "requirement": 90, "position": 1, "verifier": "Riot", "publisher": "Riot", "creators": [], "level_id": 10565740}};

// first one should succeed
clnt.post("/api/v2/demons/", &demon)
Expand Down
Loading