refactor(model): rename Postcard.country -> country_to for clear semantics - country_from: origin country (where postcard was sent from) - country_to: destination country (where postcard was sent to) - Profile.country remains as user's home country - Updated all routes, schemas, templates, and API endpoints
This commit is contained in:
@@ -118,8 +118,10 @@ new Chart(document.getElementById('chart-received'), {
|
||||
<span class="badge badge-{{ pc.status }}">{{ {'sent':'已寄出','delivered':'已送达','received':'已收到'}.get(pc.status) if user.language=='zh' else {'sent':'Sent','delivered':'Delivered','received':'Received'}.get(pc.status) }}</span>
|
||||
</div>
|
||||
<div class="recent-meta">
|
||||
{% if pc.country_from and pc.country_to %}<span>{{ pc.country_from|flag }} {{ pc.country_from }} → {{ pc.country_to|flag }} {{ pc.country_to }}</span>
|
||||
{% elif pc.country_to %}<span>{{ pc.country_to|flag }} {{ pc.country_to }}</span>
|
||||
{% endif %}
|
||||
{% if pc.status in ('sent','delivered') %}
|
||||
<span>{{ pc.country|flag }} {{ pc.country or '' }}</span>
|
||||
<span>→ {{ pc.recipient_name or '-' }}</span>
|
||||
{% else %}
|
||||
<span>← {{ pc.sender_name or '-' }}</span>
|
||||
|
||||
@@ -37,8 +37,8 @@
|
||||
<img src="{{ pc.image_front }}" alt="" class="showcase-card-img" loading="lazy">
|
||||
<div class="showcase-card-body">
|
||||
<div class="showcase-card-meta">
|
||||
{% if pc.country_from and pc.country %}<span>{{ pc.country_from|flag }} {{ pc.country_from }} → {{ pc.country|flag }} {{ pc.country }}</span>
|
||||
{% elif pc.country %}<span>{{ pc.country|flag }} {{ pc.country }}</span>
|
||||
{% if pc.country_to_from and pc.country_to %}<span>{{ pc.country_to_from|flag }} {{ pc.country_to_from }} → {{ pc.country_to|flag }} {{ pc.country_to }}</span>
|
||||
{% elif pc.country_to %}<span>{{ pc.country_to|flag }} {{ pc.country_to }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
@@ -78,8 +78,8 @@ function _appendCard(c) {
|
||||
div.setAttribute('data-front', c.image_front);
|
||||
div.onclick = function() { openLightbox(div); };
|
||||
var countryHtml = '';
|
||||
if (c.country_from && c.country) countryHtml = '<span>' + _flag(c.country_from) + ' ' + c.country_from + ' → ' + _flag(c.country) + ' ' + c.country + '</span>';
|
||||
else if (c.country) countryHtml = '<span>' + _flag(c.country) + ' ' + c.country + '</span>';
|
||||
if (c.country_from && c.country_to) countryHtml = '<span>' + _flag(c.country_from) + ' ' + c.country_from + ' → ' + _flag(c.country_to) + ' ' + c.country_to + '</span>';
|
||||
else if (c.country_to) countryHtml = '<span>' + _flag(c.country_to) + ' ' + c.country_to + '</span>';
|
||||
div.innerHTML = '<img src="' + c.image_front + '" alt="" class="showcase-card-img" loading="lazy">' +
|
||||
'<div class="showcase-card-body"><div class="showcase-card-meta">' + countryHtml + '</div></div>';
|
||||
grid.appendChild(div);
|
||||
|
||||
@@ -52,12 +52,12 @@
|
||||
<dt>{{ 'pc_detail.status'|t(user.language) }}</dt><dd>{{ {'sent':'已寄出','delivered':'已送达','received':'已收到'}.get(postcard.status, postcard.status) if user.language=='zh' else {'sent':'Sent','delivered':'Delivered','received':'Received'}.get(postcard.status, postcard.status) }}</dd>
|
||||
{% if postcard.status in ('sent','delivered') %}
|
||||
<dt>{{ 'pc_detail.recipient'|t(user.language) }}</dt><dd>{{ postcard.recipient_name or '-' }}</dd>
|
||||
<dt>{{ 'pc_detail.route'|t(user.language) }}</dt><dd>{% if postcard.country_from %}{{ postcard.country_from|flag }} {{ postcard.country_from }} → {% endif %}{{ postcard.country|flag }} {{ postcard.country or '-' }}</dd>
|
||||
<dt>{{ 'pc_detail.route'|t(user.language) }}</dt><dd>{% if postcard.country_to_from %}{{ postcard.country_to_from|flag }} {{ postcard.country_to_from }} → {% endif %}{{ postcard.country_to|flag }} {{ postcard.country_to or '-' }}</dd>
|
||||
<dt>{{ 'pc_detail.send_time'|t(user.language) }}</dt><dd>{{ postcard.send_time.strftime('%Y-%m-%d') if postcard.send_time else '-' }}</dd>
|
||||
<dt>{{ 'pc_detail.arrival_time'|t(user.language) }}</dt><dd>{{ postcard.arrival_time.strftime('%Y-%m-%d') if postcard.arrival_time else '-' }}</dd>
|
||||
{% else %}
|
||||
<dt>{{ 'pc_detail.sender'|t(user.language) }}</dt><dd>{{ postcard.sender_name or '-' }}</dd>
|
||||
<dt>{{ 'pc_detail.route'|t(user.language) }}</dt><dd>{% if postcard.country_from %}{{ postcard.country_from|flag }} {{ postcard.country_from }} → {% endif %}{{ postcard.country|flag }} {{ postcard.country or '-' }}</dd>
|
||||
<dt>{{ 'pc_detail.route'|t(user.language) }}</dt><dd>{% if postcard.country_to_from %}{{ postcard.country_to_from|flag }} {{ postcard.country_to_from }} → {% endif %}{{ postcard.country_to|flag }} {{ postcard.country_to or '-' }}</dd>
|
||||
<dt>{{ 'pc_detail.receive_time'|t(user.language) }}</dt><dd>{{ postcard.receive_time.strftime('%Y-%m-%d') if postcard.receive_time else '-' }}</dd>
|
||||
{% endif %}
|
||||
<dt>{{ 'pc_detail.profile'|t(user.language) }}</dt><dd>{{ postcard.profile.nickname }}</dd>
|
||||
|
||||
@@ -32,10 +32,10 @@
|
||||
</div>
|
||||
|
||||
<label>{{ 'pc_form.country_from'|t(user.language) }}</label>
|
||||
<input type="text" name="country_from" id="input-country-from" value="{{ postcard.country_from if postcard and postcard.country_from else (profile.country if profile else '') }}" maxlength="2" style="width:80px;text-transform:uppercase" oninput="this.value=this.value.toUpperCase()">
|
||||
<input type="text" name="country_from" id="input-country-from" value="{{ postcard.country_to_from if postcard and postcard.country_to_from else (profile.country if profile else '') }}" maxlength="2" style="width:80px;text-transform:uppercase" oninput="this.value=this.value.toUpperCase()">
|
||||
|
||||
<label>{{ 'pc_form.country'|t(user.language) }} *</label>
|
||||
<input type="text" name="country" id="input-country" value="{{ postcard.country if postcard else '' }}" maxlength="2" placeholder="JP" style="width:80px;text-transform:uppercase" oninput="this.value=this.value.toUpperCase()">
|
||||
<input type="text" name="country_to" id="input-country-to" value="{{ postcard.country_to if postcard else '' }}" maxlength="2" placeholder="JP" style="width:80px;text-transform:uppercase" oninput="this.value=this.value.toUpperCase()">
|
||||
|
||||
<label>{{ 'pc_form.notes'|t(user.language) }}</label>
|
||||
<textarea name="notes" rows="3" placeholder="{{ 'pc_form.notes_ph'|t(user.language) }}">{{ postcard.notes if postcard else '' }}</textarea>
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
<div class="postcard-row-info">
|
||||
<strong>{{ pc.card_number }}</strong>
|
||||
<div class="postcard-row-detail">
|
||||
<span>{% if pc.country_from %}{{ pc.country_from|flag }}→{% endif %}{{ pc.country|flag }} {{ pc.country or '-' }}</span>
|
||||
<span>{% if pc.country_to_from %}{{ pc.country_to_from|flag }}→{% endif %}{{ pc.country_to|flag }} {{ pc.country_to or '-' }}</span>
|
||||
<span>→ {{ pc.recipient_name or '-' }}</span>
|
||||
</div>
|
||||
<span class="badge badge-{{ pc.status }}">{{ {'sent':'已寄出','delivered':'已送达'}.get(pc.status) if user.language=='zh' else {'sent':'Sent','delivered':'Delivered'}.get(pc.status) }}</span>
|
||||
|
||||
@@ -49,8 +49,8 @@
|
||||
<img src="{{ pc.image_front }}" alt="" class="showcase-card-img" loading="lazy">
|
||||
<div class="showcase-card-body">
|
||||
<div class="showcase-card-meta">
|
||||
{% if pc.country_from and pc.country %}<span>{{ pc.country_from|flag }} {{ pc.country_from }} → {{ pc.country|flag }} {{ pc.country }}</span>
|
||||
{% elif pc.country %}<span>{{ pc.country|flag }}</span>
|
||||
{% if pc.country_to_from and pc.country_to %}<span>{{ pc.country_to_from|flag }} {{ pc.country_to_from }} → {{ pc.country_to|flag }} {{ pc.country_to }}</span>
|
||||
{% elif pc.country_to %}<span>{{ pc.country_to|flag }}</span>
|
||||
{% endif %}
|
||||
{% if pc.send_time %}<span>{{ pc.send_time.strftime('%Y-%m-%d') }}</span>{% endif %}
|
||||
</div>
|
||||
@@ -74,8 +74,8 @@
|
||||
<img src="{{ pc.image_front }}" alt="" class="showcase-card-img" loading="lazy">
|
||||
<div class="showcase-card-body">
|
||||
<div class="showcase-card-meta">
|
||||
{% if pc.country_from and pc.country %}<span>{{ pc.country_from|flag }} {{ pc.country_from }} → {{ pc.country|flag }} {{ pc.country }}</span>
|
||||
{% elif pc.country %}<span>{{ pc.country|flag }}</span>
|
||||
{% if pc.country_to_from and pc.country_to %}<span>{{ pc.country_to_from|flag }} {{ pc.country_to_from }} → {{ pc.country_to|flag }} {{ pc.country_to }}</span>
|
||||
{% elif pc.country_to %}<span>{{ pc.country_to|flag }}</span>
|
||||
{% endif %}
|
||||
{% if pc.send_time %}<span>{{ pc.send_time.strftime('%Y-%m-%d') }}</span>{% endif %}
|
||||
</div>
|
||||
@@ -98,8 +98,8 @@
|
||||
<img src="{{ pc.image_front }}" alt="" class="showcase-card-img" loading="lazy">
|
||||
<div class="showcase-card-body">
|
||||
<div class="showcase-card-meta">
|
||||
{% if pc.country_from and pc.country %}<span>{{ pc.country_from|flag }} {{ pc.country_from }} → {{ pc.country|flag }} {{ pc.country }}</span>
|
||||
{% elif pc.country %}<span>{{ pc.country|flag }}</span>
|
||||
{% if pc.country_to_from and pc.country_to %}<span>{{ pc.country_to_from|flag }} {{ pc.country_to_from }} → {{ pc.country_to|flag }} {{ pc.country_to }}</span>
|
||||
{% elif pc.country_to %}<span>{{ pc.country_to|flag }}</span>
|
||||
{% endif %}
|
||||
{% if pc.receive_time %}<span>{{ pc.receive_time.strftime('%Y-%m-%d') }}</span>{% endif %}
|
||||
</div>
|
||||
@@ -123,8 +123,8 @@
|
||||
<img src="{{ pc.image_front }}" alt="" class="showcase-card-img" loading="lazy">
|
||||
<div class="showcase-card-body">
|
||||
<div class="showcase-card-meta">
|
||||
{% if pc.country_from and pc.country %}<span>{{ pc.country_from|flag }} {{ pc.country_from }} → {{ pc.country|flag }} {{ pc.country }}</span>
|
||||
{% elif pc.country %}<span>{{ pc.country|flag }}</span>
|
||||
{% if pc.country_to_from and pc.country_to %}<span>{{ pc.country_to_from|flag }} {{ pc.country_to_from }} → {{ pc.country_to|flag }} {{ pc.country_to }}</span>
|
||||
{% elif pc.country_to %}<span>{{ pc.country_to|flag }}</span>
|
||||
{% endif %}
|
||||
{% if pc.receive_time %}<span>{{ pc.receive_time.strftime('%Y-%m-%d') }}</span>{% endif %}
|
||||
</div>
|
||||
@@ -169,8 +169,8 @@ function _appendCard(c, gridId) {
|
||||
div.setAttribute('data-front', c.image_front);
|
||||
div.onclick = function() { openLightbox(div); };
|
||||
var countryHtml = '';
|
||||
if (c.country_from && c.country) countryHtml = '<span>' + _flag(c.country_from) + ' ' + c.country_from + ' → ' + _flag(c.country) + ' ' + c.country + '</span>';
|
||||
else if (c.country) countryHtml = '<span>' + _flag(c.country) + '</span>';
|
||||
if (c.country_from && c.country_to) countryHtml = '<span>' + _flag(c.country_from) + ' ' + c.country_from + ' → ' + _flag(c.country_to) + ' ' + c.country_to + '</span>';
|
||||
else if (c.country_to) countryHtml = '<span>' + _flag(c.country_to) + '</span>';
|
||||
div.innerHTML = '<img src="' + c.image_front + '" alt="" class="showcase-card-img" loading="lazy">' +
|
||||
'<div class="showcase-card-body"><div class="showcase-card-meta">' + countryHtml + '</div></div>';
|
||||
grid.appendChild(div);
|
||||
|
||||
Reference in New Issue
Block a user