first commit

This commit is contained in:
Mateusz Gruszczyński
2025-03-07 22:35:43 +01:00
commit 6bd6284f49
17 changed files with 652 additions and 0 deletions

View File

@ -0,0 +1,16 @@
{% extends 'base.html' %}
{% block title %}Dodaj wpłatę{% endblock %}
{% block content %}
<h1>Dodaj wpłatę do zbiórki: {{ zbiorka.nazwa }}</h1>
<form method="post">
<div class="mb-3">
<label for="kwota" class="form-label">Kwota wpłaty (PLN)</label>
<input type="number" step="0.01" class="form-control" id="kwota" name="kwota" required>
</div>
<div class="mb-3">
<label for="opis" class="form-label">Opis wpłaty (opcjonalnie)</label>
<textarea class="form-control" id="opis" name="opis" rows="3"></textarea>
</div>
<button type="submit" class="btn btn-success">Dodaj wpłatę</button>
</form>
{% endblock %}

View File

@ -0,0 +1,43 @@
{% extends 'base.html' %}
{% block title %}Dodaj zbiórkę{% endblock %}
{% block content %}
<h1>Dodaj nową zbiórkę</h1>
<form method="post">
<!-- Pozostałe pola formularza -->
<div class="mb-3">
<label for="nazwa" class="form-label">Nazwa zbiórki</label>
<input type="text" class="form-control" id="nazwa" name="nazwa" required>
</div>
<div class="mb-3">
<label for="opis" class="form-label">Opis</label>
<textarea class="form-control" id="opis" name="opis" rows="6" required></textarea>
</div>
<div class="mb-3">
<label for="numer_konta" class="form-label">Numer konta</label>
<input type="text" class="form-control" id="numer_konta" name="numer_konta" required>
</div>
<div class="mb-3">
<label for="numer_telefonu_blik" class="form-label">Numer telefonu BLIK</label>
<input type="text" class="form-control" id="numer_telefonu_blik" name="numer_telefonu_blik" required>
</div>
<div class="mb-3">
<label for="cel" class="form-label">Cel zbiórki (PLN)</label>
<input type="number" step="0.01" class="form-control" id="cel" name="cel" required>
</div>
<div class="form-check mb-3">
<input type="checkbox" class="form-check-input" id="ukryj_kwote" name="ukryj_kwote">
<label class="form-check-label" for="ukryj_kwote">Ukryj kwoty (cel i stan)</label>
</div>
<button type="submit" class="btn btn-success">Dodaj zbiórkę</button>
</form>
<!-- Inicjalizacja edytora Markdown (SimpleMDE) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
<script>
var simplemde = new SimpleMDE({
element: document.getElementById("opis"),
forceSync: true
});
</script>
{% endblock %}

View File

@ -0,0 +1,50 @@
{% extends 'base.html' %}
{% block title %}Panel Admina{% endblock %}
{% block content %}
<h1>Panel Admina</h1>
<div class="mb-3">
<a href="{{ url_for('dodaj_zbiorka') }}" class="btn btn-success">Dodaj zbiórkę</a>
</div>
<table class="table table-dark table-striped">
<thead>
<tr>
<th>ID</th>
<th>Nazwa</th>
<th>Widoczność</th>
<th>Opcje</th>
</tr>
</thead>
<tbody>
{% for z in zbiorki %}
<tr>
<td>{{ z.id }}</td>
<td>{{ z.nazwa }}</td>
<td>
{% if z.ukryta %}
<span class="badge bg-secondary">Ukryta</span>
{% else %}
<span class="badge bg-success">Widoczna</span>
{% endif %}
</td>
<td>
<a href="{{ url_for('edytuj_zbiorka', zbiorka_id=z.id) }}" class="btn btn-primary btn-sm">Edytuj</a>
<a href="{{ url_for('admin_dodaj_wplate', zbiorka_id=z.id) }}" class="btn btn-warning btn-sm">Dodaj wpłatę</a>
<a href="{{ url_for('edytuj_stan', zbiorka_id=z.id) }}" class="btn btn-info btn-sm">Edytuj stan</a>
<form action="{{ url_for('toggle_visibility', zbiorka_id=z.id) }}" method="post" style="display: inline;">
<button type="submit" class="btn btn-secondary btn-sm">
{% if z.ukryta %} Pokaż {% else %} Ukryj {% endif %}
</button>
</form>
<form action="{{ url_for('usun_zbiorka', zbiorka_id=z.id) }}" method="post" style="display: inline;">
<button type="submit" class="btn btn-danger btn-sm" onclick="return confirm('Czy na pewno chcesz usunąć tę zbiórkę?');">Usuń</button>
</form>
</td>
</tr>
{% else %}
<tr>
<td colspan="4">Brak zbiórek</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endblock %}

View File

@ -0,0 +1,43 @@
{% extends 'base.html' %}
{% block title %}Edytuj zbiórkę{% endblock %}
{% block content %}
<h1>Edytuj zbiórkę</h1>
<form method="post">
<!-- Pozostałe pola formularza -->
<div class="mb-3">
<label for="nazwa" class="form-label">Nazwa zbiórki</label>
<input type="text" class="form-control" id="nazwa" name="nazwa" value="{{ zbiorka.nazwa }}" required>
</div>
<div class="mb-3">
<label for="opis" class="form-label">Opis</label>
<textarea class="form-control" id="opis" name="opis" rows="6" required>{{ zbiorka.opis }}</textarea>
</div>
<div class="mb-3">
<label for="numer_konta" class="form-label">Numer konta</label>
<input type="text" class="form-control" id="numer_konta" name="numer_konta" value="{{ zbiorka.numer_konta }}" required>
</div>
<div class="mb-3">
<label for="numer_telefonu_blik" class="form-label">Numer telefonu BLIK</label>
<input type="text" class="form-control" id="numer_telefonu_blik" name="numer_telefonu_blik" value="{{ zbiorka.numer_telefonu_blik }}" required>
</div>
<div class="mb-3">
<label for="cel" class="form-label">Cel zbiórki (PLN)</label>
<input type="number" step="0.01" class="form-control" id="cel" name="cel" value="{{ zbiorka.cel }}" required>
</div>
<div class="form-check mb-3">
<input type="checkbox" class="form-check-input" id="ukryj_kwote" name="ukryj_kwote" {% if zbiorka.ukryj_kwote %}checked{% endif %}>
<label class="form-check-label" for="ukryj_kwote">Ukryj kwoty (cel i stan)</label>
</div>
<button type="submit" class="btn btn-primary">Zaktualizuj zbiórkę</button>
</form>
<!-- Inicjalizacja edytora Markdown (SimpleMDE) -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css">
<script src="https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js"></script>
<script>
var simplemde = new SimpleMDE({
element: document.getElementById("opis"),
forceSync: true
});
</script>
{% endblock %}

View File

@ -0,0 +1,13 @@
{% extends 'base.html' %}
{% block title %}Edytuj stan zbiórki{% endblock %}
{% block content %}
<h1>Edytuj stan zbiórki: {{ zbiorka.nazwa }}</h1>
<form method="post">
<div class="mb-3">
<label for="stan" class="form-label">Nowy stan zbiórki (PLN)</label>
<input type="number" step="0.01" class="form-control" id="stan" name="stan" value="{{ zbiorka.stan }}" required>
</div>
<button type="submit" class="btn btn-primary">Aktualizuj stan</button>
<a href="{{ url_for('admin_dashboard') }}" class="btn btn-secondary">Powrót</a>
</form>
{% endblock %}

39
templates/base.html Normal file
View File

@ -0,0 +1,39 @@
<!DOCTYPE html>
<html lang="pl">
<head>
<meta charset="UTF-8">
<title>{% block title %}Aplikacja Zbiórek{% endblock %}</title>
<!-- Bootswatch Darkly - atrakcyjny ciemny motyw -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootswatch@5.3.0/dist/darkly/bootstrap.min.css">
<!-- Opcjonalny plik custom.css dla drobnych modyfikacji -->
<link rel="stylesheet" href="{{ url_for('static', filename='css/custom.css') }}">
</head>
<body class="bg-dark text-light">
<nav class="navbar navbar-expand-lg navbar-dark bg-secondary">
<div class="container">
<a class="navbar-brand" href="{{ url_for('index') }}">Zbiórki unitraklub.pl</a>
<div class="collapse navbar-collapse">
<ul class="navbar-nav ms-auto">
{% if current_user.is_authenticated %}
<li class="nav-item"><a class="nav-link" href="{{ url_for('admin_dashboard') }}">Panel Admina</a></li>
<li class="nav-item"><a class="nav-link" href="{{ url_for('logout') }}">Wyloguj</a></li>
{% else %}
<li class="nav-item"><a class="nav-link" href="{{ url_for('login') }}">Zaloguj</a></li>
{% endif %}
</ul>
</div>
</div>
</nav>
<div class="container mt-4">
{% with messages = get_flashed_messages(with_categories=true) %}
{% if messages %}
{% for category, message in messages %}
<div class="alert alert-{{ category }}">{{ message }}</div>
{% endfor %}
{% endif %}
{% endwith %}
{% block content %}{% endblock %}
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
</body>
</html>

14
templates/index.html Normal file
View File

@ -0,0 +1,14 @@
{% extends 'base.html' %}
{% block title %}Lista Zbiórek{% endblock %}
{% block content %}
<h1>Lista Zbiórek</h1>
<div class="list-group">
{% for z in zbiorki %}
<a href="{{ url_for('zbiorka', zbiorka_id=z.id) }}" class="list-group-item list-group-item-action bg-secondary text-light">
{{ z.nazwa }}
</a>
{% else %}
<p>Brak zbiórek</p>
{% endfor %}
</div>
{% endblock %}

17
templates/login.html Normal file
View File

@ -0,0 +1,17 @@
{% extends 'base.html' %}
{% block title %}Logowanie{% endblock %}
{% block content %}
<h1>Logowanie</h1>
<form method="post">
<div class="mb-3">
<label for="username" class="form-label">Nazwa użytkownika</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Hasło</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary">Zaloguj</button>
</form>
<p class="mt-3">Nie masz konta? <a href="{{ url_for('register') }}">Zarejestruj się</a></p>
{% endblock %}

16
templates/register.html Normal file
View File

@ -0,0 +1,16 @@
{% extends 'base.html' %}
{% block title %}Rejestracja{% endblock %}
{% block content %}
<h1>Rejestracja</h1>
<form method="post">
<div class="mb-3">
<label for="username" class="form-label">Nazwa użytkownika</label>
<input type="text" class="form-control" id="username" name="username" required>
</div>
<div class="mb-3">
<label for="password" class="form-label">Hasło</label>
<input type="password" class="form-control" id="password" name="password" required>
</div>
<button type="submit" class="btn btn-primary">Zarejestruj się</button>
</form>
{% endblock %}

60
templates/zbiorka.html Normal file
View File

@ -0,0 +1,60 @@
{% extends 'base.html' %}
{% block title %}{{ zbiorka.nazwa }}{% endblock %}
{% block content %}
<div class="container my-4">
<div class="card mb-4">
<div class="card-header">
<h1 class="card-title">{{ zbiorka.nazwa }}</h1>
</div>
<div class="card-body">
<!-- Opis zbiórki renderowany przy użyciu Markdown -->
<div class="mb-3">
{{ zbiorka.opis | markdown }}
</div>
<ul class="list-group list-group-flush mb-3">
<li class="list-group-item"><strong>Numer konta:</strong> {{ zbiorka.numer_konta }}</li>
<li class="list-group-item"><strong>Numer telefonu BLIK:</strong> {{ zbiorka.numer_telefonu_blik }}</li>
{% if not zbiorka.ukryj_kwote %}
<li class="list-group-item"><strong>Cel zbiórki:</strong> {{ zbiorka.cel }} PLN</li>
<li class="list-group-item"><strong>Stan zbiórki:</strong> {{ zbiorka.stan }} PLN</li>
{% endif %}
</ul>
{% set progress = (zbiorka.stan / zbiorka.cel * 100) if zbiorka.cel > 0 else 0 %}
<h5>Postęp zbiórki</h5>
<div class="progress mb-3" style="height: 40px;">
<div class="progress-bar progress-bar-striped progress-bar-animated" role="progressbar"
style="width: {{ progress if progress < 100 else 100 }}%;"
aria-valuenow="{{ progress }}" aria-valuemin="0" aria-valuemax="100">
{{ progress|round(2) }}%
</div>
</div>
<div class="d-flex justify-content-between">
{% if current_user.is_authenticated and current_user.is_admin %}
<a href="{{ url_for('admin_dodaj_wplate', zbiorka_id=zbiorka.id) }}" class="btn btn-primary">Dodaj wpłatę</a>
{% endif %}
<a href="{{ url_for('index') }}" class="btn btn-secondary">Powrót do listy zbiórek</a>
</div>
</div>
</div>
<div class="card">
<div class="card-header">
<h2 class="card-title">Wpłaty</h2>
</div>
<div class="card-body">
{% if zbiorka.wplaty|length > 0 %}
<ul class="list-group">
{% for w in zbiorka.wplaty %}
<li class="list-group-item">
<strong>{{ w.data.strftime('%Y-%m-%d %H:%M:%S') }}:</strong> {{ w.kwota }} PLN
{% if w.opis %} {{ w.opis }}{% endif %}
</li>
{% endfor %}
</ul>
{% else %}
<p>Brak wpłat</p>
{% endif %}
</div>
</div>
</div>
{% endblock %}