Fixed how image URL's are generated for common vehicles/ordnance.

master
Pacman Ghost 5 years ago
parent ec3c9ca2f1
commit e01c78e9af
  1. 10
      vasl_templates/webapp/static/snippets.js
  2. 8
      vasl_templates/webapp/static/vo.js
  3. 0
      vasl_templates/webapp/tests/fixtures/vo-notes/greek/vehicles/201.png
  4. 0
      vasl_templates/webapp/tests/fixtures/vo-notes/greek/vehicles/202.html
  5. 0
      vasl_templates/webapp/tests/fixtures/vo-notes/greek/vehicles/203.html
  6. 0
      vasl_templates/webapp/tests/fixtures/vo-notes/greek/vehicles/203.png
  7. 37
      vasl_templates/webapp/tests/test_vo_notes.py

@ -177,14 +177,14 @@ function make_snippet( $btn, params, extra_params, show_date_warnings )
var data = $btn.parent().parent().data( "sortable2-data" ) ;
var key = (vo_type === "vehicles") ? "VEHICLE" : "ORDNANCE" ;
params[ key + "_NAME" ] = data.vo_entry.name ;
if ( data.vo_note.substr( 0, 7 ) === "http://" )
if ( data.vo_note.substr( 0, 7 ) === "http://" ) {
// the vehicle/ordnance note is an image - just include it directly
params[ key + "_NOTE_HTML" ] = '<img src="' + data.vo_note + '">' ;
else {
} else {
// the vehicle/ordnance is HTML - check if we should show it as HTML or as an image
if ( gUserSettings["vo-notes-as-images"] ) {
// show the vehicle/ordnance note as an image
var nat = params[ "PLAYER_" + player_no ] ;
var url = APP_URL_BASE + "/" + vo_type + "/" + nat + "/note/" + get_vo_note_key(data.vo_entry) ;
params[ key + "_NOTE_HTML" ] = '<img src="' + url + '">' ;
params[ key + "_NOTE_HTML" ] = '<img src="' + data.vo_note_image_url + '">' ;
} else {
// insert the raw HTML into the snippet
params[ key + "_NOTE_HTML" ] = data.vo_note ;

@ -166,13 +166,18 @@ function do_add_vo( vo_type, player_no, vo_entry, vo_image_id, elite, custom_cap
] ;
var vo_note_key = get_vo_note_key( vo_entry ) ;
var vo_note = get_vo_note( vo_type, nat, vo_note_key ) ;
if ( ! vo_note ) {
var vo_note_image_url = null ;
if ( vo_note )
vo_note_image_url = APP_URL_BASE + "/" + vo_type + "/" + nat + "/note/" + vo_note_key ;
else {
// NOTE: Note numbers seem to be distinct across all Allied Minor or all Axis Minor vehicles/ordnance,
// so if we don't find a note in a given nationality's normal vehicles/ordnance, we can get away with
// just checking their corresponding common vehicles/ordnance.
var nat_type = gTemplatePack.nationalities[ nat ].type ;
if ( ["allied-minor","axis-minor"].indexOf( nat_type ) !== -1 ) {
vo_note = get_vo_note( vo_type, nat_type, vo_note_key ) ;
if ( vo_note )
vo_note_image_url = APP_URL_BASE + "/" + vo_type + "/" + nat_type + "/note/" + vo_note_key ;
}
}
if ( vo_note ) {
@ -184,6 +189,7 @@ function do_add_vo( vo_type, player_no, vo_entry, vo_image_id, elite, custom_cap
) ;
}
data.vo_note = vo_note ;
data.vo_note_image_url = vo_note_image_url ;
}
buf.push( "</div>" ) ;
var $content = $( buf.join("") ) ;

@ -11,7 +11,8 @@ import lxml.etree
import tabulate
from vasl_templates.webapp.tests.utils import \
init_webapp, get_nationalities, select_tab, set_player, find_child, find_children, wait_for, wait_for_clipboard
init_webapp, get_nationalities, select_tab, set_player, select_menu_option, click_dialog_button, \
find_child, find_children, wait_for, wait_for_clipboard
from vasl_templates.webapp.tests.test_scenario_persistence import load_scenario, save_scenario
from vasl_templates.webapp.tests.test_vehicles_ordnance import add_vo, delete_vo
@ -132,7 +133,7 @@ def test_ma_html_notes( webapp, webdriver ):
# check the snippets
_check_vo_snippets( 1, "vehicles", [
( "PNG note", "vehicles/allied-minor/note/201" ),
( "PNG note", "vehicles/greek/note/201" ),
"HTML note: <table width='500'><tr><td>\nThis is an HTML vehicle note (202).\n</table>",
"PNG + HTML notes: <table width='500'><tr><td>\nThis is an HTML vehicle note (203).\n</table>",
] )
@ -175,6 +176,38 @@ def test_common_vo_notes( webapp, webdriver ):
( "common axis minor ordnance", "ordnance/axis-minor/note/104" ),
] )
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def test_common_vo_notes2( webapp, webdriver ):
"""Test handling of Allied/Axis Minor common vehicles/ordnance (as images)."""
# 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": "greek",
"OB_VEHICLES_1": [
{ "name": "HTML note" },
{ "name": "common allied minor vehicle" },
],
} )
# enable "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 not elem.is_selected()
elem.click()
click_dialog_button( "OK" )
# check the snippets
_check_vo_snippets( 1, "vehicles", [
( "HTML note", "vehicles/greek/note/202" ),
( "common allied minor vehicle", "vehicles/allied-minor/note/101" ),
] )
# ---------------------------------------------------------------------
def test_extra_ma_notes( webapp, webdriver ):

Loading…
Cancel
Save