feat: add school management auth and student CRUD UI

This commit is contained in:
Sina
2026-09-24 23:34:21 +03:30
parent 12e9efcb5c
commit 8a196f8c4f
20 changed files with 326 additions and 9 deletions

38
templates/base.html Normal file
View File

@@ -0,0 +1,38 @@
{% load static %}
<!doctype html>
<html lang="fa" dir="rtl">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{% block title %}مدرسه‌یار{% endblock %}</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Vazirmatn:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="{% static 'css/style.css' %}">
</head>
<body>
<div class="app-shell">
{% if user.is_authenticated %}
<aside class="sidebar">
<a class="brand" href="{% url 'dashboard' %}">
<span class="brand-mark">م</span>
<span><strong>مدرسه‌یار</strong><small>مدیریت هوشمند مدرسه</small></span>
</a>
<nav class="main-nav">
<a class="nav-link {% if request.resolver_match.url_name == 'dashboard' %}active{% endif %}" href="{% url 'dashboard' %}"><span>▦</span> داشبورد</a>
<a class="nav-link {% if request.resolver_match.url_name == 'student_add' %}active{% endif %}" href="{% url 'student_add' %}"><span>+</span> ثبت دانش‌آموز</a>
</nav>
<div class="sidebar-footer">
<div class="profile-mini"><span class="avatar">{{ user.username|first|upper }}</span><span><b>{{ user.username }}</b><small>مدیر مدرسه</small></span></div>
<form action="{% url 'logout' %}" method="post">{% csrf_token %}<button class="logout-link" type="submit">خروج از حساب <span>↪</span></button></form>
</div>
</aside>
{% endif %}
<main class="main-content {% if not user.is_authenticated %}full-content{% endif %}">
{% if messages %}<div class="messages">{% for message in messages %}<div class="message {{ message.tags }}">{{ message }}</div>{% endfor %}</div>{% endif %}
{% block content %}{% endblock %}
</main>
</div>
<script src="{% static 'js/app.js' %}"></script>
</body>
</html>

View File

@@ -0,0 +1 @@
{% for field in form %}<div class="field-group">{{ field.label_tag }}{{ field }}{% if field.help_text %}<small class="help-text">{{ field.help_text|safe }}</small>{% endif %}{% for error in field.errors %}<small class="error-text">{{ error }}</small>{% endfor %}</div>{% endfor %}{% if form.non_field_errors %}<div class="error-text">{{ form.non_field_errors }}</div>{% endif %}

View File

@@ -0,0 +1,5 @@
{% extends 'base.html' %}
{% block title %}ورود مدیر | مدرسه‌یار{% endblock %}
{% block content %}
<section class="auth-layout"><div class="auth-intro"><span class="eyebrow">پنل مدیریت مدرسه</span><h1>مدرسه را با آرامش مدیریت کنید.</h1><p>اطلاعات دانش‌آموزان را یک‌جا، دقیق و همیشه در دسترس داشته باشید.</p><div class="intro-note"><span>✦</span><span>فضایی امن برای مدیریت روزانه مدرسه</span></div></div><div class="auth-card"><div class="auth-icon">◈</div><h2>خوش آمدید</h2><p class="muted">برای ورود به پنل مدیریت اطلاعات خود را وارد کنید.</p><form method="post" class="form-stack">{% csrf_token %}{% include 'registration/form_fields.html' with form=form %}<button class="button button-primary button-wide" type="submit">ورود به داشبورد <span>←</span></button></form><p class="auth-footer">حساب مدیر ندارید؟ <a href="{% url 'signup' %}">ثبت‌نام کنید</a></p></div></section>
{% endblock %}

View File

@@ -0,0 +1,5 @@
{% extends 'base.html' %}
{% block title %}ثبت‌نام مدیر | مدرسه‌یار{% endblock %}
{% block content %}
<section class="auth-layout"><div class="auth-intro"><span class="eyebrow">شروعی ساده و سریع</span><h1>پنل اختصاصی مدرسه‌تان را بسازید.</h1><p>با چند قدم کوتاه، مدیریت اطلاعات دانش‌آموزان را منظم‌تر کنید.</p></div><div class="auth-card"><div class="auth-icon">✦</div><h2>ساخت حساب مدیر</h2><p class="muted">اطلاعات ورود خود را برای استفاده از پنل بسازید.</p><form method="post" class="form-stack">{% csrf_token %}{% include 'registration/form_fields.html' with form=form %}<button class="button button-primary button-wide" type="submit">ساخت حساب و ورود <span>←</span></button></form><p class="auth-footer">قبلاً ثبت‌نام کرده‌اید؟ <a href="{% url 'login' %}">وارد شوید</a></p></div></section>
{% endblock %}

View File

@@ -0,0 +1,3 @@
{% extends 'base.html' %}
{% block title %}داشبورد | مدرسه‌یار{% endblock %}
{% block content %}<header class="topbar"><div><span class="eyebrow">مرکز کنترل</span><h1>سلام، {{ user.username }} <span class="wave">✦</span></h1><p>امروز چه چیزی را مدیریت می‌کنیم؟</p></div><a class="button button-primary" href="{% url 'student_add' %}"><span>+</span> ثبت دانش‌آموز</a></header><section class="stats-grid"><article class="stat-card stat-main"><div class="stat-icon">♧</div><div><span>کل دانش‌آموزان</span><strong>{{ total_students }}</strong><small>پرونده ثبت‌شده در مدرسه</small></div></article><article class="stat-card"><div class="stat-icon soft-blue">⌁</div><div><span>میانگین سنی</span><strong>{{ average_age }}</strong><small>سال</small></div></article><article class="stat-card"><div class="stat-icon soft-gold">◌</div><div><span>پایه‌های فعال</span><strong>{{ grade_count }}</strong><small>پایه تحصیلی</small></div></article></section><section class="list-section"><div class="section-heading"><div><h2>فهرست دانش‌آموزان</h2><p>آخرین اطلاعات ثبت‌شده در سیستم</p></div><span class="count-badge">{{ total_students }} نفر</span></div>{% if students %}<div class="table-wrap"><table><thead><tr><th>دانش‌آموز</th><th>سن</th><th>پایه تحصیلی</th><th>تاریخ ثبت</th><th><span class="sr-only">عملیات</span></th></tr></thead><tbody>{% for student in students %}<tr><td><div class="student-cell"><span class="student-avatar avatar-{{ forloop.counter|divisibleby:3|yesno:'pink,blue' }}">{{ student.first_name|first }}</span><div><strong>{{ student.first_name }} {{ student.last_name }}</strong><small>شناسه #{{ student.pk|stringformat:'04d' }}</small></div></div></td><td>{{ student.age }} سال</td><td><span class="grade-pill">{{ student.get_grade_display }}</span></td><td>{{ student.created_at|date:'Y/m/d' }}</td><td><div class="row-actions"><a href="{% url 'student_edit' student.pk %}" title="ویرایش">✎</a><a class="delete-action" href="{% url 'student_delete' student.pk %}" title="حذف">⌫</a></div></td></tr>{% endfor %}</tbody></table></div>{% else %}<div class="empty-state"><div class="empty-icon">♧</div><h3>هنوز دانش‌آموزی ثبت نشده است</h3><p>اولین پرونده را ثبت کنید تا فهرست مدرسه شکل بگیرد.</p><a class="button button-primary" href="{% url 'student_add' %}">ثبت اولین دانش‌آموز</a></div>{% endif %}</section>{% endblock %}

View File

@@ -0,0 +1,3 @@
{% extends 'base.html' %}
{% block title %}حذف دانش‌آموز | مدرسه‌یار{% endblock %}
{% block content %}<section class="confirm-panel"><div class="danger-icon">!</div><span class="eyebrow">حذف پرونده</span><h1>حذف {{ object }}؟</h1><p>این اطلاعات برای همیشه حذف می‌شود و امکان بازگردانی آن وجود ندارد.</p><form method="post" class="form-actions">{% csrf_token %}<a class="button button-ghost" href="{% url 'dashboard' %}">انصراف</a><button class="button button-danger" type="submit">بله، حذف شود</button></form></section>{% endblock %}

View File

@@ -0,0 +1,3 @@
{% extends 'base.html' %}
{% block title %}{% if object %}ویرایش دانش‌آموز{% else %}ثبت دانش‌آموز{% endif %} | مدرسه‌یار{% endblock %}
{% block content %}<div class="page-header"><div><span class="eyebrow">اطلاعات دانش‌آموز</span><h1>{% if object %}ویرایش اطلاعات{% else %}ثبت دانش‌آموز جدید{% endif %}</h1><p>اطلاعات را با دقت وارد کنید تا پرونده دانش‌آموز کامل بماند.</p></div><a class="button button-ghost" href="{% url 'dashboard' %}">بازگشت به فهرست</a></div><section class="form-panel"><form method="post" class="student-form">{% csrf_token %}<div class="form-grid">{% for field in form %}<div class="field-group">{{ field.label_tag }}{{ field }}{% for error in field.errors %}<small class="error-text">{{ error }}</small>{% endfor %}</div>{% endfor %}</div><div class="form-actions"><a class="button button-ghost" href="{% url 'dashboard' %}">انصراف</a><button class="button button-primary" type="submit">{% if object %}ذخیره تغییرات{% else %}ثبت دانش‌آموز{% endif %} <span>←</span></button></div></form></section>{% endblock %}