Commit ·
4d2f561
1
Parent(s): 417bff4
確定済みのみExcel/PDFエクスポートを許可
Browse files- バックエンド:未確定状態でアクセスするとエラーflashでシフト表に戻す
- UI:未確定時はExcel/PDFボタンをdisabledに(ホバーでツールチップ表示)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- routes/export_routes.py +6 -0
- templates/schedule/index.html +9 -0
routes/export_routes.py
CHANGED
|
@@ -22,6 +22,9 @@ def excel(period_id):
|
|
| 22 |
if not period:
|
| 23 |
flash("期間が見つかりません", "error")
|
| 24 |
return redirect(url_for("schedule.index", period_id=period_id))
|
|
|
|
|
|
|
|
|
|
| 25 |
employees = repo.get_all_employees(active_only=True)
|
| 26 |
assignments = _assignments_dict(period_id)
|
| 27 |
buf = io.BytesIO()
|
|
@@ -38,6 +41,9 @@ def pdf(period_id):
|
|
| 38 |
if not period:
|
| 39 |
flash("期間が見つかりません", "error")
|
| 40 |
return redirect(url_for("schedule.index", period_id=period_id))
|
|
|
|
|
|
|
|
|
|
| 41 |
employees = repo.get_all_employees(active_only=True)
|
| 42 |
assignments = _assignments_dict(period_id)
|
| 43 |
buf = io.BytesIO()
|
|
|
|
| 22 |
if not period:
|
| 23 |
flash("期間が見つかりません", "error")
|
| 24 |
return redirect(url_for("schedule.index", period_id=period_id))
|
| 25 |
+
if period.status != "confirmed":
|
| 26 |
+
flash("確定済みのシフトのみエクスポートできます", "error")
|
| 27 |
+
return redirect(url_for("schedule.index", period_id=period_id))
|
| 28 |
employees = repo.get_all_employees(active_only=True)
|
| 29 |
assignments = _assignments_dict(period_id)
|
| 30 |
buf = io.BytesIO()
|
|
|
|
| 41 |
if not period:
|
| 42 |
flash("期間が見つかりません", "error")
|
| 43 |
return redirect(url_for("schedule.index", period_id=period_id))
|
| 44 |
+
if period.status != "confirmed":
|
| 45 |
+
flash("確定済みのシフトのみエクスポートできます", "error")
|
| 46 |
+
return redirect(url_for("schedule.index", period_id=period_id))
|
| 47 |
employees = repo.get_all_employees(active_only=True)
|
| 48 |
assignments = _assignments_dict(period_id)
|
| 49 |
buf = io.BytesIO()
|
templates/schedule/index.html
CHANGED
|
@@ -190,12 +190,21 @@
|
|
| 190 |
</div>
|
| 191 |
<div class="ms-auto d-flex gap-1">
|
| 192 |
{% if period %}
|
|
|
|
| 193 |
<a href="{{ url_for('export.excel', period_id=period.id) }}" class="btn btn-outline-light btn-sm">
|
| 194 |
<i class="bi bi-file-earmark-spreadsheet"></i>
|
| 195 |
</a>
|
| 196 |
<a href="{{ url_for('export.pdf', period_id=period.id) }}" class="btn btn-outline-light btn-sm">
|
| 197 |
<i class="bi bi-file-earmark-pdf"></i>
|
| 198 |
</a>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
<a href="{{ url_for('schedule.stats_multi') }}" class="btn btn-outline-light btn-sm">
|
| 200 |
<i class="bi bi-bar-chart-fill"></i>
|
| 201 |
</a>
|
|
|
|
| 190 |
</div>
|
| 191 |
<div class="ms-auto d-flex gap-1">
|
| 192 |
{% if period %}
|
| 193 |
+
{% if period.status == 'confirmed' %}
|
| 194 |
<a href="{{ url_for('export.excel', period_id=period.id) }}" class="btn btn-outline-light btn-sm">
|
| 195 |
<i class="bi bi-file-earmark-spreadsheet"></i>
|
| 196 |
</a>
|
| 197 |
<a href="{{ url_for('export.pdf', period_id=period.id) }}" class="btn btn-outline-light btn-sm">
|
| 198 |
<i class="bi bi-file-earmark-pdf"></i>
|
| 199 |
</a>
|
| 200 |
+
{% else %}
|
| 201 |
+
<button class="btn btn-outline-secondary btn-sm" disabled title="確定後にエクスポートできます">
|
| 202 |
+
<i class="bi bi-file-earmark-spreadsheet"></i>
|
| 203 |
+
</button>
|
| 204 |
+
<button class="btn btn-outline-secondary btn-sm" disabled title="確定後にエクスポートできます">
|
| 205 |
+
<i class="bi bi-file-earmark-pdf"></i>
|
| 206 |
+
</button>
|
| 207 |
+
{% endif %}
|
| 208 |
<a href="{{ url_for('schedule.stats_multi') }}" class="btn btn-outline-light btn-sm">
|
| 209 |
<i class="bi bi-bar-chart-fill"></i>
|
| 210 |
</a>
|