fix: trade_policy 宏使用 with context 修复 500
Jinja imported macros did not receive trade_policy from render context, causing Internal Server Error on all instance pages. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -34,7 +34,7 @@
|
||||
</div>
|
||||
<div class="row" style="margin-top:10px">
|
||||
<label>币种</label>
|
||||
{% from 'trade_policy_fields.html' import trade_policy_symbol %}
|
||||
{% from 'trade_policy_fields.html' import trade_policy_symbol with context %}
|
||||
{{ trade_policy_symbol('symbol', 'symbol-input', default_symbol, placeholder='BTC/USDT') }}
|
||||
<label>关键位</label>
|
||||
<select id="key-id">
|
||||
|
||||
@@ -142,7 +142,7 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
<form id="key-form" action="/add_key" method="post" class="form-row">
|
||||
{% from 'trade_policy_fields.html' import trade_policy_symbol, trade_policy_direction %}
|
||||
{% from 'trade_policy_fields.html' import trade_policy_symbol, trade_policy_direction with context %}
|
||||
{{ trade_policy_symbol('symbol', 'key-symbol') }}
|
||||
<select name="type" id="key-type-select" required>
|
||||
{% if position_sizing_mode != 'full_margin' %}
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
<form id="trend-pullback-form" action="{{ url_for('preview_trend_pullback') }}" method="post" class="form-row">
|
||||
{% from 'trade_policy_fields.html' import trade_policy_symbol, trade_policy_direction %}
|
||||
{% from 'trade_policy_fields.html' import trade_policy_symbol, trade_policy_direction with context %}
|
||||
{{ trade_policy_symbol('symbol', 'trend-symbol', placeholder='BTC 或 ETH/USDT') }}
|
||||
{{ trade_policy_direction('direction', 'trend-direction') }}
|
||||
<input name="leverage" type="number" min="1" step="1" placeholder="杠杆(必填)" required>
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
{# 方向 / 币种:env 账户级限制(三所共用宏) #}
|
||||
{# 方向 / 币种:env 账户级限制(三所共用宏);调用方须 with context #}
|
||||
{% if trade_policy is not defined %}
|
||||
{% set trade_policy = {'symbol_restrict_enabled': false, 'direction_restrict_enabled': false, 'symbol_whitelist': [], 'allows_long': true, 'allows_short': true, 'direction_mode': 'both', 'badge_text': ''} %}
|
||||
{% endif %}
|
||||
{% macro trade_policy_symbol(name, id, value='', required=true, placeholder='BTC 或 BTC/USDT') -%}
|
||||
{% if trade_policy.symbol_restrict_enabled and trade_policy.symbol_whitelist %}
|
||||
<select name="{{ name }}" id="{{ id }}" {% if required %}required{% endif %} class="trade-policy-symbol-select">
|
||||
|
||||
Reference in New Issue
Block a user