- version : 0.7

- description : adding download template option and move (template.csv -> templates/template.csv).
هذا الالتزام موجود في:
2025-06-11 18:19:44 +03:00
الأصل 6840e565a4
التزام c5d5c1408c
3 ملفات معدلة مع 41 إضافات و27 حذوفات

9
app.py
عرض الملف

@@ -2,7 +2,7 @@ import sqlite3
import csv import csv
import io import io
import re import re
from flask import Flask, render_template, request, redirect, url_for, flash from flask import Flask, render_template, request, redirect, url_for, flash, send_from_directory
# --- App Setup --- # --- App Setup ---
app = Flask(__name__) app = Flask(__name__)
@@ -228,5 +228,12 @@ def import_csv():
return redirect(url_for('index')) return redirect(url_for('index'))
# New route to download the CSV template
@app.route('/download_csv_template')
def download_csv_template():
# The directory where the template.csv is located (your templates folder)
# The second argument is the filename to be sent
return send_from_directory(app.template_folder, 'template.csv', as_attachment=True)
if __name__ == '__main__': if __name__ == '__main__':
app.run(debug=True) app.run(debug=True)

عرض الملف

@@ -71,6 +71,12 @@
<code class="text-xs font-mono">اسم الطالب, العمر, اسم ولي الأمر, هاتف ولي الأمر 1, هاتف ولي الأمر 2, هاتف الطالب, الصف, اسم المدرسة, العنوان, المحفوظات</code> <code class="text-xs font-mono">اسم الطالب, العمر, اسم ولي الأمر, هاتف ولي الأمر 1, هاتف ولي الأمر 2, هاتف الطالب, الصف, اسم المدرسة, العنوان, المحفوظات</code>
</p> </p>
<p>إذا كانت الحقول الاختيارية (هاتف ولي الأمر 2، هاتف الطالب) فارغة، اتركها كذلك.</p> <p>إذا كانت الحقول الاختيارية (هاتف ولي الأمر 2، هاتف الطالب) فارغة، اتركها كذلك.</p>
{# Added link to download CSV template #}
<p class="mt-3">
<a href="{{ url_for('download_csv_template') }}" class="text-blue-600 hover:underline font-semibold" download>
تنزيل قالب CSV
</a>
</p>
</div> </div>
<div class="mt-6 text-left"> <div class="mt-6 text-left">
<form id="import-form" action="{{ url_for('import_csv') }}" method="POST" enctype="multipart/form-data"> <form id="import-form" action="{{ url_for('import_csv') }}" method="POST" enctype="multipart/form-data">
@@ -89,6 +95,7 @@
</div> </div>
</div> </div>
<div class="bg-white p-6 rounded-xl shadow-lg"> <div class="bg-white p-6 rounded-xl shadow-lg">
<div class="flex justify-between items-center mb-4 pb-4 border-b"> <div class="flex justify-between items-center mb-4 pb-4 border-b">
<h2 class="text-2xl font-semibold text-gray-800">الطلاب المسجلون</h2> <h2 class="text-2xl font-semibold text-gray-800">الطلاب المسجلون</h2>

عرض الملف

لا يمكن عرض هذا الملف لأنه يحتوي على عدد خاطئ من الحقول في السطر 5.