Handle Romanian/Slovakian/Croatian-only capabilities.

master
Pacman Ghost 6 years ago
parent bdecdfb838
commit 4de10016ac
  1. 30
      vasl_templates/webapp/static/snippets.js
  2. 4
      vasl_templates/webapp/templates/index.html
  3. 10
      vasl_templates/webapp/templates/vo-report.html
  4. 2
      vasl_templates/webapp/tests/fixtures/vo-reports/ordnance/axis-minor-common/1940.txt
  5. 6
      vasl_templates/webapp/tests/fixtures/vo-reports/ordnance/axis-minor-common/1941.txt
  6. 6
      vasl_templates/webapp/tests/fixtures/vo-reports/ordnance/axis-minor-common/1942.txt
  7. 4
      vasl_templates/webapp/tests/fixtures/vo-reports/ordnance/axis-minor-common/1943.txt
  8. 4
      vasl_templates/webapp/tests/fixtures/vo-reports/ordnance/axis-minor-common/1944.txt
  9. 4
      vasl_templates/webapp/tests/fixtures/vo-reports/ordnance/axis-minor-common/1945.txt
  10. 60
      vasl_templates/webapp/tests/test_capabilities.py
  11. 10
      vasl_templates/webapp/tests/test_vo_reports.py
  12. 2
      vasl_templates/webapp/vo.py

@ -236,8 +236,10 @@ function unload_snippet_params( params, check_date_capabilities )
// but by the time the filter gets called, it's too late :-( Instead, we provide a "raw_capabilities"
// parameter that people can use in their templates - ugly, but probably not something that will
// get a lot of use :-/
var nat = params[ "PLAYER_"+player_no ] ;
var capabilities = make_capabilities(
entry,
nat,
params.SCENARIO_THEATER,
params.SCENARIO_YEAR, params.SCENARIO_MONTH, check_date_capabilities,
false
@ -246,6 +248,7 @@ function unload_snippet_params( params, check_date_capabilities )
obj.capabilities = capabilities ;
capabilities = make_capabilities(
entry,
nat,
params.SCENARIO_THEATER,
params.SCENARIO_YEAR, params.SCENARIO_MONTH, check_date_capabilities,
true
@ -270,7 +273,7 @@ function unload_snippet_params( params, check_date_capabilities )
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
function make_capabilities( entry, scenario_theater, scenario_year, scenario_month, check_date_capabilities, raw )
function make_capabilities( entry, nat, scenario_theater, scenario_year, scenario_month, check_date_capabilities, raw )
{
var capabilities = [] ;
@ -314,7 +317,7 @@ function make_capabilities( entry, scenario_theater, scenario_year, scenario_mon
capabilities.push( make_raw_capability( key, entry.capabilities2[key] ) ) ;
}
else {
var cap = _select_capability_by_date( entry.capabilities2[key], scenario_theater, scenario_year, scenario_month ) ;
var cap = _select_capability_by_date( entry.capabilities2[key], nat, scenario_theater, scenario_year, scenario_month ) ;
if ( cap === null )
continue ;
if ( cap == "<invalid>" ) {
@ -381,14 +384,14 @@ function make_raw_capability( name, capability )
return buf.join( "" ) ;
}
function _select_capability_by_date( capabilities, scenario_theater, scenario_year, scenario_month )
function _select_capability_by_date( capabilities, nat, scenario_theater, scenario_year, scenario_month )
{
// NOTE: The capability can sometimes not have a number e.g. Tetrarch CS s# = "ref1", Stuart III(a) = "HE(4+)"
var timestamp, val ;
if ( capabilities[0] === null ) {
timestamp = capabilities[1] ;
if ( timestamp.match( /^\d\+?$/ ) ) {
val = _check_capability_timestamp( capabilities, timestamp, scenario_theater, scenario_year, scenario_month ) ;
val = _check_capability_timestamp( capabilities, timestamp, nat, scenario_theater, scenario_year, scenario_month ) ;
if ( val === "<ignore>" )
return null ;
return "";
@ -404,7 +407,7 @@ function _select_capability_by_date( capabilities, scenario_theater, scenario_ye
var retval = "???" ;
for ( var i=0 ; i < capabilities.length ; ++i ) {
timestamp = capabilities[i][1].toString() ;
val = _check_capability_timestamp( capabilities[i], timestamp, scenario_theater, scenario_year, scenario_month ) ;
val = _check_capability_timestamp( capabilities[i], timestamp, nat, scenario_theater, scenario_year, scenario_month ) ;
if ( val === "<invalid>" )
return val ;
if ( val === "<ignore>" )
@ -418,7 +421,7 @@ function _select_capability_by_date( capabilities, scenario_theater, scenario_ye
return ref ? retval+ref : retval ;
}
function _check_capability_timestamp( capabilities, timestamp, scenario_theater, scenario_year, scenario_month )
function _check_capability_timestamp( capabilities, timestamp, nat, scenario_theater, scenario_year, scenario_month )
{
var MONTH_NAMES = { F:2, J:6, A:8, S:9 } ;
@ -439,15 +442,18 @@ function _check_capability_timestamp( capabilities, timestamp, scenario_theater,
timestamp = timestamp.substring( 0, timestamp.length-1 ) ;
}
if ( timestamp.substring( timestamp.length-1 ) === "R" ) {
// FIXME! What does a "R" superscript mean?
if ( nat != "romanian" )
return "<ignore>" ;
timestamp = timestamp.substring( 0, timestamp.length-1 ) ;
}
if ( timestamp.substring( timestamp.length-1 ) === "S" ) {
// FIXME! What does a "S" superscript mean?
timestamp = timestamp.substring( 0, timestamp.length-1 ) ;
if ( timestamp.substring( timestamp.length-2 ) === "CS" ) {
if ( nat != "croatian" && nat != "slovakian" )
return "<ignore>" ;
timestamp = timestamp.substring( 0, timestamp.length-2 ) ;
}
if ( timestamp.substring( timestamp.length-1 ) === "C" ) {
// FIXME! What does a "C" superscript mean?
if ( timestamp.substring( timestamp.length-1 ) === "S" ) {
if ( nat != "slovakian" )
return "<ignore>" ;
timestamp = timestamp.substring( 0, timestamp.length-1 ) ;
}

@ -301,8 +301,8 @@ gAppVersion = "{{APP_VERSION}}" ;
gImagesBaseUrl = "{{url_for('static',filename='images')}}" ;
gGetTemplatePackUrl = "{{url_for('get_template_pack')}}" ;
gGetDefaultScenarioUrl = "{{url_for('get_default_scenario')}}" ;
gVehicleListingsUrl = "{{url_for('get_vehicle_listings')}}" ;
gOrdnanceListingsUrl = "{{url_for('get_ordnance_listings')}}" ;
gVehicleListingsUrl = "{{url_for('get_vehicle_listings',merge_common=1)}}" ;
gOrdnanceListingsUrl = "{{url_for('get_ordnance_listings',merge_common=1)}}" ;
gHelpUrl = "{{url_for('show_help')}}" ;
</script>
<script src="{{url_for('static',filename='main.js')}}"></script>

@ -25,9 +25,11 @@ $(document).ready( function () {
// get the vehicle listings
var url ;
if ( "{{VO_TYPE}}" == "vehicles" )
url = "{{url_for( 'get_vehicle_listings', report=1, no_merge_common=1 ) | safe}}"
url = "{{url_for( 'get_vehicle_listings', report=1 )}}"
else
url = "{{url_for( 'get_ordnance_listings', report=1, no_merge_common=1 ) | safe}}" ;
url = "{{url_for( 'get_ordnance_listings', report=1 )}}" ;
if ( getUrlParam( "merge_common" ) === "1" )
url += "&merge_common=1" ;
$.getJSON( url, function(data) {
load_vo_listings( data ) ;
} ).fail( function( xhr, status, errorMsg ) {
@ -79,9 +81,9 @@ function load_vo_listings( objs )
buf.push( "<td>", fmtval(has_if) ) ;
buf.push( "<td>", fmtval(make_crew_survival(obj)) ) ;
}
var capabilities = make_capabilities( obj, theater, year, month, true, true ) ;
var capabilities = make_capabilities( obj, nat, theater, year, month, true, true ) ;
buf.push( "<td>", listval(capabilities) ) ;
var capabilities = make_capabilities( obj, theater, year, month, true, false ) ;
var capabilities = make_capabilities( obj, nat, theater, year, month, true, false ) ;
buf.push( "<td>", listval(capabilities) ) ;
buf.push( "<td>", "<span class='val'>" + fmtval(obj.note_number) + "</span>" ) ;
buf.push( "<td>", listval(obj.notes) ) ;

@ -21,7 +21,7 @@ Skoda M17 NT QSU NT QSU
Skoda M28(80) T T 60† S C
Skoda M14/19 NT s8 NT s8 61† A† R H S C
leFH 18(g) NT H4[3+] s5 NT s5 62† E H S B
Skoda M35 NT AP7 C7[CS]† NT AP7 C7† 63† R S C
Skoda M35 NT AP7 C7[CS]† NT AP7 63† R S C
G obr. 10/30 NT h-d s7 NT h-d s7 64† R B
G obr. 38 NT s5[1-2R]† NT 65 R B
Skoda M14 NT NT 66† R H S

@ -9,7 +9,7 @@ Brandt M27/31 NT QSU s7 NT QSU s7
PM obr. 38 NT QSU h-d s8 NT QSU h-d s8 48† R H
Ur wz. 35 1PP 1PP 49 R H S C B
s18-1100 5PP 5PP 50 A R H
Kanon PUV vz. 37(t) NT QSU A4[1S] NT QSU A4 51† E H S B
Kanon PUV vz. 37(t) NT QSU A4[1S] NT QSU 51† E H S B
Bohler M35 NT QSU no Gunshield NT QSU no Gunshield 52† A R H S
5cm PaK 38(g) NT QSU A4[3]3[4] NT QSU 53† E R H S B
7.5cm PaK 97/38(g) NT QSU H5[3+] s6 NT QSU s6 54† E R B
@ -21,9 +21,9 @@ Skoda M17 NT QSU NT QSU
Skoda M28(80) T T 60† S C
Skoda M14/19 NT s8 NT s8 61† A† R H S C
leFH 18(g) NT H4[3+] s5 NT s5 62† E H S B
Skoda M35 NT AP7 C7[CS]† NT AP7 C7† 63† R S C
Skoda M35 NT AP7 C7[CS]† NT AP7 63† R S C
G obr. 10/30 NT h-d s7 NT h-d s7 64† R B
G obr. 38 NT s5[1-2R]† NT s5† 65 R B
G obr. 38 NT s5[1-2R]† NT 65 R B
Skoda M14 NT NT 66† R H S
Skoda M15/16 NT no IF s6 NT no IF s6 67† S C
C mle 17 S NT s7 NT s7 68† R B

@ -9,7 +9,7 @@ Brandt M27/31 NT QSU s7 NT QSU s7
PM obr. 38 NT QSU h-d s8 NT QSU h-d s8 48† R H
Ur wz. 35 1PP 1PP 49 R H S C B
s18-1100 5PP 5PP 50 A R H
Kanon PUV vz. 37(t) NT QSU A4[1S] NT QSU A4 51† E H S B
Kanon PUV vz. 37(t) NT QSU A4[1S] NT QSU 51† E H S B
Bohler M35 NT QSU no Gunshield NT QSU no Gunshield 52† A R H S
5cm PaK 38(g) NT QSU A4[3]3[4] NT QSU 53† E R H S B
7.5cm PaK 97/38(g) NT QSU H5[3+] s6 NT QSU s6 54† E R B
@ -21,9 +21,9 @@ Skoda M17 NT QSU NT QSU
Skoda M28(80) T T 60† S C
Skoda M14/19 NT s8 NT s8 61† A† R H S C
leFH 18(g) NT H4[3+] s5 NT s5 62† E H S B
Skoda M35 NT AP7 C7[CS]† NT AP7 C7† 63† R S C
Skoda M35 NT AP7 C7[CS]† NT AP7 63† R S C
G obr. 10/30 NT h-d s7 NT h-d s7 64† R B
G obr. 38 NT s5[1-2R]† NT s5† 65 R B
G obr. 38 NT s5[1-2R]† NT 65 R B
Skoda M14 NT NT 66† R H S
Skoda M15/16 NT no IF s6 NT no IF s6 67† S C
C mle 17 S NT s7 NT s7 68† R B

@ -9,7 +9,7 @@ Brandt M27/31 NT QSU s7 NT QSU s7
PM obr. 38 NT QSU h-d s8 NT QSU h-d s8 48† R H
Ur wz. 35 1PP 1PP 49 R H S C B
s18-1100 5PP 5PP 50 A R H
Kanon PUV vz. 37(t) NT QSU A4[1S] NT QSU A4 51† E H S B
Kanon PUV vz. 37(t) NT QSU A4[1S] NT QSU 51† E H S B
Bohler M35 NT QSU no Gunshield NT QSU no Gunshield 52† A R H S
5cm PaK 38(g) NT QSU A4[3]3[4] NT QSU A4 53† E R H S B
7.5cm PaK 97/38(g) NT QSU H5[3+] s6 NT QSU H5 s6 54† E R B
@ -21,7 +21,7 @@ Skoda M17 NT QSU NT QSU
Skoda M28(80) T T 60† S C
Skoda M14/19 NT s8 NT s8 61† A† R H S C
leFH 18(g) NT H4[3+] s5 NT H4 s5 62† E H S B
Skoda M35 NT AP7 C7[CS]† NT AP7 C7† 63† R S C
Skoda M35 NT AP7 C7[CS]† NT AP7 63† R S C
G obr. 10/30 NT h-d s7 NT h-d s7 64† R B
G obr. 38 NT s5[1-2R]† NT 65 R B
Skoda M14 NT NT 66† R H S

@ -9,7 +9,7 @@ Brandt M27/31 NT QSU s7 NT QSU s7
PM obr. 38 NT QSU h-d s8 NT QSU h-d s8 48† R H
Ur wz. 35 1PP 1PP 49 R H S C B
s18-1100 5PP 5PP 50 A R H
Kanon PUV vz. 37(t) NT QSU A4[1S] NT QSU A4 51† E H S B
Kanon PUV vz. 37(t) NT QSU A4[1S] NT QSU 51† E H S B
Bohler M35 NT QSU no Gunshield NT QSU no Gunshield 52† A R H S
5cm PaK 38(g) NT QSU A4[3]3[4] NT QSU A3 53† E R H S B
7.5cm PaK 97/38(g) NT QSU H5[3+] s6 NT QSU H5 s6 54† E R B
@ -21,7 +21,7 @@ Skoda M17 NT QSU NT QSU
Skoda M28(80) T T 60† S C
Skoda M14/19 NT s8 NT s8 61† A† R H S C
leFH 18(g) NT H4[3+] s5 NT H4 s5 62† E H S B
Skoda M35 NT AP7 C7[CS]† NT AP7 C7† 63† R S C
Skoda M35 NT AP7 C7[CS]† NT AP7 63† R S C
G obr. 10/30 NT h-d s7 NT h-d s7 64† R B
G obr. 38 NT s5[1-2R]† NT 65 R B
Skoda M14 NT NT 66† R H S

@ -9,7 +9,7 @@ Brandt M27/31 NT QSU s7 NT QSU s7
PM obr. 38 NT QSU h-d s8 NT QSU h-d s8 48† R H
Ur wz. 35 1PP 1PP 49 R H S C B
s18-1100 5PP 5PP 50 A R H
Kanon PUV vz. 37(t) NT QSU A4[1S] NT QSU A4 51† E H S B
Kanon PUV vz. 37(t) NT QSU A4[1S] NT QSU 51† E H S B
Bohler M35 NT QSU no Gunshield NT QSU no Gunshield 52† A R H S
5cm PaK 38(g) NT QSU A4[3]3[4] NT QSU A3 53† E R H S B
7.5cm PaK 97/38(g) NT QSU H5[3+] s6 NT QSU H5 s6 54† E R B
@ -21,7 +21,7 @@ Skoda M17 NT QSU NT QSU
Skoda M28(80) T T 60† S C
Skoda M14/19 NT s8 NT s8 61† A† R H S C
leFH 18(g) NT H4[3+] s5 NT H4 s5 62† E H S B
Skoda M35 NT AP7 C7[CS]† NT AP7 C7† 63† R S C
Skoda M35 NT AP7 C7[CS]† NT AP7 63† R S C
G obr. 10/30 NT h-d s7 NT h-d s7 64† R B
G obr. 38 NT s5[1-2R]† NT 65 R B
Skoda M14 NT NT 66† R H S

@ -1,5 +1,7 @@
""" Test snippet generation for capabilities. """
import re
import pytest
from vasl_templates.webapp.tests.test_vo_reports import get_vo_report
@ -268,8 +270,8 @@ def test_month_capabilities( webapp, webdriver ):
pytest.config.option.short_tests, #pylint: disable=no-member
reason = "--short-tests specified"
)
def test_scenario_theater( webapp, webdriver ):
"""Test scenario theater specific capabilities."""
def test_theater_capabilities( webapp, webdriver ):
"""Test theater-specific capabilities."""
# M2A1 105mm Howitzer: C7(4+P)†1
ordnance = [ "american", "ordnance", "M2A1 105mm Howitzer" ]
@ -343,16 +345,63 @@ def test_scenario_theater( webapp, webdriver ):
# ---------------------------------------------------------------------
@pytest.mark.skipif(
pytest.config.option.short_tests, #pylint: disable=no-member
reason = "--short-tests specified"
)
def test_nationality_capabilities( webapp, webdriver ):
"""Test nationality-specific capabilities."""
# G obr. 38: s5(1-2R)†
ordnance = [ "romanian", "ordnance", "G obr. 38" ]
val = _get_capabilities( webdriver, webapp, *ordnance, "ETO", "01/1940", merge_common=True )
assert not re.search( r"s5\u2020", val )
ordnance = [ "romanian", "ordnance", "G obr. 38" ]
val = _get_capabilities( webdriver, webapp, *ordnance, "ETO", "01/1941", merge_common=True )
assert re.search( r"s5\u2020", val )
ordnance = [ "slovakian", "ordnance", "G obr. 38" ]
val = _get_capabilities( webdriver, webapp, *ordnance, "ETO", "01/1941", merge_common=True )
assert not re.search( r"s5\u2020", val )
# Skoda M35: C7(CS)†
ordnance = [ "croatian", "ordnance", "Skoda M35" ]
val = _get_capabilities( webdriver, webapp, *ordnance, "ETO", "01/1940", merge_common=True )
assert re.search( r"C7\u2020", val )
ordnance = [ "slovakian", "ordnance", "Skoda M35" ]
val = _get_capabilities( webdriver, webapp, *ordnance, "ETO", "01/1940", merge_common=True )
assert re.search( r"C7\u2020", val )
ordnance = [ "bulgarian", "ordnance", "Skoda M35" ]
val = _get_capabilities( webdriver, webapp, *ordnance, "ETO", "01/1940", merge_common=True )
assert not re.search( r"C7\u2020", val )
# Kanon PUV vz. 37(t): A4(1S)
ordnance = [ "slovakian", "ordnance", "Kanon PUV vz. 37(t)" ]
val = _get_capabilities( webdriver, webapp, *ordnance, "ETO", "01/1940", merge_common=True )
assert not re.search( r"A4", val )
ordnance = [ "slovakian", "ordnance", "Kanon PUV vz. 37(t)" ]
val = _get_capabilities( webdriver, webapp, *ordnance, "ETO", "01/1941", merge_common=True )
assert re.search( r"A4", val )
ordnance = [ "croatian", "ordnance", "Kanon PUV vz. 37(t)" ]
val = _get_capabilities( webdriver, webapp, *ordnance, "ETO", "01/1941", merge_common=True )
assert not re.search( r"A4", val )
# ---------------------------------------------------------------------
def _check_capabilities( webdriver, webapp,
nat, vo_type, vo_name, scenario_theater, scenario_date,
expected, row=None
): #pylint: disable=too-many-arguments
"""Check the vehicle/ordnance capabilities for the specified parameters."""
capabilities = _get_capabilities( webdriver, webapp, nat, vo_type, vo_name, scenario_theater, scenario_date, row )
capabilities = _get_capabilities(
webdriver, webapp, nat, vo_type, vo_name, scenario_theater, scenario_date,
merge_common = False,
row = row
)
assert capabilities == expected
def _get_capabilities( webdriver, webapp,
nat, vo_type, vo_name, scenario_theater, scenario_date,
merge_common=False,
row=None
): #pylint: disable=too-many-arguments
"""Get the vehicle/ordnance capabilities for the specified parameters.
@ -369,7 +418,10 @@ def _get_capabilities( webdriver, webapp,
# generate the V/O report
month, year = scenario_date.split( "/" )
results = get_vo_report( webapp, webdriver, scenario_theater, nat, vo_type, year, month, name=vo_name )
results = get_vo_report( webapp, webdriver,
scenario_theater, nat, vo_type, year, month, name=vo_name,
merge_common = merge_common
)
assert len(results) == 1+expected_rows
# check the capabilities

@ -84,7 +84,10 @@ def test_vo_reports( webapp, webdriver ):
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def get_vo_report( webapp, webdriver, theater, nat, vo_type, year, month, name=None ):
def get_vo_report( webapp, webdriver,
theater, nat, vo_type, year, month,
name=None, merge_common=False
): #pylint: disable=too-many-arguments,too-many-locals
"""Get a vehicle/ordnance report.
NOTE: We can't get the V/O report to return its results as, say, plain-text, for easy checking,
@ -97,8 +100,11 @@ def get_vo_report( webapp, webdriver, theater, nat, vo_type, year, month, name=N
# initialize
url = webapp.url_for( "get_vo_report", theater=theater, nat=nat, vo_type=vo_type, year=year, month=month )
assert "?" in url
if name:
url += "?&name={}".format( name )
url += "&name={}".format( name )
if merge_common:
url += "&merge_common=1"
webdriver.get( url )
wait_for( 2, lambda: find_child("#results").is_displayed() )

@ -52,7 +52,7 @@ def _do_get_listings( listings_type ): #pylint: disable=too-many-branches
listings[nat] = json.load( fp )
# merge the common entries into each Allied/Axis Minor listing
if not request.args.get( "no_merge_common" ):
if request.args.get( "merge_common" ) == "1":
for minor_type in ("allied-minor","axis-minor"):
if minor_type+"-common" not in listings:
continue

Loading…
Cancel
Save