Use a shared template for vehicle/ordnance snippets.

master
Pacman Ghost 5 years ago
parent db6144e774
commit b3b3e77ec2
  1. 17
      vasl_templates/webapp/data/default-template-pack/ma_note.css
  2. 54
      vasl_templates/webapp/data/default-template-pack/ob_ma_notes.j2
  3. 41
      vasl_templates/webapp/data/default-template-pack/ob_ordnance.j2
  4. 38
      vasl_templates/webapp/data/default-template-pack/ob_ordnance_ma_notes.j2
  5. 24
      vasl_templates/webapp/data/default-template-pack/ob_ordnance_note.j2
  6. 24
      vasl_templates/webapp/data/default-template-pack/ob_vehicle_note.j2
  7. 41
      vasl_templates/webapp/data/default-template-pack/ob_vehicles.j2
  8. 38
      vasl_templates/webapp/data/default-template-pack/ob_vehicles_ma_notes.j2
  9. 47
      vasl_templates/webapp/data/default-template-pack/ob_vo.j2
  10. 29
      vasl_templates/webapp/data/default-template-pack/ob_vo_note.j2
  11. 5
      vasl_templates/webapp/data/default-template-pack/vo.css
  12. 19
      vasl_templates/webapp/snippets.py
  13. 55
      vasl_templates/webapp/static/snippets.js
  14. 8
      vasl_templates/webapp/tests/fixtures/data/default-template-pack/ob_ma_notes.j2
  15. 6
      vasl_templates/webapp/tests/fixtures/data/default-template-pack/ob_ordnance.j2
  16. 8
      vasl_templates/webapp/tests/fixtures/data/default-template-pack/ob_ordnance_ma_notes.j2
  17. 1
      vasl_templates/webapp/tests/fixtures/data/default-template-pack/ob_ordnance_note.j2
  18. 1
      vasl_templates/webapp/tests/fixtures/data/default-template-pack/ob_vehicle_note.j2
  19. 6
      vasl_templates/webapp/tests/fixtures/data/default-template-pack/ob_vehicles.j2
  20. 8
      vasl_templates/webapp/tests/fixtures/data/default-template-pack/ob_vehicles_ma_notes.j2
  21. 6
      vasl_templates/webapp/tests/fixtures/data/default-template-pack/ob_vo.j2
  22. 1
      vasl_templates/webapp/tests/fixtures/data/default-template-pack/ob_vo_note.j2
  23. 20
      vasl_templates/webapp/tests/test_template_packs.py
  24. 9
      vasl_templates/webapp/tests/utils.py

@ -1,17 +0,0 @@
.ma-note { margin: 2px 0 3px 0 ; text-align: justify ; }
.ma-note .key { font-weight: bold ; }
.ma-note table { margin-left: 10px ; }
.ma-note td { padding: 0 ; }
.ma-note ul { padding-left: 10px ; list-style-image: url("{{IMAGES_BASE_URL}}/bullet.png") ; }
.ma-note li { margin-bottom: 2px ; }
.ma-note .example { font-size: 90% ; font-style: italic ; }
.ma-note table { margin-left: 10px ; margin-top: -5px ; }
.ma-note table th { padding: 2px 10px 2px 5px ; text-align: left ; background: #f0f0f0 ; }
.ma-note table td { padding: 0 10px 0 5px ; }
.extra-notes-caption { border: 1px solid #e0e0e0 ; background: #fcfcfc ; font-weight: bold ; padding: 2px 5px ; }
.slashed { text-decoration: line-through ; }
p { margin-top: 5px ; margin-bottom: 0 ; }
ul { margin: 0 0 0 15px ; padding: 0 ; }
sup { font-size: 75% ; }

@ -0,0 +1,54 @@
<html> <!-- vasl-templates:id {{SNIPPET_ID}} -->
<head>
<meta charset="utf-8">
<style>
.ma-note { margin: 2px 0 3px 0 ; text-align: justify ; }
.ma-note .key { font-weight: bold ; }
.ma-note table { margin-left: 10px ; }
.ma-note td { padding: 0 ; }
.ma-note ul { padding-left: 10px ; list-style-image: url("{{IMAGES_BASE_URL}}/bullet.png") ; }
.ma-note li { margin-bottom: 2px ; }
.ma-note .example { font-size: 90% ; font-style: italic ; }
.ma-note table { margin-left: 10px ; margin-top: -5px ; }
.ma-note table th { padding: 2px 10px 2px 5px ; text-align: left ; background: #f0f0f0 ; }
.ma-note table td { padding: 0 10px 0 5px ; }
.extra-notes-caption { border: 1px solid #e0e0e0 ; background: #fcfcfc ; font-weight: bold ; padding: 2px 5px ; }
.slashed { text-decoration: line-through ; }
p { margin-top: 5px ; margin-bottom: 0 ; }
ul { margin: 0 0 0 15px ; padding: 0 ; }
sup { font-size: 75% ; }
</style>
</head>
<table style="
{%if OB_MA_NOTES_WIDTH%} width: {{OB_MA_NOTES_WIDTH}} ; {%endif%}
">
<tr>
<td colspan="2" style="
background: {{OB_COLOR}} ;
border-bottom: 1px solid {{OB_COLOR_2}} ;
padding: 2px 5px ;
font-weight: bold ;
">
{%if PLAYER_FLAG%}<img src="{{PLAYER_FLAG}}">&nbsp;{%endif%}{{PLAYER_NAME}} {{VO_TYPE}} Notes
{%if OB_MA_NOTES%}
<tr> <td style="padding: 0 5px;">
{%for ma_note in OB_MA_NOTES%}
<div class="ma-note"> {{ma_note}} </div>
{%endfor%}
{%endif%}
{%if OB_EXTRA_MA_NOTES%}
<tr> <td style="padding: 0 5px;">
{%if OB_EXTRA_MA_NOTES_CAPTION%} <div class="extra-notes-caption"> {{OB_EXTRA_MA_NOTES_CAPTION}} </div> {%endif%}
{%for ma_note in OB_EXTRA_MA_NOTES%}
<div class="ma-note"> {{ma_note}} </div>
{%endfor%}
{%endif%}
</table>
</html>

@ -1,41 +0,0 @@
<html> <!-- vasl-templates:id {{SNIPPET_ID}} -->
<head>
<meta charset="utf-8">
<style> {{VO_CSS}} </style>
</head>
<table style="
{%if OB_ORDNANCE_WIDTH%} width: {{OB_ORDNANCE_WIDTH}} ; {%endif%}
">
<tr>
<td colspan="2" style="
background: {{OB_COLOR}} ;
border-bottom: 1px solid {{OB_COLOR_2}} ;
padding: 2px 5px ;
font-weight: bold ;
">
{%if PLAYER_FLAG%}<img src="{{PLAYER_FLAG}}">&nbsp;{%endif%}{{PLAYER_NAME}} Ordnance
{%for ord in OB_ORDNANCE%}
<tr style="border-bottom:1px dotted #e0e0e0;">
<td valign="top" style="padding:2px 5px 5px;">
<b>{{ord.name}}</b> {%if ord.elite%}&#x24ba;{%endif%}
{%if ord.image%} <br> <img src="{{ord.image}}"> {%endif%}
<div class="note">
{%if ord.extn_id%} &#x2756; {%endif%}
{%if ord.notes%}
{{ord.note_number}}, {{ord.notes | join(", ")}}
{%else%}
{{ord.note_number}}
{%endif%}
</div>
<td valign="top" style="padding:2px 5px;">
{%for cap in ord.capabilities%} <div class="capability"> {{cap}} </div> {%endfor%}
{%for cmnt in ord.comments%} <div class="comment"> {{cmnt}} </div> {%endfor%}
{%endfor%}
</table>
</html>

@ -1,38 +0,0 @@
<html> <!-- vasl-templates:id {{SNIPPET_ID}} -->
<head>
<meta charset="utf-8">
<style> {{MA_NOTE_CSS}} </style>
</head>
<table style="
{%if OB_ORDNANCE_MA_NOTES_WIDTH%} width: {{OB_ORDNANCE_MA_NOTES_WIDTH}} ; {%endif%}
">
<tr>
<td colspan="2" style="
background: {{OB_COLOR}} ;
border-bottom: 1px solid {{OB_COLOR_2}} ;
padding: 2px 5px ;
font-weight: bold ;
">
{%if PLAYER_FLAG%}<img src="{{PLAYER_FLAG}}">&nbsp;{%endif%}{{PLAYER_NAME}} Ordnance Notes
{%if OB_ORDNANCE_MA_NOTES%}
<tr> <td style="padding: 0 5px;">
{%for ma_note in OB_ORDNANCE_MA_NOTES%}
<div class="ma-note"> {{ma_note}} </div>
{%endfor%}
{%endif%}
{%if OB_ORDNANCE_EXTRA_MA_NOTES%}
<tr> <td style="padding: 0 5px;">
{%if OB_ORDNANCE_EXTRA_MA_NOTES_CAPTION%} <div class="extra-notes-caption"> {{OB_ORDNANCE_EXTRA_MA_NOTES_CAPTION}} </div> {%endif%}
{%for ma_note in OB_ORDNANCE_EXTRA_MA_NOTES%}
<div class="ma-note"> {{ma_note}} </div>
{%endfor%}
{%endif%}
</table>
</html>

@ -1,24 +0,0 @@
<html> <!-- vasl-templates:id {{SNIPPET_ID}} -->
<head>
<meta charset="utf-8">
<style> {{VO_NOTE_CSS}} </style>
</head>
<table>
<tr>
<td colspan="2" style="
background: {{OB_COLOR}} ;
border-bottom: 1px solid {{OB_COLOR_2}} ;
padding: 2px 5px ;
font-weight: bold ;
">
{%if PLAYER_FLAG%}<img src="{{PLAYER_FLAG}}">&nbsp;{%endif%}{{ORDNANCE_NAME}}
<tr>
<td> {{ORDNANCE_NOTE_HTML}}
</table>
</html>

@ -1,24 +0,0 @@
<html> <!-- vasl-templates:id {{SNIPPET_ID}} -->
<head>
<meta charset="utf-8">
<style> {{VO_NOTE_CSS}} </style>
</head>
<table>
<tr>
<td colspan="2" style="
background: {{OB_COLOR}} ;
border-bottom: 1px solid {{OB_COLOR_2}} ;
padding: 2px 5px ;
font-weight: bold ;
">
{%if PLAYER_FLAG%}<img src="{{PLAYER_FLAG}}">&nbsp;{%endif%}{{VEHICLE_NAME}}
<tr>
<td> {{VEHICLE_NOTE_HTML}}
</table>
</html>

@ -1,41 +0,0 @@
<html> <!-- vasl-templates:id {{SNIPPET_ID}} -->
<head>
<meta charset="utf-8">
<style> {{VO_CSS}} </style>
</head>
<table style="
{%if OB_VEHICLES_WIDTH%} width: {{OB_VEHICLES_WIDTH}} ; {%endif%}
">
<tr>
<td colspan="2" style="
background: {{OB_COLOR}} ;
border-bottom: 1px solid {{OB_COLOR_2}} ;
padding: 2px 5px ;
font-weight: bold ;
">
{%if PLAYER_FLAG%}<img src="{{PLAYER_FLAG}}">&nbsp;{%endif%}{{PLAYER_NAME}} Vehicles
{%for veh in OB_VEHICLES%}
<tr style="border-bottom:1px dotted #e0e0e0;">
<td valign="top" style="padding:2px 5px 5px;">
<b>{{veh.name}}</b> {%if veh.elite%}&#x24ba;{%endif%}
{%if veh.image%} <br> <img src="{{veh.image}}"> {%endif%}
<div class="note">
{%if veh.extn_id%} &#x2756; {%endif%}
{%if veh.notes%}
{{veh.note_number}}, {{veh.notes | join(", ")}}
{%else%}
{{veh.note_number}}
{%endif%}
</div>
<td valign="top" style="padding:2px 5px;">
{%for cap in veh.capabilities%} <div class="capability"> {{cap}} </div> {%endfor%}
{%for cmnt in veh.comments%} <div class="comment"> {{cmnt}} </div> {%endfor%}
{%endfor%}
</table>
</html>

@ -1,38 +0,0 @@
<html> <!-- vasl-templates:id {{SNIPPET_ID}} -->
<head>
<meta charset="utf-8">
<style> {{MA_NOTE_CSS}} </style>
</head>
<table style="
{%if OB_VEHICLES_MA_NOTES_WIDTH%} width: {{OB_VEHICLES_MA_NOTES_WIDTH}} ; {%endif%}
">
<tr>
<td colspan="2" style="
background: {{OB_COLOR}} ;
border-bottom: 1px solid {{OB_COLOR_2}} ;
padding: 2px 5px ;
font-weight: bold ;
">
{%if PLAYER_FLAG%}<img src="{{PLAYER_FLAG}}">&nbsp;{%endif%}{{PLAYER_NAME}} Vehicle Notes
{%if OB_VEHICLES_MA_NOTES%}
<tr> <td style="padding: 0 5px;">
{%for ma_note in OB_VEHICLES_MA_NOTES%}
<div class="ma-note"> {{ma_note}} </div>
{%endfor%}
{%endif%}
{%if OB_VEHICLES_EXTRA_MA_NOTES%}
<tr> <td style="padding: 0 5px;">
{%if OB_VEHICLES_EXTRA_MA_NOTES_CAPTION%} <div class="extra-notes-caption"> {{OB_VEHICLES_EXTRA_MA_NOTES_CAPTION}} </div> {%endif%}
{%for ma_note in OB_VEHICLES_EXTRA_MA_NOTES%}
<div class="ma-note"> {{ma_note}} </div>
{%endfor%}
{%endif%}
</table>
</html>

@ -0,0 +1,47 @@
<html> <!-- vasl-templates:id {{SNIPPET_ID}} -->
<head>
<meta charset="utf-8">
<style>
td { margin: 0 ; padding: 0 ; }
sup { font-size: 75% ; }
.note { margin-top: 2px ; font-size: 90% ; font-style: italic ; color: #808080 ; }
.comment { font-size: 90% ; font-style: italic ; color: #404040 ; }
</style>
</head>
<table style="
{%if OB_VO_WIDTH%} width: {{OB_VO_WIDTH}} ; {%endif%}
">
<tr>
<td colspan="2" style="
background: {{OB_COLOR}} ;
border-bottom: 1px solid {{OB_COLOR_2}} ;
padding: 2px 5px ;
font-weight: bold ;
">
{%if PLAYER_FLAG%}<img src="{{PLAYER_FLAG}}">&nbsp;{%endif%}{{PLAYER_NAME}} {{VO_TYPES}}
{%for vo in OB_VO%}
<tr style="border-bottom:1px dotted #e0e0e0;">
<td valign="top" style="padding:2px 5px 5px;">
<b>{{vo.name}}</b> {%if vo.elite%}&#x24ba;{%endif%}
{%if vo.image%} <br> <img src="{{vo.image}}"> {%endif%}
<div class="note">
{%if vo.extn_id%} &#x2756; {%endif%}
{%if vo.notes%}
{{vo.note_number}}, {{vo.notes | join(", ")}}
{%else%}
{{vo.note_number}}
{%endif%}
</div>
<td valign="top" style="padding:2px 5px;">
{%for cap in vo.capabilities%} <div class="capability"> {{cap}} </div> {%endfor%}
{%for cmnt in vo.comments%} <div class="comment"> {{cmnt}} </div> {%endfor%}
{%endfor%}
</table>
</html>

@ -1,9 +1,12 @@
img.piece { float: left ; margin-right: 0.5em ; }
<html> <!-- vasl-templates:id {{SNIPPET_ID}} -->
<head>
<meta charset="utf-8">
<style>
img.piece { float: left ; margin-right: 0.5em ; }
.header { margin-bottom: 0.25em ; }
.header .note-number { font-weight: bold ; }
.header .name { font-weight: bold ; font-style: italic ; }
.content { text-align: justify ; }
.content p { margin-top: 5px ; }
.content ul { margin-left: 0 ; padding-left: 25px ; list-style-image: url("{{IMAGES_BASE_URL}}/bullet.png") ; }
@ -15,7 +18,25 @@ img.piece { float: left ; margin-right: 0.5em ; }
.content table { margin: 0 10px 0 10px ; margin-top: -0.5em ; }
.content table th { padding: 2px 10px 2px 5px ; text-align: left ; background: #f0f0f0 ; }
.content table td { padding: 0 10px 0 5px ; }
table.layout td { padding: 0 5px 0 5px ; }
.content .rf { display: none ; }
</style>
</head>
<table>
<tr>
<td colspan="2" style="
background: {{OB_COLOR}} ;
border-bottom: 1px solid {{OB_COLOR_2}} ;
padding: 2px 5px ;
font-weight: bold ;
">
{%if PLAYER_FLAG%}<img src="{{PLAYER_FLAG}}">&nbsp;{%endif%}{{VO_NAME}}
<tr>
<td> {{VO_NOTE_HTML}}
</table>
</html>

@ -1,5 +0,0 @@
td { margin: 0 ; padding: 0 ; }
sup { font-size: 75% ; }
.note { margin-top: 2px ; font-size: 90% ; font-style: italic ; color: #808080 ; }
.comment { font-size: 90% ; font-style: italic ; color: #404040 ; }

@ -112,9 +112,24 @@ def _do_get_template_pack( dname ):
relpath = os.path.relpath( os.path.abspath(fname), dname )
if relpath.startswith( "extras" + os.sep ):
fname_stem = "extras/" + fname_stem
templates[fname_stem] = fp.read()
# FUDGE! In early versions of this program, the vehicles and ordnance templates were different
# (e.g. because only vehicles can be radioless, only ordnance can be QSU), but once everything
# was handled via generic capabilities, they became the same. We would therefore like to have
# a single template file handle both vehicles and ordnance, but the program had been architected
# in such a way that vehicles and ordnance snippets are generated from their own templates,
# so rather than re-architect the program, we maintain separate templates, that just happen
# to be read from the same file. This causes a bit of stuffing around when the code needs to know
# what file a template comes from (e.g. loading a template pack), but it's mostly transparent...
if fname_stem == "ob_vo":
templates["ob_vehicles"] = templates["ob_ordnance"] = fp.read()
elif fname_stem == "ob_vo_note":
templates["ob_vehicle_note"] = templates["ob_ordnance_note"] = fp.read()
elif fname_stem == "ob_ma_notes":
templates["ob_vehicles_ma_notes"] = templates["ob_ordnance_ma_notes"] = fp.read()
else:
templates[fname_stem] = fp.read()
elif extn == ".css":
css[fname_stem] = fp.read().strip()
css[fname_stem] = fp.read()
return nationalities, templates, css
# ---------------------------------------------------------------------

@ -148,46 +148,54 @@ function make_snippet( $btn, params, extra_params, show_date_warnings )
} else
params.SNIPPET_ID = template_id ;
// set the vehicle/ordnance labels
if ( template_id.indexOf( "_vehicles_" ) !== -1 ) {
params.VO_TYPE = "Vehicle" ;
params.VO_TYPES = "Vehicles" ;
} else if ( template_id.indexOf( "_ordnance_" ) !== -1 ) {
params.VO_TYPE = "Ordnance" ;
params.VO_TYPES = "Ordnance" ;
}
// set player-specific parameters
if ( template_id === "ob_vehicles_1" ) {
template_id = "ob_vehicles" ;
params.OB_VEHICLES = params.OB_VEHICLES_1 ;
params.OB_VEHICLES_WIDTH = params.OB_VEHICLES_WIDTH_1 ;
params.OB_VO = params.OB_VEHICLES_1 ;
params.OB_VO_WIDTH = params.OB_VEHICLES_WIDTH_1 ;
snippet_save_name = params.PLAYER_1 + " vehicles" ;
} else if ( template_id === "ob_vehicles_2" ) {
template_id = "ob_vehicles" ;
params.OB_VEHICLES = params.OB_VEHICLES_2 ;
params.OB_VEHICLES_WIDTH = params.OB_VEHICLES_WIDTH_2 ;
params.OB_VO = params.OB_VEHICLES_2 ;
params.OB_VO_WIDTH = params.OB_VEHICLES_WIDTH_2 ;
snippet_save_name = params.PLAYER_2 + " vehicles" ;
}
if ( template_id === "ob_ordnance_1" ) {
template_id = "ob_ordnance" ;
params.OB_ORDNANCE = params.OB_ORDNANCE_1 ;
params.OB_ORDNANCE_WIDTH = params.OB_ORDNANCE_WIDTH_1 ;
params.OB_VO = params.OB_ORDNANCE_1 ;
params.OB_VO_WIDTH = params.OB_ORDNANCE_WIDTH_1 ;
snippet_save_name = params.PLAYER_1 + " ordnance" ;
} else if ( template_id === "ob_ordnance_2" ) {
template_id = "ob_ordnance" ;
params.OB_ORDNANCE = params.OB_ORDNANCE_2 ;
params.OB_ORDNANCE_WIDTH = params.OB_ORDNANCE_WIDTH_2 ;
params.OB_VO = params.OB_ORDNANCE_2 ;
params.OB_VO_WIDTH = params.OB_ORDNANCE_WIDTH_2 ;
snippet_save_name = params.PLAYER_2 + " ordnance" ;
}
// set vehicle/ordnance note parameters
function set_vo_note( vo_type ) {
var data = $btn.parent().parent().data( "sortable2-data" ) ;
var key = (vo_type === "vehicles") ? "VEHICLE" : "ORDNANCE" ;
params[ key + "_NAME" ] = data.vo_entry.name ;
params.VO_NAME = data.vo_entry.name ;
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 + '">' ;
params.VO_NOTE_HTML = '<img src="' + data.vo_note + '">' ;
} 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
params[ key + "_NOTE_HTML" ] = '<img src="' + data.vo_note_image_url + '">' ;
params.VO_NOTE_HTML = '<img src="' + data.vo_note_image_url + '">' ;
} else {
// insert the raw HTML into the snippet
params[ key + "_NOTE_HTML" ] = data.vo_note ;
params.VO_NOTE_HTML = data.vo_note ;
}
}
snippet_save_name = data.vo_entry.name ;
@ -197,18 +205,6 @@ function make_snippet( $btn, params, extra_params, show_date_warnings )
else if ( template_id === "ob_ordnance_note" )
set_vo_note( "ordnance" ) ;
// install the CSS
function install_css( key ) {
if ( gTemplatePack.css[ key ] ) {
params[ key.toUpperCase() + "_CSS" ] = strReplaceAll(
gTemplatePack.css[key], "{{IMAGES_BASE_URL}}", params.IMAGES_BASE_URL
) ;
}
}
install_css( "vo" ) ;
install_css( "vo_note" ) ;
install_css( "ma_note" ) ;
// generate snippets for multi-applicable vehicle/ordnance notes
var pos ;
function add_ma_notes( ma_notes, keys, param_name, nat, vo_type ) {
@ -266,8 +262,7 @@ function make_snippet( $btn, params, extra_params, show_date_warnings )
var vo_type_uc = vo_type.toUpperCase() ;
var postfixes = [ "MA_NOTES", "MA_NOTES_WIDTH", "EXTRA_MA_NOTES", "EXTRA_MA_NOTES_CAPTION" ] ;
for ( var i=0 ; i < postfixes.length ; ++i ) {
var stem = "OB_" + vo_type_uc + "_" + postfixes[i] ;
params[ stem ] = params[ stem + "_" + player_no ] ;
params[ "OB_" + postfixes[i] ] = params[ "OB_" + vo_type_uc + "_" + postfixes[i] + "_" + player_no ] ;
}
snippet_save_name = params["PLAYER_"+player_no] + (vo_type === "vehicles" ? " vehicle notes" : " ordnance notes") ;
}
@ -1729,6 +1724,12 @@ function do_load_template_pack( fname, data )
var template_id = fname.substring( 0, fname.length-extn.length ).toLowerCase() ;
if ( extn === ".css" )
template_pack.css[template_id] = data ;
else if ( template_id === "ob_vo" )
template_pack.templates.ob_vehicles = template_pack.templates.ob_ordnance = data ;
else if ( template_id === "ob_vo_note" )
template_pack.templates.ob_vehicle_note = template_pack.templates.ob_ordnance_note = data ;
else if ( template_id === "ob_ma_notes" )
template_pack.templates.ob_vehicles_ma_notes = template_pack.templates.ob_ordnance_ma_notes = data ;
else {
if ( gValidTemplateIds.indexOf( template_id ) === -1 && template_id.substr(0,7) !== "extras/" ) {
unknown_template_ids.push( fname ) ;

@ -0,0 +1,8 @@
{%for ma_note in OB_MA_NOTES%} [*] {{ma_note}}
{%endfor%}
{%if OB_EXTRA_MA_NOTES%}
{%if OB_EXTRA_MA_NOTES_CAPTION%} === {{OB_EXTRA_MA_NOTES_CAPTION}} === {%endif%}
{%for ma_note in OB_EXTRA_MA_NOTES%} [*] {{ma_note}}
{%endfor%}
{%endif%}

@ -1,6 +0,0 @@
[{{PLAYER_NAME}}] ; width={{OB_ORDNANCE_WIDTH}}{%for ord in OB_ORDNANCE %}
[*] {{ord.name}}: #={{ord.note_number}}{%if ord.notes%}
- notes:{%for n in ord.notes%} "{{n}}"{%endfor%}{%endif%}{%if ord.capabilities%}
- capabilities:{%for c in ord.capabilities%} "{{c}}"{%endfor%}{%endif%}{%if ord.raw_capabilities%}
- raw capabilities:{%for c in ord.capabilities%} "{{c}}"{%endfor%}{%endif%}{%if ord.comments%}
- comments:{%for c in ord.comments%} "{{c}}"{%endfor%}{%endif%}{%endfor%}

@ -1,8 +0,0 @@
{%for ma_note in OB_ORDNANCE_MA_NOTES%} [*] {{ma_note}}
{%endfor%}
{%if OB_ORDNANCE_EXTRA_MA_NOTES%}
{%if OB_ORDNANCE_EXTRA_MA_NOTES_CAPTION%} === {{OB_ORDNANCE_EXTRA_MA_NOTES_CAPTION}} === {%endif%}
{%for ma_note in OB_ORDNANCE_EXTRA_MA_NOTES%} [*] {{ma_note}}
{%endfor%}
{%endif%}

@ -1,6 +0,0 @@
[{{PLAYER_NAME}}] ; width={{OB_VEHICLES_WIDTH}}{%for veh in OB_VEHICLES %}
[*] {{veh.name}}: #={{veh.note_number}}{%if veh.notes%}
- notes:{%for n in veh.notes%} "{{n}}"{%endfor%}{%endif%}{%if veh.capabilities%}
- capabilities:{%for c in veh.capabilities%} "{{c}}"{%endfor%}{%endif%}{%if veh.raw_capabilities%}
- raw capabilities:{%for c in veh.raw_capabilities%} "{{c}}"{%endfor%}{%endif%}{%if veh.comments%}
- comments:{%for c in veh.comments%} "{{c}}"{%endfor%}{%endif%}{%endfor%}

@ -1,8 +0,0 @@
{%for ma_note in OB_VEHICLES_MA_NOTES%} [*] {{ma_note}}
{%endfor%}
{%if OB_VEHICLES_EXTRA_MA_NOTES%}
{%if OB_VEHICLES_EXTRA_MA_NOTES_CAPTION%} === {{OB_VEHICLES_EXTRA_MA_NOTES_CAPTION}} === {%endif%}
{%for ma_note in OB_VEHICLES_EXTRA_MA_NOTES%} [*] {{ma_note}}
{%endfor%}
{%endif%}

@ -0,0 +1,6 @@
[{{PLAYER_NAME}}] ; width={{OB_VO_WIDTH}}{%for vo in OB_VO %}
[*] {{vo.name}}: #={{vo.note_number}}{%if vo.notes%}
- notes:{%for n in vo.notes%} "{{n}}"{%endfor%}{%endif%}{%if vo.capabilities%}
- capabilities:{%for c in vo.capabilities%} "{{c}}"{%endfor%}{%endif%}{%if vo.raw_capabilities%}
- raw capabilities:{%for c in vo.raw_capabilities%} "{{c}}"{%endfor%}{%endif%}{%if vo.comments%}
- comments:{%for c in vo.comments%} "{{c}}"{%endfor%}{%endif%}{%endfor%}

@ -5,6 +5,7 @@ import zipfile
import tempfile
import base64
import re
import random
import pytest
@ -148,16 +149,29 @@ def test_missing_templates( webapp, webdriver ):
dname = os.path.normpath( os.path.join( os.path.split(__file__)[0], "../data/default-template-pack" ) )
for root,_,fnames in os.walk( dname ):
for fname in fnames:
if os.path.splitext( fname )[1] == ".swp":
continue
fname = os.path.join( root, fname )
fname2 = os.path.relpath( fname, start=dname )
if fname2.startswith( "extras/" ):
continue
if fname2 == "ob_vo":
fname2 = random.choice( [ "ob_vehicles", "ob_ordnance" ] )
elif fname2 == "ob_vo_note":
fname2 = random.choice( [ "ob_vehicles_note", "ob_ordnance_note" ] )
elif fname2 == "ob_ma_note":
fname2 = random.choice( [ "ob_vehicles_ma_note", "ob_ordnance_ma_note" ] )
files[ fname2 ] = "dummy template" # nb: we don't care about the content
def adjust_template_id( template_id ): #pylint: disable=missing-docstring
if template_id.startswith( ( "ob_vehicles_", "ob_ordnance_" ) ) and template_id.endswith( ( "_1", "_2" ) ):
return template_id[:-2]
return template_id
if re.search( r"^ob_(vehicles|ordnance)_\d$", template_id ):
return "ob_vo"
elif re.search( r"^ob_(vehicle|ordnance)_note_\d$", template_id ):
return "ob_vo_note"
elif re.search( r"^ob_(vehicles|ordnance)_ma_notes_\d$", template_id ):
return "ob_ma_notes"
else:
return template_id
# upload the template pack, with one file missing each time
for fname in files:

@ -89,7 +89,14 @@ def for_each_template( func ): #pylint: disable=too-many-branches
fname,extn = os.path.splitext( fname )
if extn != ".j2":
continue
templates_to_test.add( fname )
if fname == "ob_vo":
templates_to_test.update( [ "ob_vehicles", "ob_ordnance" ] )
elif fname == "ob_vo_note":
templates_to_test.update( [ "ob_vehicle_note", "ob_ordnance_note" ] )
elif fname == "ob_ma_notes":
templates_to_test.update( [ "ob_vehicles_ma_notes", "ob_ordnance_ma_notes" ] )
else:
templates_to_test.add( fname )
# test the standard templates
for tab_id,template_ids in _STD_TEMPLATES.items():

Loading…
Cancel
Save