diff --git a/vasl_templates/webapp/static/snippets.js b/vasl_templates/webapp/static/snippets.js index 46781b1..150d61d 100644 --- a/vasl_templates/webapp/static/snippets.js +++ b/vasl_templates/webapp/static/snippets.js @@ -580,7 +580,11 @@ function get_vo_note( vo_type, nat, key ) var vo_note = gVehicleOrdnanceNotes[ vo_type ][ nat ][ key ] ; // FUDGE! We need to detect between a full HTML note and an image-based one. // This is not great, but it'll do... :-/ - if ( vo_note.substr( 0, nat.length+1 ) === nat+"/" ) + var nat2 = nat ; + var pos = nat2.indexOf( "~" ) ; + if ( pos > 0 ) + nat2 = nat2.substring( 0, pos ) ; + if ( vo_note.substr( 0, nat2.length+1 ) === nat2+"/" ) return make_app_url( "/" + vo_type + "/" + nat + "/note/" + key, true ) ; else return vo_note ; diff --git a/vasl_templates/webapp/tests/fixtures/data/default-template-pack/nationalities.json b/vasl_templates/webapp/tests/fixtures/data/default-template-pack/nationalities.json index 688e3a5..fa5755d 100644 --- a/vasl_templates/webapp/tests/fixtures/data/default-template-pack/nationalities.json +++ b/vasl_templates/webapp/tests/fixtures/data/default-template-pack/nationalities.json @@ -24,6 +24,15 @@ "ob_colors": [ "OBCOL:british~canadian","OBCOL2:british~canadian", "OBCOL-BORDER:british~canadian" ] }, +"chinese": { + "display_name": "Chinese", + "ob_colors": [ "OBCOL:chinese","OBCOL2:chinese", "OBCOL-BORDER:chinese" ] +}, +"chinese~gmd": { + "display_name": "Chinese GMD", + "ob_colors": [ "OBCOL:chinese~gmd","OBCOL2:chinese~gmd", "OBCOL-BORDER:chinese~gmd" ] +}, + "french": { "display_name": "French", "ob_colors": [ "OBCOL:french","OBCOL2:french", "OBCOL-BORDER:french" ] diff --git a/vasl_templates/webapp/tests/fixtures/data/ordnance/chinese.json b/vasl_templates/webapp/tests/fixtures/data/ordnance/chinese.json new file mode 100644 index 0000000..bff6403 --- /dev/null +++ b/vasl_templates/webapp/tests/fixtures/data/ordnance/chinese.json @@ -0,0 +1,8 @@ +[ + +{ "name": "a chinese ordnance", + "note_number": "1", + "id": "ch/o:001" +} + +] diff --git a/vasl_templates/webapp/tests/fixtures/data/ordnance/chinese~gmd.json b/vasl_templates/webapp/tests/fixtures/data/ordnance/chinese~gmd.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/vasl_templates/webapp/tests/fixtures/data/ordnance/chinese~gmd.json @@ -0,0 +1 @@ +[] diff --git a/vasl_templates/webapp/tests/fixtures/data/vehicles/chinese.json b/vasl_templates/webapp/tests/fixtures/data/vehicles/chinese.json new file mode 100644 index 0000000..5a7ac10 --- /dev/null +++ b/vasl_templates/webapp/tests/fixtures/data/vehicles/chinese.json @@ -0,0 +1,8 @@ +[ + +{ "name": "a chinese vehicle", + "note_number": "1", + "id": "ch/v:001" +} + +] diff --git a/vasl_templates/webapp/tests/fixtures/data/vehicles/chinese~gmd.json b/vasl_templates/webapp/tests/fixtures/data/vehicles/chinese~gmd.json new file mode 100644 index 0000000..fe51488 --- /dev/null +++ b/vasl_templates/webapp/tests/fixtures/data/vehicles/chinese~gmd.json @@ -0,0 +1 @@ +[] diff --git a/vasl_templates/webapp/tests/fixtures/vo-notes/chinese/ordnance/1.png b/vasl_templates/webapp/tests/fixtures/vo-notes/chinese/ordnance/1.png new file mode 100644 index 0000000..62b2678 Binary files /dev/null and b/vasl_templates/webapp/tests/fixtures/vo-notes/chinese/ordnance/1.png differ diff --git a/vasl_templates/webapp/tests/fixtures/vo-notes/chinese/vehicles/1.png b/vasl_templates/webapp/tests/fixtures/vo-notes/chinese/vehicles/1.png new file mode 100644 index 0000000..62b2678 Binary files /dev/null and b/vasl_templates/webapp/tests/fixtures/vo-notes/chinese/vehicles/1.png differ diff --git a/vasl_templates/webapp/tests/test_vo_notes.py b/vasl_templates/webapp/tests/test_vo_notes.py index 53157da..dd15cc0 100644 --- a/vasl_templates/webapp/tests/test_vo_notes.py +++ b/vasl_templates/webapp/tests/test_vo_notes.py @@ -138,6 +138,39 @@ def test_ma_html_notes( webapp, webdriver ): # --------------------------------------------------------------------- +def test_derived_nationalities( webapp, webdriver ): + """Test generating V/O notes for derived nationalities.""" + + # initialize + webapp.control_tests.set_vo_notes_dir( "{TEST}" ) + init_webapp( webapp, webdriver, scenario_persistence=1 ) + load_scenario( { + "PLAYER_1": "chinese", + "OB_VEHICLES_1": [ { "name": "a chinese vehicle" } ], + "OB_ORDNANCE_1": [ { "name": "a chinese ordnance" } ], + "PLAYER_2": "chinese~gmd", + "OB_VEHICLES_2": [ { "name": "a chinese vehicle" } ], + "OB_ORDNANCE_2": [ { "name": "a chinese ordnance" } ], + } ) + + # check the snippets for the base nationality + _check_vo_snippets( 1, "vehicles", [ + ( "a chinese vehicle", "vehicles/chinese/note/1" ) + ] ) + _check_vo_snippets( 1, "ordnance", [ + ( "a chinese ordnance", "ordnance/chinese/note/1" ) + ] ) + + # check the snippets for the derived nationality + _check_vo_snippets( 2, "vehicles", [ + ( "a chinese vehicle", "vehicles/chinese~gmd/note/1" ) + ] ) + _check_vo_snippets( 2, "ordnance", [ + ( "a chinese ordnance", "ordnance/chinese~gmd/note/1" ) + ] ) + +# --------------------------------------------------------------------- + def test_common_vo_notes( webapp, webdriver ): """Test handling of Allied/Axis Minor common vehicles/ordnance."""