Show the correct vehicle note for Landing Craft.

master
Pacman Ghost 5 years ago
parent 43a1c33ed8
commit ff5752fc74
  1. 5
      vasl_templates/webapp/static/snippets.js
  2. 1
      vasl_templates/webapp/tests/fixtures/data/vehicles/japanese.json
  3. 1
      vasl_templates/webapp/tests/fixtures/data/vehicles/landing-craft.json
  4. 1
      vasl_templates/webapp/tests/fixtures/vo-notes/japanese/vehicles/2.html
  5. 1
      vasl_templates/webapp/tests/fixtures/vo-notes/landing-craft/2.html
  6. 32
      vasl_templates/webapp/tests/test_vo_notes.py
  7. 7
      vasl_templates/webapp/vo.py

@ -25,6 +25,7 @@ var MA_NOTE_REDIRECTS = {
"Jp": "japanese",
"Ru": "russian",
"US": "american",
"LC": "landing-craft",
"AllM": "allied-minor",
"AxM": "axis-minor",
} ;
@ -414,7 +415,7 @@ function get_vo_note_key( vo_entry )
if ( ! vo_entry.note_number )
return null ;
// NOTE: There are some note numbers of the form "1.2" :-/ We also need to handle redirects.
var match = vo_entry.note_number.match( new RegExp( "^((Br|US|Fr) )?([0-9]+(.\\d)?)" ) ) ;
var match = vo_entry.note_number.match( new RegExp( "^((Br|US|Fr|LC) )?([0-9]+(.\\d)?)" ) ) ;
if ( ! match )
return null ;
var key = match[0] ;
@ -429,7 +430,7 @@ function get_vo_note( vo_type, nat, key )
return null ;
// check for redirects
var match = key.match( /^(Br|US|Fr) (.+)$/ ) ;
var match = key.match( /^(Br|US|Fr|LC) (.+)$/ ) ;
if ( match ) {
nat = MA_NOTE_REDIRECTS[ match[1] ] ;
key = match[2] ;

@ -1,6 +1,7 @@
[
{ "name": "japanese vehicle",
"note_number": "2",
"notes": [ "A\u2020<sup>1</sup>" ],
"id": "ja/v:000"
}

@ -6,6 +6,7 @@
"gpid": [ 399, 397 ]
},
{ "name": "Daihatsu",
"note_number": "2",
"notes": [ "B" ],
"id": "sh/v:007",
"gpid": 417

@ -208,6 +208,13 @@ def test_common_vo_notes2( webapp, webdriver ):
( "common allied minor vehicle", "vehicles/allied-minor/note/101" ),
] )
# restore "show vehicle/ordnance notes as images"
select_menu_option( "user_settings" )
elem = find_child( ".ui-dialog.user-settings input[name='vo-notes-as-images']" )
assert elem.is_selected()
elem.click()
click_dialog_button( "OK" )
# ---------------------------------------------------------------------
def test_extra_ma_notes( webapp, webdriver ):
@ -286,6 +293,31 @@ def test_extra_ma_notes( webapp, webdriver ):
# ---------------------------------------------------------------------
def test_landing_craft_notes( webapp, webdriver ):
"""Test handling of Landing Craft notes."""
# initialize
init_webapp( webapp, webdriver, scenario_persistence=1,
reset = lambda ct: ct.set_vo_notes_dir( dtype="test" )
)
# load the test scenario
load_scenario( {
"PLAYER_1": "japanese",
"OB_VEHICLES_1": [
{ "name": "japanese vehicle" },
{ "name": "Daihatsu" },
],
} )
# check the vehicle notes
_check_vo_snippets( 1, "vehicles", [
"japanese vehicle: <table width='500'><tr><td>\nJapanese Vehicle Note #2.\n</table>",
"Daihatsu: <table width='500'><tr><td>\nLanding Craft Note #2.\n</table>",
] )
# ---------------------------------------------------------------------
def test_update_ui( webapp, webdriver ):
"""Check that the UI is updated correctly for multi-applicable notes."""

@ -43,7 +43,7 @@ def load_vo_listings():
"ordnance": _do_load_vo_listings( "ordnance", True, False )
}
def _do_load_vo_listings( vo_type, merge_common, report ): #pylint: disable=too-many-locals,too-many-branches
def _do_load_vo_listings( vo_type, merge_common, report ): #pylint: disable=too-many-locals,too-many-branches,too-many-statements
"""Load the vehicle/ordnance listings."""
# locate the data directory
@ -97,6 +97,11 @@ def _do_load_vo_listings( vo_type, merge_common, report ): #pylint: disable=too-
# add in any landing craft
if vo_type == "vehicles":
for lc in listings.get("landing-craft",[]):
# FUDGE! Landing Craft get appended to the vehicles for the Japanese/American/British,
# so we need to tag the note numbers so that they refer to the *Landing Craft* note,
# not the Japanese/American/British vehicle note.
if "note_number" in lc:
lc["note_number"] = "LC {}".format( lc["note_number"] )
if lc["name"] in ("Daihatsu","Shohatsu"):
listings["japanese"].append( lc )
else:

Loading…
Cancel
Save