bump project

This commit is contained in:
2026-05-01 21:24:21 +03:30
parent dc4b1a1400
commit 139b3e26da
83 changed files with 2455 additions and 18349 deletions

View File

@@ -0,0 +1,31 @@
{% extends "base.html" %}
{% from "macros/forms.html" import render_field, render_select %}
{% block title %}Create account · Face Attendance{% endblock %}
{% block content %}
<div class="page-header">
<div>
<p class="eyebrow">Administration</p>
<h1>Create account</h1>
</div>
<a class="btn btn-outline-secondary" href="{{ url_for('admin.accounts') }}">Back</a>
</div>
<section class="form-section">
<form method="post" novalidate>
{{ form.hidden_tag() }}
<div class="row g-3">
<div class="col-md-6">{{ render_field(form.full_name) }}</div>
<div class="col-md-6">{{ render_field(form.username) }}</div>
<div class="col-md-6">{{ render_field(form.email) }}</div>
<div class="col-md-6">{{ render_select(form.role) }}</div>
<div class="col-md-6">{{ render_field(form.password) }}</div>
<div class="col-md-6">{{ render_field(form.confirm_password) }}</div>
</div>
<div class="form-actions">
{{ form.submit(class="btn btn-primary") }}
</div>
</form>
</section>
{% endblock %}

View File

@@ -0,0 +1,53 @@
{% extends "base.html" %}
{% block title %}Accounts · Face Attendance{% endblock %}
{% block content %}
<div class="page-header">
<div>
<p class="eyebrow">Administration</p>
<h1>Accounts</h1>
</div>
<a class="btn btn-primary" href="{{ url_for('admin.new_account') }}">Create account</a>
</div>
<section class="content-section">
{% if accounts %}
<div class="table-responsive">
<table class="table align-middle">
<thead>
<tr>
<th>Name</th>
<th>Username</th>
<th>Email</th>
<th>Role</th>
<th>Status</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
{% for account in accounts %}
<tr>
<td>{{ account.full_name }}</td>
<td>{{ account.username }}</td>
<td>{{ account.email }}</td>
<td>{{ account.role|title }}</td>
<td><span class="badge text-bg-{{ 'success' if account.active else 'secondary' }}">{{ "Active" if account.active else "Inactive" }}</span></td>
<td class="text-end">
{% if account.id != current_user.id %}
<form method="post" action="{{ url_for('admin.toggle_account', account_id=account.id) }}" class="d-inline">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button class="btn btn-outline-secondary btn-sm" type="submit">{{ "Deactivate" if account.active else "Activate" }}</button>
</form>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="empty-state">No staff accounts exist yet.</div>
{% endif %}
</section>
{% endblock %}

View File

@@ -0,0 +1,48 @@
{% extends "base.html" %}
{% block title %}Attendance · Face Attendance{% endblock %}
{% block content %}
<div class="page-header">
<div>
<p class="eyebrow">Reports</p>
<h1>Attendance</h1>
</div>
{% if current_user.can_operate %}
<a class="btn btn-primary" href="{{ url_for('attendance.kiosk') }}">Open kiosk</a>
{% endif %}
</div>
<section class="content-section">
{% if events %}
<div class="table-responsive">
<table class="table align-middle">
<thead>
<tr>
<th>Person</th>
<th>Employee ID</th>
<th>Type</th>
<th>Time</th>
<th>Source</th>
<th>Recorded by</th>
</tr>
</thead>
<tbody>
{% for event in events %}
<tr>
<td><a href="{{ url_for('people.detail', person_id=event.person.id) }}">{{ event.person.full_name }}</a></td>
<td>{{ event.person.employee_id }}</td>
<td><span class="badge text-bg-{{ 'success' if event.event_type == 'check_in' else 'warning' }}">{{ event.type_label }}</span></td>
<td>{{ event.occurred_at.strftime("%Y-%m-%d %H:%M") }}</td>
<td>{{ event.source }}</td>
<td>{{ event.created_by.full_name if event.created_by else "System" }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="empty-state">No attendance has been recorded yet.</div>
{% endif %}
</section>
{% endblock %}

View File

@@ -0,0 +1,39 @@
{% extends "base.html" %}
{% block title %}Kiosk · Face Attendance{% endblock %}
{% block content %}
<div class="page-header">
<div>
<p class="eyebrow">Recognition</p>
<h1>Attendance kiosk</h1>
</div>
<a class="btn btn-outline-secondary" href="{{ url_for('attendance.index') }}">Reports</a>
</div>
<div class="kiosk-grid" data-identify-url="{{ url_for('recognition.identify') }}" data-record-url="{{ url_for('attendance.create_event') }}">
<section class="camera-panel">
<div class="camera-frame">
<video id="cameraStream" autoplay playsinline muted></video>
<img id="snapshotPreview" alt="Processed camera snapshot">
<canvas id="snapshotCanvas"></canvas>
</div>
<div class="camera-actions">
<button class="btn btn-outline-secondary" id="startCamera" type="button">Start camera</button>
<button class="btn btn-primary" id="capturePhoto" type="button" disabled>Capture and identify</button>
</div>
<p class="text-secondary small mb-0" id="cameraStatus">Camera is not active.</p>
</section>
<section class="content-section result-panel">
<h2>Recognition results</h2>
<div id="recognitionResults" class="result-list">
<div class="empty-state">Capture a face to see matching people.</div>
</div>
</section>
</div>
{% endblock %}
{% block scripts %}
<script src="{{ url_for('static', filename='js/kiosk.js') }}"></script>
{% endblock %}

View File

@@ -0,0 +1,27 @@
{% extends "base.html" %}
{% from "macros/forms.html" import render_field %}
{% block title %}Sign in · Face Attendance{% endblock %}
{% block content %}
<div class="auth-layout">
<section class="auth-panel">
<div class="mb-4">
<p class="eyebrow">Secure attendance management</p>
<h1 class="h3 mb-2">Sign in</h1>
<p class="text-secondary mb-0">Use your staff account to access the attendance system.</p>
</div>
<form method="post" novalidate>
{{ form.hidden_tag() }}
{{ render_field(form.username, "username") }}
{{ render_field(form.password, "password") }}
<div class="form-check mb-4">
{{ form.remember(class="form-check-input") }}
{{ form.remember.label(class="form-check-label") }}
</div>
{{ form.submit(class="btn btn-primary w-100") }}
</form>
</section>
</div>
{% endblock %}

65
app/templates/base.html Normal file
View File

@@ -0,0 +1,65 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{% block title %}Face Attendance{% endblock %}</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="{{ url_for('static', filename='css/app.css') }}">
</head>
<body>
{% if current_user.is_authenticated %}
<nav class="navbar navbar-expand-lg border-bottom bg-white sticky-top">
<div class="container-fluid px-4">
<a class="navbar-brand fw-semibold" href="{{ url_for('main.dashboard') }}">Face Attendance</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#mainNav" aria-controls="mainNav" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="mainNav">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item"><a class="nav-link" href="{{ url_for('main.dashboard') }}">Dashboard</a></li>
{% if current_user.can_operate %}
<li class="nav-item"><a class="nav-link" href="{{ url_for('attendance.kiosk') }}">Kiosk</a></li>
{% endif %}
<li class="nav-item"><a class="nav-link" href="{{ url_for('people.index') }}">People</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('attendance.index') }}">Attendance</a></li>
{% if current_user.is_admin %}
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin.accounts') }}">Accounts</a></li>
{% endif %}
</ul>
<div class="d-flex align-items-center gap-3">
<span class="small text-secondary">{{ current_user.full_name }} · {{ current_user.role|title }}</span>
<form method="post" action="{{ url_for('auth.logout') }}">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button class="btn btn-outline-secondary btn-sm" type="submit">Sign out</button>
</form>
</div>
</div>
</div>
</nav>
{% endif %}
<main class="page-shell">
<div class="container-fluid px-4">
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
<div class="flash-stack">
{% for category, message in messages %}
<div class="alert alert-{{ category }} alert-dismissible fade show" role="alert">
{{ message }}
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
{% endfor %}
</div>
{% endif %}
{% endwith %}
{% block content %}{% endblock %}
</div>
</main>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"></script>
{% block scripts %}{% endblock %}
</body>
</html>

View File

@@ -0,0 +1,67 @@
{% extends "base.html" %}
{% block title %}Dashboard · Face Attendance{% endblock %}
{% block content %}
<div class="page-header">
<div>
<p class="eyebrow">Overview</p>
<h1>Dashboard</h1>
</div>
{% if current_user.can_operate %}
<a class="btn btn-primary" href="{{ url_for('attendance.kiosk') }}">Open kiosk</a>
{% endif %}
</div>
<div class="stats-grid">
<div class="stat-card">
<span>Active people</span>
<strong>{{ stats.active_people }}</strong>
</div>
<div class="stat-card">
<span>Total people</span>
<strong>{{ stats.people }}</strong>
</div>
<div class="stat-card">
<span>Attendance events</span>
<strong>{{ stats.events }}</strong>
</div>
<div class="stat-card">
<span>Staff accounts</span>
<strong>{{ stats.accounts }}</strong>
</div>
</div>
<section class="content-section">
<div class="section-header">
<h2>Recent attendance</h2>
<a href="{{ url_for('attendance.index') }}">View all</a>
</div>
{% if latest_events %}
<div class="table-responsive">
<table class="table align-middle">
<thead>
<tr>
<th>Person</th>
<th>Type</th>
<th>Time</th>
<th>Recorded by</th>
</tr>
</thead>
<tbody>
{% for event in latest_events %}
<tr>
<td>{{ event.person.full_name }}</td>
<td><span class="badge text-bg-{{ 'success' if event.event_type == 'check_in' else 'warning' }}">{{ event.type_label }}</span></td>
<td>{{ event.occurred_at.strftime("%Y-%m-%d %H:%M") }}</td>
<td>{{ event.created_by.full_name if event.created_by else "System" }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="empty-state">No attendance has been recorded yet.</div>
{% endif %}
</section>
{% endblock %}

View File

@@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block title %}Access denied · Face Attendance{% endblock %}
{% block content %}
<section class="error-page">
<h1>Access denied</h1>
<p>Your account does not have permission to perform this action.</p>
<a class="btn btn-primary" href="{{ url_for('main.dashboard') }}">Go to dashboard</a>
</section>
{% endblock %}

View File

@@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block title %}Not found · Face Attendance{% endblock %}
{% block content %}
<section class="error-page">
<h1>Page not found</h1>
<p>The page or record you requested does not exist.</p>
<a class="btn btn-primary" href="{{ url_for('main.dashboard') }}">Go to dashboard</a>
</section>
{% endblock %}

View File

@@ -0,0 +1,9 @@
{% extends "base.html" %}
{% block title %}Server error · Face Attendance{% endblock %}
{% block content %}
<section class="error-page">
<h1>Server error</h1>
<p>The application could not complete the request. The error has been logged.</p>
<a class="btn btn-primary" href="{{ url_for('main.dashboard') }}">Go to dashboard</a>
</section>
{% endblock %}

View File

@@ -0,0 +1,35 @@
{% macro render_field(field, placeholder='') %}
<div class="mb-3">
{{ field.label(class="form-label") }}
{{ field(class="form-control" + (" is-invalid" if field.errors else ""), placeholder=placeholder) }}
{% if field.errors %}
<div class="invalid-feedback">
{{ field.errors|join(" ") }}
</div>
{% endif %}
</div>
{% endmacro %}
{% macro render_textarea(field, rows=4) %}
<div class="mb-3">
{{ field.label(class="form-label") }}
{{ field(class="form-control" + (" is-invalid" if field.errors else ""), rows=rows) }}
{% if field.errors %}
<div class="invalid-feedback">
{{ field.errors|join(" ") }}
</div>
{% endif %}
</div>
{% endmacro %}
{% macro render_select(field) %}
<div class="mb-3">
{{ field.label(class="form-label") }}
{{ field(class="form-select" + (" is-invalid" if field.errors else "")) }}
{% if field.errors %}
<div class="invalid-feedback">
{{ field.errors|join(" ") }}
</div>
{% endif %}
</div>
{% endmacro %}

View File

@@ -0,0 +1,46 @@
{% extends "base.html" %}
{% block title %}{{ person.full_name }} · Face Attendance{% endblock %}
{% block content %}
<div class="page-header">
<div>
<p class="eyebrow">Person profile</p>
<h1>{{ person.full_name }}</h1>
<p class="text-secondary mb-0">{{ person.employee_id }} · {{ "Active" if person.active else "Inactive" }}</p>
</div>
<a class="btn btn-outline-secondary" href="{{ url_for('people.index') }}">Back</a>
</div>
<div class="detail-grid">
<section class="content-section">
<h2>Profile</h2>
<dl class="detail-list">
<dt>Employee ID</dt>
<dd>{{ person.employee_id }}</dd>
<dt>Face samples</dt>
<dd>{{ person.face_encodings|length }}</dd>
<dt>Last presence</dt>
<dd>{{ presence_summary }}</dd>
<dt>Notes</dt>
<dd>{{ person.notes or "No notes" }}</dd>
</dl>
</section>
<section class="content-section">
<h2>Recent events</h2>
{% if events %}
<div class="event-list">
{% for event in events %}
<div class="event-row">
<span class="badge text-bg-{{ 'success' if event.event_type == 'check_in' else 'warning' }}">{{ event.type_label }}</span>
<span>{{ event.occurred_at.strftime("%Y-%m-%d %H:%M") }}</span>
</div>
{% endfor %}
</div>
{% else %}
<div class="empty-state">No attendance events for this person.</div>
{% endif %}
</section>
</div>
{% endblock %}

View File

@@ -0,0 +1,39 @@
{% extends "base.html" %}
{% from "macros/forms.html" import render_field, render_textarea %}
{% block title %}Enroll person · Face Attendance{% endblock %}
{% block content %}
<div class="page-header">
<div>
<p class="eyebrow">Enrollment</p>
<h1>Enroll person</h1>
</div>
<a class="btn btn-outline-secondary" href="{{ url_for('people.index') }}">Back</a>
</div>
<section class="form-section">
<form method="post" enctype="multipart/form-data" novalidate>
{{ form.hidden_tag() }}
<div class="row g-3">
<div class="col-md-6">{{ render_field(form.full_name) }}</div>
<div class="col-md-6">{{ render_field(form.employee_id) }}</div>
<div class="col-12">{{ render_textarea(form.notes, 3) }}</div>
</div>
<div class="upload-grid">
{% for field in [form.photo_1, form.photo_2, form.photo_3, form.photo_4] %}
<div>
{{ field.label(class="form-label") }}
{{ field(class="form-control", accept="image/png,image/jpeg") }}
</div>
{% endfor %}
</div>
<p class="form-help">Upload one to four clear single-face photos. More samples usually improve recognition quality.</p>
<div class="form-actions">
{{ form.submit(class="btn btn-primary") }}
</div>
</form>
</section>
{% endblock %}

View File

@@ -0,0 +1,53 @@
{% extends "base.html" %}
{% block title %}People · Face Attendance{% endblock %}
{% block content %}
<div class="page-header">
<div>
<p class="eyebrow">Enrollment</p>
<h1>People</h1>
</div>
{% if current_user.can_operate %}
<a class="btn btn-primary" href="{{ url_for('people.new_person') }}">Enroll person</a>
{% endif %}
</div>
<section class="content-section">
{% if people %}
<div class="table-responsive">
<table class="table align-middle">
<thead>
<tr>
<th>Name</th>
<th>Employee ID</th>
<th>Face samples</th>
<th>Status</th>
<th class="text-end">Actions</th>
</tr>
</thead>
<tbody>
{% for person in people %}
<tr>
<td><a href="{{ url_for('people.detail', person_id=person.id) }}">{{ person.full_name }}</a></td>
<td>{{ person.employee_id }}</td>
<td>{{ person.face_encodings|length }}</td>
<td><span class="badge text-bg-{{ 'success' if person.active else 'secondary' }}">{{ "Active" if person.active else "Inactive" }}</span></td>
<td class="text-end">
{% if current_user.can_operate %}
<form method="post" action="{{ url_for('people.toggle_person', person_id=person.id) }}" class="d-inline">
<input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
<button class="btn btn-outline-secondary btn-sm" type="submit">{{ "Deactivate" if person.active else "Activate" }}</button>
</form>
{% endif %}
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="empty-state">No people have been enrolled yet.</div>
{% endif %}
</section>
{% endblock %}