144 lines
6.3 KiB
HTML
144 lines
6.3 KiB
HTML
|
|
{% extends "base.html" %}
|
||
|
|
{% set editing = session is not none %}
|
||
|
|
{% block title %}{{ 'Edit session' if editing else 'New session' }} — The Shooter's Network{% endblock %}
|
||
|
|
{% block content %}
|
||
|
|
<h1>{{ 'Edit session' if editing else 'Log a session' }}</h1>
|
||
|
|
|
||
|
|
{% set f = prefill or session %}
|
||
|
|
|
||
|
|
<form method="post"
|
||
|
|
action="{{ url_for('sessions.edit', session_id=session.id) if editing else url_for('sessions.new') }}"
|
||
|
|
style="max-width:580px;">
|
||
|
|
|
||
|
|
<h2>Basic info</h2>
|
||
|
|
|
||
|
|
<div style="display:grid;grid-template-columns:1fr 1fr;gap:1rem;margin-bottom:1rem;">
|
||
|
|
<div>
|
||
|
|
<label class="fl">Date *</label>
|
||
|
|
<input type="date" name="session_date" required
|
||
|
|
value="{{ (f.session_date.isoformat() if f.session_date else '') if f else (today or '') }}"
|
||
|
|
style="width:100%;padding:0.55rem 0.75rem;border:1px solid #ccc;border-radius:4px;font-size:0.95rem;">
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<label class="fl">Distance (m)</label>
|
||
|
|
<input type="number" name="distance_m" min="1" max="5000"
|
||
|
|
value="{{ f.distance_m if f and f.distance_m else '' }}"
|
||
|
|
style="width:100%;padding:0.55rem 0.75rem;border:1px solid #ccc;border-radius:4px;font-size:0.95rem;">
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div style="margin-bottom:1rem;">
|
||
|
|
<label class="fl">Location</label>
|
||
|
|
<input type="text" name="location_name" value="{{ f.location_name if f else '' }}"
|
||
|
|
placeholder="e.g. Range name, city"
|
||
|
|
style="width:100%;padding:0.55rem 0.75rem;border:1px solid #ccc;border-radius:4px;font-size:0.95rem;">
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<h2>Weather</h2>
|
||
|
|
|
||
|
|
<div style="display:grid;grid-template-columns:repeat(3,1fr);gap:1rem;margin-bottom:1rem;">
|
||
|
|
<div>
|
||
|
|
<label class="fl">Condition</label>
|
||
|
|
<select name="weather_cond"
|
||
|
|
style="width:100%;padding:0.55rem 0.75rem;border:1px solid #ccc;border-radius:4px;font-size:0.93rem;background:#fff;">
|
||
|
|
{% for val, label in weather_conditions %}
|
||
|
|
<option value="{{ val }}" {% if f and f.weather_cond == val %}selected{% endif %}>{{ label }}</option>
|
||
|
|
{% endfor %}
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<label class="fl">Temp (°C)</label>
|
||
|
|
<input type="number" name="weather_temp_c" step="0.1"
|
||
|
|
value="{{ f.weather_temp_c if f and f.weather_temp_c is not none else '' }}"
|
||
|
|
style="width:100%;padding:0.55rem 0.75rem;border:1px solid #ccc;border-radius:4px;font-size:0.95rem;">
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<label class="fl">Wind (km/h)</label>
|
||
|
|
<input type="number" name="weather_wind_kph" step="0.1" min="0"
|
||
|
|
value="{{ f.weather_wind_kph if f and f.weather_wind_kph is not none else '' }}"
|
||
|
|
style="width:100%;padding:0.55rem 0.75rem;border:1px solid #ccc;border-radius:4px;font-size:0.95rem;">
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<h2>Equipment & Ammo</h2>
|
||
|
|
|
||
|
|
<div style="display:grid;grid-template-columns:1fr 1fr;gap:1rem;margin-bottom:1rem;">
|
||
|
|
<div>
|
||
|
|
<label class="fl">Rifle / Handgun</label>
|
||
|
|
<select name="rifle_id"
|
||
|
|
style="width:100%;padding:0.55rem 0.75rem;border:1px solid #ccc;border-radius:4px;font-size:0.93rem;background:#fff;">
|
||
|
|
<option value="">— none —</option>
|
||
|
|
{% for r in rifles %}
|
||
|
|
<option value="{{ r.id }}" {% if f and f.rifle_id == r.id %}selected{% endif %}>
|
||
|
|
{{ r.name }}{% if r.caliber %} ({{ r.caliber }}){% endif %}
|
||
|
|
</option>
|
||
|
|
{% endfor %}
|
||
|
|
</select>
|
||
|
|
{% if not rifles %}
|
||
|
|
<div style="font-size:0.78rem;color:#aaa;margin-top:.25rem;">
|
||
|
|
<a href="{{ url_for('equipment.new') }}">Add a rifle first</a>
|
||
|
|
</div>
|
||
|
|
{% endif %}
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<label class="fl">Scope</label>
|
||
|
|
<select name="scope_id"
|
||
|
|
style="width:100%;padding:0.55rem 0.75rem;border:1px solid #ccc;border-radius:4px;font-size:0.93rem;background:#fff;">
|
||
|
|
<option value="">— none —</option>
|
||
|
|
{% for sc in scopes %}
|
||
|
|
<option value="{{ sc.id }}" {% if f and f.scope_id == sc.id %}selected{% endif %}>{{ sc.name }}</option>
|
||
|
|
{% endfor %}
|
||
|
|
</select>
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div style="display:grid;grid-template-columns:repeat(3,1fr);gap:1rem;margin-bottom:1rem;">
|
||
|
|
<div>
|
||
|
|
<label class="fl">Ammo brand</label>
|
||
|
|
<input type="text" name="ammo_brand" value="{{ f.ammo_brand if f else '' }}"
|
||
|
|
placeholder="e.g. Lapua, Federal"
|
||
|
|
style="width:100%;padding:0.55rem 0.75rem;border:1px solid #ccc;border-radius:4px;font-size:0.95rem;">
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<label class="fl">Bullet weight (gr)</label>
|
||
|
|
<input type="number" name="ammo_weight_gr" step="0.1" min="0"
|
||
|
|
value="{{ f.ammo_weight_gr if f and f.ammo_weight_gr is not none else '' }}"
|
||
|
|
style="width:100%;padding:0.55rem 0.75rem;border:1px solid #ccc;border-radius:4px;font-size:0.95rem;">
|
||
|
|
</div>
|
||
|
|
<div>
|
||
|
|
<label class="fl">Lot number</label>
|
||
|
|
<input type="text" name="ammo_lot" value="{{ f.ammo_lot if f else '' }}"
|
||
|
|
style="width:100%;padding:0.55rem 0.75rem;border:1px solid #ccc;border-radius:4px;font-size:0.95rem;">
|
||
|
|
</div>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<h2>Notes & Visibility</h2>
|
||
|
|
|
||
|
|
<div style="margin-bottom:1rem;">
|
||
|
|
<label class="fl">Notes</label>
|
||
|
|
<textarea name="notes" rows="4"
|
||
|
|
style="width:100%;padding:0.55rem 0.75rem;border:1px solid #ccc;border-radius:4px;font-size:0.95rem;resize:vertical;">{{ f.notes if f else '' }}</textarea>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div style="margin-bottom:1.5rem;">
|
||
|
|
<label style="display:flex;align-items:center;gap:0.6rem;cursor:pointer;font-size:0.95rem;">
|
||
|
|
<input type="checkbox" name="is_public" value="1"
|
||
|
|
{% if f and f.is_public %}checked{% endif %}
|
||
|
|
style="width:16px;height:16px;">
|
||
|
|
Make this session public (visible in the community feed)
|
||
|
|
</label>
|
||
|
|
</div>
|
||
|
|
|
||
|
|
<div style="display:flex;gap:1rem;align-items:center;">
|
||
|
|
<button type="submit"
|
||
|
|
style="background:#1a1a2e;color:#fff;border:none;border-radius:4px;padding:0.6rem 1.5rem;font-size:0.95rem;cursor:pointer;">
|
||
|
|
{{ 'Save changes' if editing else 'Log session' }}
|
||
|
|
</button>
|
||
|
|
<a href="{{ url_for('sessions.detail', session_id=session.id) if editing else url_for('sessions.index') }}"
|
||
|
|
style="font-size:0.9rem;color:#666;">Cancel</a>
|
||
|
|
</div>
|
||
|
|
</form>
|
||
|
|
|
||
|
|
<style>.fl { display:block; font-size:.88rem; font-weight:600; color:#444; margin-bottom:.3rem; }</style>
|
||
|
|
{% endblock %}
|