Compare commits
28
Commits
f02d3b8085
..
v1.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e8031858cd | ||
|
|
80ed950aed | ||
|
|
77e0c2b5bb | ||
|
|
ad75e2f958 | ||
|
|
b9b37daf01 | ||
|
|
40ffbb7de7 | ||
|
|
edd0a3767f | ||
|
|
2b4a1f551a | ||
|
|
edabd2ff80 | ||
|
|
3d4444bde4 | ||
|
|
115933284f | ||
|
|
222be68db2 | ||
|
|
9ca2f8f7ea | ||
|
|
36a1378429 | ||
|
|
84b4a5b482 | ||
|
|
a4d3da1d64 | ||
|
|
e14ea5445e | ||
|
|
4c3786bb7b | ||
|
|
61a3121b25 | ||
|
|
4533318b29 | ||
|
|
4341351923 | ||
|
|
41b0b72532 | ||
|
|
cda3ad2203 | ||
|
|
fd43032b55 | ||
|
|
4ddb48aef0 | ||
|
|
616fcacb60 | ||
|
|
59ec73c8b7 | ||
|
|
986518b2e4 |
+52
-25
@@ -1,3 +1,8 @@
|
||||
# UWAGA:
|
||||
# Po zmianie pliku .env samo `docker compose restart` może nie wystarczyć.
|
||||
# Aby nowe wartości zostały na pewno wczytane do kontenerów, użyj:
|
||||
# docker compose up -d --force-recreate
|
||||
|
||||
# APP_PORT:
|
||||
# Domyślny port, na którym uruchamiana jest aplikacja Flask
|
||||
# Domyślnie: 8000
|
||||
@@ -6,27 +11,30 @@ APP_PORT=8000
|
||||
# SECRET_KEY:
|
||||
# Klucz używany przez Flask do zabezpieczenia sesji, tokenów i formularzy
|
||||
# Powinien być długi i trudny do odgadnięcia
|
||||
SECRET_KEY=supersekretnyklucz123
|
||||
# Może zawierać znaki specjalne
|
||||
SECRET_KEY="supersekretnyklucz123"
|
||||
|
||||
# SYSTEM_PASSWORD:
|
||||
# Hasło główne administratora systemowego, używane np. przy inicjalizacji
|
||||
# Domyślnie: admin
|
||||
SYSTEM_PASSWORD=admin
|
||||
# Może zawierać znaki specjalne
|
||||
SYSTEM_PASSWORD="admin"
|
||||
|
||||
# DEFAULT_ADMIN_USERNAME:
|
||||
# Domyślna nazwa użytkownika administratora (tworzona przy starcie)
|
||||
# Domyślnie: admin
|
||||
DEFAULT_ADMIN_USERNAME=admin
|
||||
DEFAULT_ADMIN_USERNAME="admin"
|
||||
|
||||
# DEFAULT_ADMIN_PASSWORD:
|
||||
# Domyślne hasło administratora
|
||||
# Domyślnie: admin123
|
||||
DEFAULT_ADMIN_PASSWORD=admin123
|
||||
# Może zawierać znaki specjalne
|
||||
DEFAULT_ADMIN_PASSWORD="admin123"
|
||||
|
||||
# UPLOAD_FOLDER:
|
||||
# Ścieżka (względna) do katalogu, gdzie zapisywane są wgrywane pliki
|
||||
# Domyślnie: uploads
|
||||
UPLOAD_FOLDER=uploads
|
||||
UPLOAD_FOLDER="uploads"
|
||||
|
||||
# SESSION_TIMEOUT_MINUTES:
|
||||
# Czas bezczynności użytkownika (w minutach), po którym sesja wygasa
|
||||
@@ -41,8 +49,12 @@ AUTH_COOKIE_MAX_AGE=86400
|
||||
# AUTHORIZED_COOKIE_VALUE:
|
||||
# Wartość ciasteczka uprawniającego do dostępu (np. do zasobów zabezpieczonych)
|
||||
# Powinna być trudna do przewidzenia
|
||||
# Chodzi to o zabezpieczenie strony "hasłęm głównym czyli endpointem /system-auth"
|
||||
AUTHORIZED_COOKIE_VALUE=twoj_wlasny_hash
|
||||
# Chodzi o zabezpieczenie strony "hasłem głównym", czyli endpointem /system-auth
|
||||
# Może zawierać znaki specjalne
|
||||
# UWAGA: zmiana SYSTEM_PASSWORD nie unieważnia automatycznie wcześniej wydanych ciasteczek.
|
||||
# Aby wymusić ponowną autoryzację, zmień także AUTHORIZED_COOKIE_VALUE
|
||||
# lub wyczyść ciasteczka w przeglądarce.
|
||||
AUTHORIZED_COOKIE_VALUE="twoj_wlasny_hash"
|
||||
|
||||
# SESSION_COOKIE_SECURE:
|
||||
# Określa, czy ciasteczko sesyjne (Flask session) ma mieć ustawiony atrybut "Secure".
|
||||
@@ -54,39 +66,54 @@ SESSION_COOKIE_SECURE=0
|
||||
# BCRYPT_PEPPER:
|
||||
# Dodatkowy „sekretny klucz” (pepper) dodawany do hasła przed zahashowaniem
|
||||
# Zwiększa bezpieczeństwo przechowywanych haseł
|
||||
BCRYPT_PEPPER=sekretnyKluczbcrypt
|
||||
# Może zawierać znaki specjalne
|
||||
BCRYPT_PEPPER="sekretnyKluczbcrypt"
|
||||
|
||||
# HEALTHCHECK_TOKEN:
|
||||
# Token wykorzystywany do sprawdzania stanu aplikacji (np. w Docker Compose)
|
||||
# Domyślnie: alamapsaikota123
|
||||
HEALTHCHECK_TOKEN=alamapsaikota123
|
||||
# Może zawierać znaki specjalne
|
||||
HEALTHCHECK_TOKEN="alamapsaikota123"
|
||||
|
||||
# Rodzaj bazy: sqlite, pgsql, mysql
|
||||
# Mozliwe wartosci: sqlite / pgsql / mysql
|
||||
DB_ENGINE=sqlite
|
||||
# Możliwe wartości: sqlite / pgsql / mysql
|
||||
DB_ENGINE="sqlite"
|
||||
|
||||
# --- Konfiguracja dla sqlite ---
|
||||
# Plik bazy bedzie utworzony automatycznie w katalogu ./instance
|
||||
# Pozostale zmienne sa ignorowane przy DB_ENGINE=sqlite
|
||||
# Plik bazy będzie utworzony automatycznie w katalogu ./instance
|
||||
# Pozostałe zmienne są ignorowane przy DB_ENGINE=sqlite
|
||||
|
||||
# --- Konfiguracja dla pgsql ---
|
||||
# Ustaw DB_ENGINE=pgsql
|
||||
# Domyslny port PostgreSQL to 5432
|
||||
# Wymaga dzialajacego serwera PostgreSQL (np. kontener `postgres`)
|
||||
# Domyślny port PostgreSQL to 5432
|
||||
# Wymaga działającego serwera PostgreSQL (np. kontener `postgres`)
|
||||
|
||||
# --- Konfiguracja dla mysql ---
|
||||
# Ustaw DB_ENGINE=mysql
|
||||
# Domyslny port MySQL to 3306
|
||||
# Wymaga kontenera z MySQL i uzytkownika z dostepem do bazy
|
||||
# Domyślny port MySQL to 3306
|
||||
# Wymaga kontenera z MySQL i użytkownika z dostępem do bazy
|
||||
|
||||
# Wspolne zmienne (dla pgsql, mysql)
|
||||
# Wspólne zmienne (dla pgsql, mysql)
|
||||
# DB_HOST = pgsql lub mysql zgodnie z deployem (profil w docker-compose.yml)
|
||||
|
||||
DB_HOST=pgsql
|
||||
DB_HOST="pgsql"
|
||||
DB_PORT=5432
|
||||
DB_NAME=myapp
|
||||
DB_USER=user
|
||||
DB_PASSWORD=pass
|
||||
|
||||
# DB_NAME:
|
||||
# Nazwa bazy danych
|
||||
# Może zawierać znaki specjalne, ale zalecane są proste nazwy
|
||||
DB_NAME="myapp"
|
||||
|
||||
# DB_USER:
|
||||
# Użytkownik bazy danych
|
||||
# Może zawierać znaki specjalne
|
||||
DB_USER="user"
|
||||
|
||||
# DB_PASSWORD:
|
||||
# Hasło do bazy danych
|
||||
# Może zawierać znaki specjalne
|
||||
# Zalecane jest używanie wartości w cudzysłowach
|
||||
DB_PASSWORD="pass"
|
||||
|
||||
# ========================
|
||||
# Nagłówki bezpieczeństwa
|
||||
@@ -164,8 +191,8 @@ UPLOADS_CACHE_CONTROL="max-age=3600, immutable"
|
||||
# Lista domyślnych kategorii tworzonych automatycznie przy starcie aplikacji,
|
||||
# jeśli nie istnieją w bazie danych.
|
||||
# Podaj w formacie CSV (oddzielone przecinkami) – kolejność zostanie zachowana.
|
||||
# Możesz dodać własne kategorie
|
||||
# UWAGA: Wielkość liter w nazwach jest zachowywana, ale porównywanie odbywa się
|
||||
# Możesz dodać własne kategorie.
|
||||
# UWAGA: wielkość liter w nazwach jest zachowywana, ale porównywanie odbywa się
|
||||
# bez rozróżniania wielkości liter (case-insensitive).
|
||||
# Domyślnie: poniższa lista
|
||||
DEFAULT_CATEGORIES="Spożywcze,Budowlane,Zabawki,Chemia,Inne,Elektronika,Odzież i obuwie,Artykuły biurowe,Kosmetyki i higiena,Motoryzacja,Ogród i rośliny,Zwierzęta,Sprzęt sportowy,Książki i prasa,Narzędzia i majsterkowanie,RTV / AGD,Apteka i suplementy,Artykuły dekoracyjne,Gry i hobby,Usługi,Pieczywo"
|
||||
DEFAULT_CATEGORIES="Spożywcze,Budowlane,Zabawki,Chemia,Inne,Elektronika,Odzież i obuwie,Artykuły biurowe,Kosmetyki i higiena,Motoryzacja,Ogród i rośliny,Zwierzęta,Sprzęt sportowy,Książki i prasa,Narzędzia i majsterkowanie,RTV / AGD,Apteka i suplementy,Artykuły dekoracyjne,Gry i hobby,Usługi,Pieczywo"
|
||||
+37
-6
@@ -9,22 +9,53 @@ flask admins promote <username|id>
|
||||
flask admins demote <username|id>
|
||||
flask admins set-password <username|id> <password>
|
||||
|
||||
Opis:
|
||||
- list: pokazuje wszystkich uzytkownikow wraz z ID i rola
|
||||
- create: tworzy konto admina lub zwyklego uzytkownika
|
||||
- promote: nadaje uprawnienia administratora
|
||||
- demote: odbiera uprawnienia administratora
|
||||
- set-password: ustawia nowe haslo dla wskazanego konta
|
||||
|
||||
Listy
|
||||
-----
|
||||
flask lists copy-schedule --source-list-id 12 --when "2026-03-20 18:30"
|
||||
flask lists copy-schedule --source-list-id 12 --when "2026-03-20 18:30" --owner admin
|
||||
flask lists copy-schedule --source-list-id 12 --when "2026-03-20 18:30" --title "Zakupy piatkowe"
|
||||
flask lists move --list-id 12 --when "2026-03-21 09:00"
|
||||
flask lists move --list-id 12 --when "2026-03-21 09:00" --keep-item-times --keep-expiry
|
||||
flask lists archive --list-id 12
|
||||
flask lists unarchive --list-id 12
|
||||
flask lists assign-owner --list-id 12 --owner admin
|
||||
flask lists create-from-template --template-id 5 --owner admin --when "2026-03-22 08:00"
|
||||
flask lists create-from-template --template-id 5 --owner admin --title "Weekend"
|
||||
flask lists delete --list-id 12
|
||||
flask lists rename --list-id 12 --title "Nowa nazwa listy"
|
||||
flask lists duplicate-many --source-list-id 12 --when-list "2026-03-23 08:00,2026-03-24 08:00,2026-03-25 08:00"
|
||||
flask lists duplicate-many --source-list-id 12 --when-list "2026-03-23 08:00,2026-03-24 08:00" --owner admin --title-prefix "Sklep"
|
||||
|
||||
Zasady dzialania
|
||||
----------------
|
||||
- copy-schedule tworzy nowa liste na podstawie istniejacej
|
||||
- kopiuje pozycje i przypisane kategorie
|
||||
- ustawia nowy created_at na wartosc z parametru --when
|
||||
- copy-schedule kopiuje pozycje i przypisane kategorie
|
||||
- copy-schedule ustawia nowy created_at na wartosc z parametru --when
|
||||
- gdy lista byla tymczasowa i miala expires_at, termin wygasniecia jest przesuwany o ten sam odstep czasu
|
||||
- wydatki i paragony nie sa kopiowane
|
||||
|
||||
- move przenosi istniejaca liste na wskazany dzien/godzine
|
||||
- move domyslnie przesuwa rowniez czasy pozycji i expires_at o ten sam offset czasu
|
||||
- move z opcja --keep-item-times zostawia added_at i purchased_at bez zmian
|
||||
- move z opcja --keep-expiry zostawia expires_at bez zmian
|
||||
- archive oznacza liste jako archiwalna
|
||||
- unarchive przywraca liste z archiwum
|
||||
- assign-owner zmienia wlasciciela listy
|
||||
- create-from-template tworzy nowa liste z szablonu dla wskazanego wlasciciela
|
||||
- create-from-template bez --when ustawia biezacy czas UTC
|
||||
- delete usuwa liste wraz z powiazanymi pozycjami, historią i paragonami zaleznymi od relacji bazy
|
||||
- rename zmienia tytul listy
|
||||
- duplicate-many tworzy wiele kopii tej samej listy dla wielu terminow przekazanych w --when-list
|
||||
- duplicate-many opcjonalnie pozwala zmienic wlasciciela i nadac prefiks nazwy nowym listom
|
||||
|
||||
SZABLONY I HISTORIA:
|
||||
- Historia zmian listy jest widoczna w widoku listy właściciela.
|
||||
- Szablon można utworzyć z panelu admina lub z poziomu listy właściciela.
|
||||
- Admin może szybko utworzyć listę z szablonu i zduplikować listę jednym kliknięciem.
|
||||
- Historia zmian listy jest widoczna w widoku listy wlasciciela.
|
||||
- Szablon mozna utworzyc z panelu admina lub z poziomu listy wlasciciela.
|
||||
- Admin moze szybko utworzyc liste z szablonu i zduplikowac liste jednym kliknieciem.
|
||||
- Operacje CLI takie jak copy-schedule, move, archive, unarchive, assign-owner, rename i create-from-template sa zapisywane w historii listy.
|
||||
|
||||
@@ -1,51 +1,21 @@
|
||||
# Aplikacja List Zakupów
|
||||
|
||||
Prosta aplikacja webowa do zarządzania listami zakupów z obsługą użytkowników, OCR paragonów, statystykami i trybem współdzielenia.
|
||||
|
||||
## Główne funkcje
|
||||
|
||||
- Logowanie i zarządzanie użytkownikami (admin/user)
|
||||
- Tworzenie list zakupów z pozycjami i ilością
|
||||
- Wgrywanie paragonów (podstawowa obsługa OCR)
|
||||
- Archiwizacja i udostępnianie list (publiczne/prywatne)
|
||||
- Statystyki wydatków z podziałem na okresy, statystyki dla użytkowników
|
||||
- Panel administracyjny (statystyki, produkty, paragony, zarządzanie, użytkowmicy)
|
||||
- Tokeny API administratora i endpoint do pobierania ostatnich wydatków
|
||||
- Ujednolicony UI formularzy, tabel i przycisków oraz drobne usprawnienia UX
|
||||
Aplikacja webowa do zarządzania listami zakupów z obsługą użytkowników, OCR paragonów, statystykami i trybem współdzielenia.
|
||||
|
||||
## Wymagania
|
||||
|
||||
- Python 3.9+
|
||||
- Docker (opcjonalnie dla produkcji)
|
||||
- Docker
|
||||
|
||||
## Instalacja lokalna (deweloperska)
|
||||
## Instalacja
|
||||
|
||||
1. Sklonuj repozytorium:
|
||||
|
||||
```bash
|
||||
git https://git.linuxiarz.pl/gru/lista_zakupowa_live.git
|
||||
git pull https://git.linuxiarz.pl/gru/lista_zakupowa_live.git
|
||||
cd lista_zakupowa_live
|
||||
```
|
||||
|
||||
2. Utwórz i uzupełnij plik `.env` (zobacz `.env example`).
|
||||
|
||||
3. Utwórz środowisko i zainstaluj zależności:
|
||||
|
||||
```bash
|
||||
python -m venv venv
|
||||
source venv/bin/activate
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
4. Uruchom aplikację:
|
||||
|
||||
```bash
|
||||
flask --app app.py run
|
||||
```
|
||||
|
||||
## Deploy z Docker Compose - stack (zalecana)
|
||||
|
||||
1. Skonfiguruj `.env`.
|
||||
1. Skonfiguruj `.env` z pliku `.env.example`
|
||||
|
||||
2.1 Uruchom: (pgsql)
|
||||
|
||||
@@ -65,9 +35,16 @@ Prosta aplikacja webowa do zarządzania listami zakupów z obsługą użytkownik
|
||||
bash deploy_docker.sh sqlite
|
||||
```
|
||||
|
||||
2.3 Restart:
|
||||
```bash
|
||||
bash deploy_docker.sh pgsql restart
|
||||
lub
|
||||
bash deploy_docker.sh sqlite restart
|
||||
```
|
||||
|
||||
Aplikacja będzie dostępna pod `http://localhost:8000`.
|
||||
|
||||
## Domyślne dane logowania
|
||||
## Domyślne dane logowania - konfigurowane z pliku `.env`
|
||||
|
||||
- Główne hasło systemowe: `admin`
|
||||
- Admin: `admin` / `admin123`
|
||||
@@ -80,15 +57,35 @@ Ustaw `DB_ENGINE` oraz odpowiednie zmienne w `.env`:
|
||||
|
||||
Przykład dla PostgreSQL:
|
||||
|
||||
```env
|
||||
DB_ENGINE=pgsql
|
||||
DB_HOST=db
|
||||
DB_PORT=5432
|
||||
DB_NAME=myapp
|
||||
DB_USER=user
|
||||
DB_PASSWORD=pass
|
||||
```
|
||||
```bash
|
||||
DB_ENGINE=pgsql
|
||||
DB_HOST=db
|
||||
DB_PORT=5432
|
||||
DB_NAME=myapp
|
||||
DB_USER=user
|
||||
DB_PASSWORD=pass
|
||||
```
|
||||
|
||||
## CLI
|
||||
|
||||
Opis komend administracyjnych znajduje sie w pliku `CLI_OPIS.txt`.
|
||||
Opis komend administracyjnych znajduje sie w pliku `KOMENDY_CLI.txt`.
|
||||
|
||||
Komendy CLI uruchamiamy wewnatrz kontenera aplikacji. Najwygodniej wejsc do katalogu projektu i wykonac polecenie przez `docker compose exec app`.
|
||||
|
||||
Przykladowe:
|
||||
|
||||
```bash
|
||||
cd /opt/lista_zakupowa_live
|
||||
docker compose -f docker/compose.yml exec app sh -c 'flask lists copy-schedule --source-list-id 393 --when "2026-03-22 11:30" --owner admin'
|
||||
```
|
||||
|
||||
Dodatkowe przyklady:
|
||||
|
||||
```bash
|
||||
docker compose -f docker/compose.yml exec app sh -c 'flask lists move --list-id 393 --when "2026-03-23 08:00"'
|
||||
|
||||
docker compose -f docker/compose.yml exec app sh -c 'flask lists rename --list-id 393 --title "Zakupy na poniedzialek"'
|
||||
|
||||
docker compose -f docker/compose.yml exec app sh -c 'flask lists create-from-template --template-id 7 --owner admin --when "2026-03-24 09:15" --title "Poranna lista"'
|
||||
```
|
||||
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
from shopping_app import app, socketio, APP_PORT, DEBUG_MODE
|
||||
from shopping_app.app_setup import logging
|
||||
|
||||
from shopping_app.startup_info import print_startup_info
|
||||
|
||||
if __name__ == "__main__":
|
||||
logging.basicConfig(level=logging.DEBUG if DEBUG_MODE else logging.INFO)
|
||||
|
||||
print_startup_info(app)
|
||||
|
||||
socketio.run(app, host="0.0.0.0", port=APP_PORT, debug=False)
|
||||
|
||||
@@ -1,85 +1,113 @@
|
||||
import os
|
||||
from urllib.parse import quote_plus
|
||||
|
||||
basedir = os.path.abspath(os.path.dirname(__file__))
|
||||
|
||||
|
||||
def env_str(name, default=None):
|
||||
value = os.environ.get(name)
|
||||
return default if value is None else value
|
||||
|
||||
|
||||
def env_int(name, default):
|
||||
value = os.environ.get(name)
|
||||
if value is None or value == "":
|
||||
return default
|
||||
try:
|
||||
return int(value)
|
||||
except (TypeError, ValueError):
|
||||
return default
|
||||
|
||||
|
||||
def env_bool(name, default=False):
|
||||
value = os.environ.get(name)
|
||||
if value is None:
|
||||
return default
|
||||
return str(value).strip().lower() in ("1", "true", "yes", "on")
|
||||
|
||||
|
||||
class Config:
|
||||
|
||||
SESSION_COOKIE_HTTPONLY = True
|
||||
SESSION_COOKIE_SAMESITE = "Lax" # działa w HTTP i HTTPS
|
||||
|
||||
SECRET_KEY = os.environ.get("SECRET_KEY", "D8pceNZ8q%YR7^7F&9wAC2")
|
||||
SESSION_COOKIE_SAMESITE = "Lax"
|
||||
|
||||
APP_PORT = int(os.environ.get("APP_PORT", "8000") or "8000")
|
||||
SECRET_KEY = env_str("SECRET_KEY", "D8pceNZ8q%YR7^7F&9wAC2")
|
||||
|
||||
APP_PORT = env_int("APP_PORT", 8000)
|
||||
|
||||
DB_ENGINE = env_str("DB_ENGINE", "sqlite").lower()
|
||||
|
||||
DB_ENGINE = os.environ.get("DB_ENGINE", "sqlite").lower()
|
||||
if DB_ENGINE == "sqlite":
|
||||
SQLALCHEMY_DATABASE_URI = (
|
||||
f"sqlite:///{os.path.join(basedir, 'db', 'shopping.db')}"
|
||||
)
|
||||
|
||||
elif DB_ENGINE == "pgsql":
|
||||
SQLALCHEMY_DATABASE_URI = f"postgresql://{os.environ['DB_USER']}:{os.environ['DB_PASSWORD']}@{os.environ['DB_HOST']}:{os.environ.get('DB_PORT', 5432)}/{os.environ['DB_NAME']}"
|
||||
db_user = quote_plus(env_str("DB_USER", "user"))
|
||||
db_password = quote_plus(env_str("DB_PASSWORD", "pass"))
|
||||
db_host = env_str("DB_HOST", "pgsql")
|
||||
db_port = env_str("DB_PORT", "5432")
|
||||
db_name = quote_plus(env_str("DB_NAME", "myapp"))
|
||||
|
||||
SQLALCHEMY_DATABASE_URI = (
|
||||
f"postgresql://{db_user}:{db_password}@{db_host}:{db_port}/{db_name}"
|
||||
)
|
||||
|
||||
elif DB_ENGINE == "mysql":
|
||||
SQLALCHEMY_DATABASE_URI = f"mysql+pymysql://{os.environ['DB_USER']}:{os.environ['DB_PASSWORD']}@{os.environ['DB_HOST']}:{os.environ.get('DB_PORT', 3306)}/{os.environ['DB_NAME']}"
|
||||
db_user = quote_plus(env_str("DB_USER", "user"))
|
||||
db_password = quote_plus(env_str("DB_PASSWORD", "pass"))
|
||||
db_host = env_str("DB_HOST", "mysql")
|
||||
db_port = env_str("DB_PORT", "3306")
|
||||
db_name = quote_plus(env_str("DB_NAME", "myapp"))
|
||||
|
||||
SQLALCHEMY_DATABASE_URI = (
|
||||
f"mysql+pymysql://{db_user}:{db_password}@{db_host}:{db_port}/{db_name}"
|
||||
)
|
||||
|
||||
else:
|
||||
raise ValueError("Nieobsługiwany typ bazy danych.")
|
||||
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
||||
SYSTEM_PASSWORD = os.environ.get("SYSTEM_PASSWORD", "admin")
|
||||
DEFAULT_ADMIN_USERNAME = os.environ.get("DEFAULT_ADMIN_USERNAME", "admin")
|
||||
DEFAULT_ADMIN_PASSWORD = os.environ.get("DEFAULT_ADMIN_PASSWORD", "admin123")
|
||||
UPLOAD_FOLDER = os.environ.get("UPLOAD_FOLDER", "uploads")
|
||||
AUTHORIZED_COOKIE_VALUE = os.environ.get("AUTHORIZED_COOKIE_VALUE", "cookievalue")
|
||||
BCRYPT_PEPPER = os.environ.get("BCRYPT_PEPPER", "sekretnyKluczBcrypt")
|
||||
SESSION_COOKIE_SECURE = os.environ.get("SESSION_COOKIE_SECURE", "0") == "1"
|
||||
HEALTHCHECK_TOKEN = os.environ.get("HEALTHCHECK_TOKEN", "alamapsaikota1234")
|
||||
|
||||
try:
|
||||
AUTH_COOKIE_MAX_AGE = int(
|
||||
os.environ.get("AUTH_COOKIE_MAX_AGE", "86400") or "86400"
|
||||
)
|
||||
except ValueError:
|
||||
AUTH_COOKIE_MAX_AGE = 86400
|
||||
SYSTEM_PASSWORD = env_str("SYSTEM_PASSWORD", "admin")
|
||||
DEFAULT_ADMIN_USERNAME = env_str("DEFAULT_ADMIN_USERNAME", "admin")
|
||||
DEFAULT_ADMIN_PASSWORD = env_str("DEFAULT_ADMIN_PASSWORD", "admin123")
|
||||
UPLOAD_FOLDER = env_str("UPLOAD_FOLDER", "uploads")
|
||||
AUTHORIZED_COOKIE_VALUE = env_str("AUTHORIZED_COOKIE_VALUE", "cookievalue")
|
||||
BCRYPT_PEPPER = env_str("BCRYPT_PEPPER", "sekretnyKluczBcrypt")
|
||||
SESSION_COOKIE_SECURE = env_bool("SESSION_COOKIE_SECURE", False)
|
||||
HEALTHCHECK_TOKEN = env_str("HEALTHCHECK_TOKEN", "alamapsaikota1234")
|
||||
|
||||
try:
|
||||
SESSION_TIMEOUT_MINUTES = int(
|
||||
os.environ.get("SESSION_TIMEOUT_MINUTES", "10080") or "10080"
|
||||
)
|
||||
except ValueError:
|
||||
SESSION_TIMEOUT_MINUTES = 10080
|
||||
AUTH_COOKIE_MAX_AGE = env_int("AUTH_COOKIE_MAX_AGE", 86400)
|
||||
SESSION_TIMEOUT_MINUTES = env_int("SESSION_TIMEOUT_MINUTES", 10080)
|
||||
|
||||
ENABLE_HSTS = os.environ.get("ENABLE_HSTS", "0") == "1"
|
||||
ENABLE_XFO = os.environ.get("ENABLE_XFO", "0") == "1"
|
||||
ENABLE_XCTO = os.environ.get("ENABLE_XCTO", "0") == "1"
|
||||
ENABLE_CSP = os.environ.get("ENABLE_CSP", "0") == "1"
|
||||
ENABLE_PP = os.environ.get("ENABLE_PP", "0") == "1"
|
||||
REFERRER_POLICY = os.environ.get("REFERRER_POLICY") or None
|
||||
ENABLE_HSTS = env_bool("ENABLE_HSTS", False)
|
||||
ENABLE_XFO = env_bool("ENABLE_XFO", False)
|
||||
ENABLE_XCTO = env_bool("ENABLE_XCTO", False)
|
||||
ENABLE_CSP = env_bool("ENABLE_CSP", False)
|
||||
ENABLE_PP = env_bool("ENABLE_PP", False)
|
||||
|
||||
DEBUG_MODE = os.environ.get("DEBUG_MODE", "1") == "1"
|
||||
DISABLE_ROBOTS = os.environ.get("DISABLE_ROBOTS", "0") == "1"
|
||||
REFERRER_POLICY = env_str("REFERRER_POLICY") or None
|
||||
|
||||
JS_CACHE_CONTROL = os.environ.get(
|
||||
"JS_CACHE_CONTROL", "no-cache"
|
||||
)
|
||||
CSS_CACHE_CONTROL = os.environ.get(
|
||||
"CSS_CACHE_CONTROL", "no-cache"
|
||||
)
|
||||
LIB_JS_CACHE_CONTROL = os.environ.get(
|
||||
"LIB_JS_CACHE_CONTROL", "max-age=604800"
|
||||
)
|
||||
LIB_CSS_CACHE_CONTROL = os.environ.get(
|
||||
"LIB_CSS_CACHE_CONTROL", "max-age=604800"
|
||||
)
|
||||
UPLOADS_CACHE_CONTROL = os.environ.get(
|
||||
"UPLOADS_CACHE_CONTROL", "public, max-age=2592000, immutable"
|
||||
DEBUG_MODE = env_bool("DEBUG_MODE", True)
|
||||
DISABLE_ROBOTS = env_bool("DISABLE_ROBOTS", False)
|
||||
|
||||
JS_CACHE_CONTROL = env_str("JS_CACHE_CONTROL", "no-cache")
|
||||
CSS_CACHE_CONTROL = env_str("CSS_CACHE_CONTROL", "no-cache")
|
||||
LIB_JS_CACHE_CONTROL = env_str("LIB_JS_CACHE_CONTROL", "max-age=604800")
|
||||
LIB_CSS_CACHE_CONTROL = env_str("LIB_CSS_CACHE_CONTROL", "max-age=604800")
|
||||
UPLOADS_CACHE_CONTROL = env_str(
|
||||
"UPLOADS_CACHE_CONTROL",
|
||||
"public, max-age=2592000, immutable",
|
||||
)
|
||||
|
||||
DEFAULT_CATEGORIES = [
|
||||
c.strip() for c in os.environ.get(
|
||||
c.strip()
|
||||
for c in env_str(
|
||||
"DEFAULT_CATEGORIES",
|
||||
"Spożywcze,Budowlane,Zabawki,Chemia,Inne,Elektronika,Odzież i obuwie,Jedzenie poza domem,"
|
||||
"Artykuły biurowe,Kosmetyki i higiena,Motoryzacja,Ogród i rośliny,"
|
||||
"Zwierzęta,Sprzęt sportowy,Książki i prasa,Narzędzia i majsterkowanie,"
|
||||
"RTV / AGD,Apteka i suplementy,Artykuły dekoracyjne,Gry i hobby,Usługi,Pieczywo,Różne,Chiny,Dom,Leki,Odzież,Samochód,Dzieci"
|
||||
).split(",") if c.strip()
|
||||
]
|
||||
"RTV / AGD,Apteka i suplementy,Artykuły dekoracyjne,Gry i hobby,Usługi,Pieczywo,Różne,Chiny,Dom,Leki,Odzież,Samochód,Dzieci",
|
||||
).split(",")
|
||||
if c.strip()
|
||||
]
|
||||
+85
-21
@@ -1,7 +1,8 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
set -euo pipefail
|
||||
|
||||
COMPOSE_FILE="docker/compose.yml"
|
||||
|
||||
# --- Wczytaj zmienne z .env ---
|
||||
if [[ -f .env ]]; then
|
||||
set -a
|
||||
source .env
|
||||
@@ -9,23 +10,63 @@ if [[ -f .env ]]; then
|
||||
fi
|
||||
|
||||
APP_PORT="${APP_PORT:-8080}"
|
||||
DEFAULT_ENGINE="${DB_ENGINE:-sqlite}"
|
||||
|
||||
PROFILE=$1
|
||||
print_usage() {
|
||||
echo "Użycie:"
|
||||
echo " $0 [sqlite|pgsql|mysql] [deploy|restart]"
|
||||
echo
|
||||
echo "Przykłady:"
|
||||
echo " $0 pgsql deploy"
|
||||
echo " $0 mysql restart"
|
||||
echo " $0 sqlite"
|
||||
echo
|
||||
echo "Domyślnie:"
|
||||
echo " silnik: z DB_ENGINE z .env albo sqlite"
|
||||
echo " akcja: deploy"
|
||||
}
|
||||
|
||||
if [[ -z "$PROFILE" ]]; then
|
||||
echo "Użycie: $0 {pgsql|mysql|sqlite}"
|
||||
exit 1
|
||||
validate_engine() {
|
||||
local engine="$1"
|
||||
case "$engine" in
|
||||
sqlite|pgsql|mysql)
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
echo "Błąd: nieobsługiwany silnik bazy: '$engine'"
|
||||
echo "Dozwolone wartości: sqlite, pgsql, mysql"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
validate_action() {
|
||||
local action="$1"
|
||||
case "$action" in
|
||||
deploy|restart)
|
||||
return 0
|
||||
;;
|
||||
*)
|
||||
echo "Błąd: nieobsługiwana akcja: '$action'"
|
||||
echo "Dozwolone wartości: deploy, restart"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
PROFILE="${1:-$DEFAULT_ENGINE}"
|
||||
ACTION="${2:-deploy}"
|
||||
|
||||
validate_engine "$PROFILE"
|
||||
validate_action "$ACTION"
|
||||
|
||||
if [[ -n "${DB_ENGINE:-}" && "$DB_ENGINE" != "$PROFILE" ]]; then
|
||||
echo "Uwaga: DB_ENGINE w .env ma wartość '$DB_ENGINE', a uruchamiasz profil '$PROFILE'."
|
||||
echo "Kontynuuję z profilem z argumentu: '$PROFILE'"
|
||||
fi
|
||||
|
||||
echo "Zatrzymuję kontenery aplikacji i bazy..."
|
||||
if [[ "$PROFILE" == "sqlite" ]]; then
|
||||
docker compose stop
|
||||
else
|
||||
docker compose --profile "$PROFILE" stop
|
||||
fi
|
||||
|
||||
echo "Pobieram najnowszy kod z repozytorium..."
|
||||
git pull
|
||||
echo "Wybrany silnik bazy: $PROFILE"
|
||||
echo "Wybrana akcja: $ACTION"
|
||||
|
||||
echo "Generowanie default.vcl z APP_PORT=$APP_PORT"
|
||||
envsubst < deploy/varnish/default.vcl.template > deploy/varnish/default.vcl
|
||||
@@ -33,11 +74,34 @@ envsubst < deploy/varnish/default.vcl.template > deploy/varnish/default.vcl
|
||||
echo "Zapisuję hash commita do version.txt..."
|
||||
git rev-parse --short HEAD > version.txt
|
||||
|
||||
echo "Buduję i uruchamiam kontenery..."
|
||||
if [[ "$PROFILE" == "sqlite" ]]; then
|
||||
docker compose up -d --build
|
||||
else
|
||||
DB_ENGINE="$PROFILE" docker compose --profile "$PROFILE" up -d --build
|
||||
if [[ "$ACTION" == "restart" ]]; then
|
||||
echo "Odtwarzam kontenery bez przebudowy obrazu..."
|
||||
|
||||
if [[ "$PROFILE" == "sqlite" ]]; then
|
||||
docker compose -f "$COMPOSE_FILE" up -d --force-recreate
|
||||
else
|
||||
DB_ENGINE="$PROFILE" docker compose -f "$COMPOSE_FILE" --profile "$PROFILE" up -d --force-recreate
|
||||
fi
|
||||
|
||||
echo "Gotowe! Wersja aplikacji: $(cat version.txt)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Gotowe! Wersja aplikacji: $(cat version.txt)"
|
||||
echo "Zatrzymuję kontenery aplikacji i bazy..."
|
||||
if [[ "$PROFILE" == "sqlite" ]]; then
|
||||
docker compose -f "$COMPOSE_FILE" stop
|
||||
else
|
||||
DB_ENGINE="$PROFILE" docker compose -f "$COMPOSE_FILE" --profile "$PROFILE" stop
|
||||
fi
|
||||
|
||||
echo "Pobieram najnowszy kod z repozytorium..."
|
||||
git pull
|
||||
|
||||
echo "Uruchamiam kontenery z przebudową obrazu..."
|
||||
if [[ "$PROFILE" == "sqlite" ]]; then
|
||||
docker compose -f "$COMPOSE_FILE" up -d --build
|
||||
else
|
||||
DB_ENGINE="$PROFILE" docker compose -f "$COMPOSE_FILE" --profile "$PROFILE" up -d --build
|
||||
fi
|
||||
|
||||
echo "Gotowe! Wersja aplikacji: $(cat version.txt)"
|
||||
@@ -1,8 +1,6 @@
|
||||
FROM python:3.14-trixie
|
||||
#FROM python:3.13-slim
|
||||
WORKDIR /app
|
||||
|
||||
# Zależności systemowe do OCR, obrazów, tesseract i języka PL
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
tesseract-ocr \
|
||||
tesseract-ocr-pol \
|
||||
@@ -14,21 +12,17 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Kopiujemy wymagania
|
||||
COPY requirements.txt requirements.txt
|
||||
COPY docker/requirements.txt /app/requirements.txt
|
||||
|
||||
# Instalujemy zależności
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
# Kopiujemy resztę aplikacji
|
||||
COPY . .
|
||||
COPY . /app
|
||||
|
||||
# Kopiujemy entrypoint i ustawiamy uprawnienia
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
# Otwieramy port
|
||||
|
||||
#EXPOSE 8000
|
||||
|
||||
# Ustawiamy entrypoint
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
@@ -0,0 +1,28 @@
|
||||
FROM python:3.14-slim-trixie
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
tesseract-ocr \
|
||||
tesseract-ocr-pol \
|
||||
libglib2.0-0 \
|
||||
libsm6 \
|
||||
libxrender1 \
|
||||
libxext6 \
|
||||
poppler-utils \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY docker/requirements.txt /app/requirements.txt
|
||||
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . /app
|
||||
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
#EXPOSE 8000
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
@@ -0,0 +1,27 @@
|
||||
FROM python:3.14-slim-trixie
|
||||
WORKDIR /app
|
||||
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
tesseract-ocr \
|
||||
tesseract-ocr-pol \
|
||||
libglib2.0-0 \
|
||||
libsm6 \
|
||||
libxrender1 \
|
||||
libxext6 \
|
||||
poppler-utils \
|
||||
&& apt-get clean \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY docker/requirements-stable.txt /app/requirements.txt
|
||||
|
||||
RUN pip install --upgrade pip
|
||||
RUN pip install --no-cache-dir -r requirements.txt
|
||||
|
||||
COPY . /app
|
||||
|
||||
COPY entrypoint.sh /entrypoint.sh
|
||||
RUN chmod +x /entrypoint.sh
|
||||
|
||||
#EXPOSE 8000
|
||||
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
@@ -1,14 +1,11 @@
|
||||
services:
|
||||
app:
|
||||
build: .
|
||||
build:
|
||||
context: ..
|
||||
dockerfile: docker/Dockerfile.debian-stable-slim
|
||||
container_name: lista-zakupow-app
|
||||
expose:
|
||||
- "${APP_PORT:-8000}"
|
||||
|
||||
# temporary
|
||||
#ports:
|
||||
# - "9281:${APP_PORT:-8000}"
|
||||
|
||||
healthcheck:
|
||||
test:
|
||||
[
|
||||
@@ -22,11 +19,11 @@ services:
|
||||
retries: 3
|
||||
start_period: 10s
|
||||
env_file:
|
||||
- .env
|
||||
- ../.env
|
||||
volumes:
|
||||
- .:/app
|
||||
- ./uploads:/app/uploads
|
||||
- ./instance:/app/instance
|
||||
- ../:/app
|
||||
- ../uploads:/app/uploads
|
||||
- ../instance:/app/instance
|
||||
networks:
|
||||
- lista-zakupow_network
|
||||
restart: unless-stopped
|
||||
@@ -40,7 +37,7 @@ services:
|
||||
ports:
|
||||
- "${APP_PORT:-8000}:80"
|
||||
volumes:
|
||||
- ./deploy/varnish/default.vcl:/etc/varnish/default.vcl:ro
|
||||
- ../deploy/varnish/default.vcl:/etc/varnish/default.vcl:ro
|
||||
environment:
|
||||
- VARNISH_SIZE=256m
|
||||
networks:
|
||||
@@ -56,7 +53,7 @@ services:
|
||||
MYSQL_PASSWORD: ${DB_PASSWORD}
|
||||
MYSQL_ROOT_PASSWORD: 89o38kUX5T4C
|
||||
volumes:
|
||||
- ./db/mysql:/var/lib/mysql
|
||||
- ../db/mysql:/var/lib/mysql
|
||||
restart: unless-stopped
|
||||
networks:
|
||||
- lista-zakupow_network
|
||||
@@ -71,7 +68,7 @@ services:
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||
PGDATA: /var/lib/postgresql
|
||||
volumes:
|
||||
- ./db/pgsql/:/var/lib/postgresql
|
||||
- ../db/pgsql:/var/lib/postgresql
|
||||
networks:
|
||||
- lista-zakupow_network
|
||||
restart: unless-stopped
|
||||
@@ -79,4 +76,4 @@ services:
|
||||
|
||||
networks:
|
||||
lista-zakupow_network:
|
||||
driver: bridge
|
||||
driver: bridge
|
||||
@@ -0,0 +1,21 @@
|
||||
bcrypt==5.0.0
|
||||
cryptography==46.0.5
|
||||
Flask==3.1.3
|
||||
Flask-Compress==1.23
|
||||
Flask-Login==0.6.3
|
||||
Flask-Session==0.8.0
|
||||
Flask-SocketIO==5.6.1
|
||||
Flask-SQLAlchemy==3.1.1
|
||||
flask-talisman==1.1.0
|
||||
gevent==25.9.1
|
||||
gevent-websocket==0.10.1
|
||||
opencv-python-headless>=4.12.0.88
|
||||
pdf2image==1.17.0
|
||||
pillow==12.1.1
|
||||
pillow_heif==1.3.0
|
||||
psutil==7.2.2
|
||||
psycopg2-binary==2.9.11
|
||||
PyMySQL==1.1.2
|
||||
pytesseract==0.3.13
|
||||
SQLAlchemy==2.0.48
|
||||
Werkzeug==3.1.6
|
||||
@@ -94,6 +94,18 @@ def read_commit(filename="version.txt", root_path=None):
|
||||
except Exception:
|
||||
return None
|
||||
|
||||
|
||||
def get_file_md5(path):
|
||||
try:
|
||||
digest = hashlib.md5()
|
||||
with open(path, "rb") as f:
|
||||
for chunk in iter(lambda: f.read(8192), b""):
|
||||
digest.update(chunk)
|
||||
return digest.hexdigest()[:12]
|
||||
except Exception:
|
||||
return "dev"
|
||||
|
||||
|
||||
commit = read_commit("version.txt", root_path=os.path.dirname(os.path.dirname(__file__))) or "dev"
|
||||
APP_VERSION = commit
|
||||
app.config["APP_VERSION"] = APP_VERSION
|
||||
|
||||
+118
-1
@@ -243,6 +243,118 @@ def duplicate_list_for_schedule(source_list: ShoppingList, scheduled_for: dateti
|
||||
db.session.commit()
|
||||
return new_list
|
||||
|
||||
|
||||
|
||||
def shift_datetime_preserving_timezone(value: datetime | None, delta: timedelta) -> datetime | None:
|
||||
if not value:
|
||||
return None
|
||||
if value.tzinfo is None:
|
||||
value = value.replace(tzinfo=timezone.utc)
|
||||
return value + delta
|
||||
|
||||
|
||||
def move_list_schedule(shopping_list: ShoppingList, new_when: datetime, keep_item_times: bool = False, keep_expiry: bool = False):
|
||||
if shopping_list is None:
|
||||
raise ValueError('Lista nie istnieje.')
|
||||
if new_when.tzinfo is None:
|
||||
new_when = new_when.replace(tzinfo=timezone.utc)
|
||||
|
||||
original_created = shopping_list.created_at or new_when
|
||||
if original_created.tzinfo is None:
|
||||
original_created = original_created.replace(tzinfo=timezone.utc)
|
||||
|
||||
delta = new_when - original_created
|
||||
shopping_list.created_at = new_when
|
||||
|
||||
if not keep_expiry and shopping_list.expires_at:
|
||||
shopping_list.expires_at = shift_datetime_preserving_timezone(shopping_list.expires_at, delta)
|
||||
|
||||
if not keep_item_times:
|
||||
for item in shopping_list.items:
|
||||
if item.added_at:
|
||||
item.added_at = shift_datetime_preserving_timezone(item.added_at, delta)
|
||||
if item.purchased_at:
|
||||
item.purchased_at = shift_datetime_preserving_timezone(item.purchased_at, delta)
|
||||
|
||||
return shopping_list, delta
|
||||
|
||||
|
||||
def rename_list(shopping_list: ShoppingList, new_title: str):
|
||||
normalized = (new_title or '').strip()
|
||||
if not normalized:
|
||||
raise ValueError('Podaj nowy tytul listy.')
|
||||
shopping_list.title = normalized
|
||||
return shopping_list
|
||||
|
||||
|
||||
def set_list_archived(shopping_list: ShoppingList, archived: bool = True):
|
||||
if shopping_list is None:
|
||||
raise ValueError('Lista nie istnieje.')
|
||||
shopping_list.is_archived = bool(archived)
|
||||
return shopping_list
|
||||
|
||||
|
||||
def assign_list_owner(shopping_list: ShoppingList, owner: User):
|
||||
if shopping_list is None:
|
||||
raise ValueError('Lista nie istnieje.')
|
||||
if owner is None:
|
||||
raise ValueError('Nie znaleziono docelowego wlasciciela.')
|
||||
shopping_list.owner_id = owner.id
|
||||
return shopping_list
|
||||
|
||||
|
||||
def delete_list_with_relations(shopping_list: ShoppingList):
|
||||
if shopping_list is None:
|
||||
raise ValueError('Lista nie istnieje.')
|
||||
shopping_list.categories.clear()
|
||||
ListPermission.query.filter_by(list_id=shopping_list.id).delete(synchronize_session=False)
|
||||
ListActivityLog.query.filter_by(list_id=shopping_list.id).delete(synchronize_session=False)
|
||||
Expense.query.filter_by(list_id=shopping_list.id).delete(synchronize_session=False)
|
||||
Receipt.query.filter_by(list_id=shopping_list.id).delete(synchronize_session=False)
|
||||
Item.query.filter_by(list_id=shopping_list.id).delete(synchronize_session=False)
|
||||
db.session.delete(shopping_list)
|
||||
|
||||
|
||||
def duplicate_list_many(source_list: ShoppingList, schedule_values: list[datetime], owner: User | None = None, title_prefix: str | None = None):
|
||||
created_lists = []
|
||||
base_prefix = (title_prefix or '').strip()
|
||||
for idx, scheduled_for in enumerate(schedule_values, start=1):
|
||||
title = None
|
||||
if base_prefix:
|
||||
title = f'{base_prefix} #{idx}'
|
||||
created_lists.append(duplicate_list_for_schedule(source_list, scheduled_for=scheduled_for, owner=owner, title=title))
|
||||
return created_lists
|
||||
|
||||
|
||||
def create_list_from_template_at_schedule(template: ListTemplate, owner: User, scheduled_for: datetime, title: str | None = None):
|
||||
if scheduled_for.tzinfo is None:
|
||||
scheduled_for = scheduled_for.replace(tzinfo=timezone.utc)
|
||||
|
||||
new_list = ShoppingList(
|
||||
title=(title or template.name).strip(),
|
||||
owner_id=owner.id,
|
||||
share_token=generate_share_token(8),
|
||||
is_temporary=False,
|
||||
expires_at=None,
|
||||
created_at=scheduled_for,
|
||||
)
|
||||
db.session.add(new_list)
|
||||
db.session.flush()
|
||||
|
||||
for idx, item in enumerate(template.items, start=1):
|
||||
db.session.add(Item(
|
||||
list_id=new_list.id,
|
||||
name=item.name,
|
||||
quantity=item.quantity or 1,
|
||||
note=item.note,
|
||||
position=item.position or idx,
|
||||
added_by=owner.id,
|
||||
added_at=scheduled_for,
|
||||
))
|
||||
|
||||
db.session.commit()
|
||||
return new_list
|
||||
|
||||
def hash_api_token(token: str) -> str:
|
||||
return hashlib.sha256((token or '').encode('utf-8')).hexdigest()
|
||||
|
||||
@@ -387,6 +499,11 @@ def action_label(action: str) -> str:
|
||||
'item_unmarked_not_purchased': 'przywrócił produkt',
|
||||
'expense_added': 'dodał wydatek',
|
||||
'list_duplicated': 'zduplikował listę',
|
||||
'list_moved': 'przeniósł listę',
|
||||
'list_archived': 'zarchiwizował listę',
|
||||
'list_unarchived': 'przywrócił listę z archiwum',
|
||||
'list_owner_changed': 'zmienił właściciela listy',
|
||||
'list_renamed': 'zmienił nazwę listy',
|
||||
'template_created': 'utworzył szablon',
|
||||
}.get(action, action)
|
||||
|
||||
@@ -821,7 +938,7 @@ def get_progress(list_id: int) -> tuple[int, int, float]:
|
||||
result = (
|
||||
db.session.query(
|
||||
func.count(Item.id),
|
||||
func.sum(case((Item.purchased == True, 1), else_=0)),
|
||||
func.sum(case(((Item.purchased == True) & (Item.not_purchased == False), 1), else_=0)),
|
||||
)
|
||||
.filter(Item.list_id == list_id)
|
||||
.first()
|
||||
|
||||
@@ -682,6 +682,12 @@ def edit_list(list_id):
|
||||
elif action == "toggle_purchased":
|
||||
item = get_valid_item_or_404(request.form.get("item_id"), list_id)
|
||||
item.purchased = not item.purchased
|
||||
if item.purchased:
|
||||
item.not_purchased = False
|
||||
item.not_purchased_reason = None
|
||||
item.purchased_at = utcnow()
|
||||
else:
|
||||
item.purchased_at = None
|
||||
db.session.commit()
|
||||
flash("Zmieniono status oznaczenia produktu", "success")
|
||||
return redirect(url_for("edit_list", list_id=list_id))
|
||||
|
||||
@@ -115,7 +115,7 @@ def main_page():
|
||||
db.session.query(
|
||||
Item.list_id,
|
||||
func.count(Item.id).label("total_count"),
|
||||
func.sum(case((Item.purchased == True, 1), else_=0)).label(
|
||||
func.sum(case((((Item.purchased == True) & (Item.not_purchased == False)), 1), else_=0)).label(
|
||||
"purchased_count"
|
||||
),
|
||||
func.sum(case((Item.not_purchased == True, 1), else_=0)).label(
|
||||
@@ -163,6 +163,28 @@ def main_page():
|
||||
l.total_expense = 0
|
||||
l.category_badges = []
|
||||
|
||||
def build_progress_summary(lists_):
|
||||
total_lists = len(lists_)
|
||||
total_products = sum(getattr(l, "total_count", 0) or 0 for l in lists_)
|
||||
purchased_products = sum(getattr(l, "purchased_count", 0) or 0 for l in lists_)
|
||||
not_purchased_products = sum(getattr(l, "not_purchased_count", 0) or 0 for l in lists_)
|
||||
total_expense = float(sum((getattr(l, "total_expense", 0) or 0) for l in lists_))
|
||||
completion_percent = (
|
||||
(purchased_products / total_products) * 100 if total_products > 0 else 0
|
||||
)
|
||||
return {
|
||||
"list_count": total_lists,
|
||||
"total_products": total_products,
|
||||
"purchased_products": purchased_products,
|
||||
"not_purchased_products": not_purchased_products,
|
||||
"remaining_products": max(total_products - purchased_products - not_purchased_products, 0),
|
||||
"total_expense": round(total_expense, 2),
|
||||
"completion_percent": completion_percent,
|
||||
}
|
||||
|
||||
user_lists_summary = build_progress_summary(user_lists)
|
||||
accessible_lists_summary = build_progress_summary(accessible_lists)
|
||||
|
||||
expiring_lists = get_expiring_lists_for_user(current_user.id) if current_user.is_authenticated else []
|
||||
templates = (ListTemplate.query.filter_by(is_active=True, created_by=current_user.id).order_by(ListTemplate.name.asc()).all() if current_user.is_authenticated else [])
|
||||
|
||||
@@ -178,16 +200,16 @@ def main_page():
|
||||
selected_month=month_str,
|
||||
expiring_lists=expiring_lists,
|
||||
templates=templates,
|
||||
user_lists_summary=user_lists_summary,
|
||||
accessible_lists_summary=accessible_lists_summary,
|
||||
)
|
||||
|
||||
|
||||
@app.route("/system-auth", methods=["GET", "POST"])
|
||||
def system_auth():
|
||||
if (
|
||||
current_user.is_authenticated
|
||||
or request.cookies.get("authorized") == AUTHORIZED_COOKIE_VALUE
|
||||
):
|
||||
flash("Jesteś już zalogowany lub autoryzowany.", "info")
|
||||
|
||||
if request.cookies.get("authorized") == AUTHORIZED_COOKIE_VALUE:
|
||||
flash("Jesteś już autoryzowany.", "info")
|
||||
return redirect(url_for("main_page"))
|
||||
|
||||
ip = request.access_route[0]
|
||||
@@ -570,9 +592,9 @@ def view_list(list_id):
|
||||
percent = (purchased_count / total_count * 100) if total_count > 0 else 0
|
||||
|
||||
for item in items:
|
||||
if item.added_by != shopping_list.owner_id:
|
||||
if item.added_by and item.added_by != shopping_list.owner_id:
|
||||
item.added_by_display = (
|
||||
item.added_by_user.username if item.added_by_user else "?"
|
||||
item.added_by_user.username if item.added_by_user else None
|
||||
)
|
||||
else:
|
||||
item.added_by_display = None
|
||||
|
||||
@@ -441,9 +441,9 @@ def shared_list(token=None, list_id=None):
|
||||
]
|
||||
|
||||
for item in items:
|
||||
if item.added_by != shopping_list.owner_id:
|
||||
if item.added_by and item.added_by != shopping_list.owner_id:
|
||||
item.added_by_display = (
|
||||
item.added_by_user.username if item.added_by_user else "?"
|
||||
item.added_by_user.username if item.added_by_user else None
|
||||
)
|
||||
else:
|
||||
item.added_by_display = None
|
||||
|
||||
+168
-1
@@ -345,6 +345,8 @@ def handle_check_item(data):
|
||||
if item:
|
||||
item.purchased = True
|
||||
item.purchased_at = datetime.now(UTC)
|
||||
item.not_purchased = False
|
||||
item.not_purchased_reason = None
|
||||
log_list_activity(item.list_id, 'item_checked', item_name=item.name, actor=current_user if current_user.is_authenticated else None, actor_name=current_user.username if current_user.is_authenticated else 'Gość')
|
||||
db.session.commit()
|
||||
|
||||
@@ -470,6 +472,8 @@ def handle_mark_not_purchased(data):
|
||||
if item:
|
||||
item.not_purchased = True
|
||||
item.not_purchased_reason = reason
|
||||
item.purchased = False
|
||||
item.purchased_at = None
|
||||
log_list_activity(item.list_id, 'item_marked_not_purchased', item_name=item.name, actor=current_user if current_user.is_authenticated else None, actor_name=current_user.username if current_user.is_authenticated else 'Gość', details=reason or None)
|
||||
db.session.commit()
|
||||
emit(
|
||||
@@ -590,6 +594,22 @@ def lists_cli():
|
||||
"""Operacje CLI na listach zakupowych."""
|
||||
|
||||
|
||||
def _load_list_for_cli(list_id: int):
|
||||
return ShoppingList.query.options(joinedload(ShoppingList.items), joinedload(ShoppingList.categories), joinedload(ShoppingList.owner)).get(list_id)
|
||||
|
||||
|
||||
def _parse_many_when_values(raw_values: str):
|
||||
values = []
|
||||
for part in (raw_values or '').split(','):
|
||||
normalized = part.strip()
|
||||
if not normalized:
|
||||
continue
|
||||
values.append(parse_cli_datetime(normalized))
|
||||
if not values:
|
||||
raise ValueError('Podaj co najmniej jedna date w --when-list.')
|
||||
return values
|
||||
|
||||
|
||||
@lists_cli.command("copy-schedule")
|
||||
@click.option("--source-list-id", required=True, type=int, help="ID listy zrodlowej.")
|
||||
@click.option("--when", "when_value", required=True, help="Nowa data utworzenia listy: YYYY-MM-DD lub YYYY-MM-DD HH:MM")
|
||||
@@ -597,7 +617,7 @@ def lists_cli():
|
||||
@click.option("--title", default=None, help="Nowy tytul listy. Domyslnie taki sam jak w oryginale.")
|
||||
def lists_copy_schedule_command(source_list_id, when_value, owner_value, title):
|
||||
with app.app_context():
|
||||
source_list = ShoppingList.query.options(joinedload(ShoppingList.items), joinedload(ShoppingList.categories)).get(source_list_id)
|
||||
source_list = _load_list_for_cli(source_list_id)
|
||||
if not source_list:
|
||||
raise click.ClickException('Nie znaleziono listy zrodlowej.')
|
||||
|
||||
@@ -613,6 +633,153 @@ def lists_copy_schedule_command(source_list_id, when_value, owner_value, title):
|
||||
raise click.ClickException('Nie znaleziono docelowego wlasciciela.')
|
||||
|
||||
new_list = duplicate_list_for_schedule(source_list, scheduled_for=scheduled_for, owner=owner, title=title)
|
||||
log_list_activity(new_list.id, 'list_duplicated', actor_name='CLI', details=f'copy-schedule ze zrodla #{source_list.id}')
|
||||
db.session.commit()
|
||||
click.echo(
|
||||
f"Utworzono kopie listy: nowa_id={new_list.id}, tytul={new_list.title}, created_at={new_list.created_at.isoformat()}"
|
||||
)
|
||||
|
||||
|
||||
@lists_cli.command("move")
|
||||
@click.option("--list-id", required=True, type=int, help="ID listy.")
|
||||
@click.option("--when", "when_value", required=True, help="Nowy termin listy: YYYY-MM-DD lub YYYY-MM-DD HH:MM")
|
||||
@click.option("--keep-item-times", is_flag=True, help="Nie przesuwaj added_at/purchased_at pozycji.")
|
||||
@click.option("--keep-expiry", is_flag=True, help="Nie przesuwaj expires_at.")
|
||||
def lists_move_command(list_id, when_value, keep_item_times, keep_expiry):
|
||||
with app.app_context():
|
||||
shopping_list = _load_list_for_cli(list_id)
|
||||
if not shopping_list:
|
||||
raise click.ClickException('Nie znaleziono listy.')
|
||||
try:
|
||||
new_when = parse_cli_datetime(when_value)
|
||||
except ValueError as exc:
|
||||
raise click.ClickException(str(exc))
|
||||
old_created = shopping_list.created_at
|
||||
move_list_schedule(shopping_list, new_when, keep_item_times=keep_item_times, keep_expiry=keep_expiry)
|
||||
log_list_activity(shopping_list.id, 'list_moved', actor_name='CLI', details=f'Z {old_created} na {shopping_list.created_at}')
|
||||
db.session.commit()
|
||||
click.echo(f'Przeniesiono liste #{shopping_list.id} na {shopping_list.created_at.isoformat()}')
|
||||
|
||||
|
||||
@lists_cli.command("archive")
|
||||
@click.option("--list-id", required=True, type=int, help="ID listy.")
|
||||
def lists_archive_command(list_id):
|
||||
with app.app_context():
|
||||
shopping_list = _load_list_for_cli(list_id)
|
||||
if not shopping_list:
|
||||
raise click.ClickException('Nie znaleziono listy.')
|
||||
set_list_archived(shopping_list, archived=True)
|
||||
log_list_activity(shopping_list.id, 'list_archived', actor_name='CLI')
|
||||
db.session.commit()
|
||||
click.echo(f'Zarchiwizowano liste #{shopping_list.id}.')
|
||||
|
||||
|
||||
@lists_cli.command("unarchive")
|
||||
@click.option("--list-id", required=True, type=int, help="ID listy.")
|
||||
def lists_unarchive_command(list_id):
|
||||
with app.app_context():
|
||||
shopping_list = _load_list_for_cli(list_id)
|
||||
if not shopping_list:
|
||||
raise click.ClickException('Nie znaleziono listy.')
|
||||
set_list_archived(shopping_list, archived=False)
|
||||
log_list_activity(shopping_list.id, 'list_unarchived', actor_name='CLI')
|
||||
db.session.commit()
|
||||
click.echo(f'Przywrocono liste #{shopping_list.id} z archiwum.')
|
||||
|
||||
|
||||
@lists_cli.command("assign-owner")
|
||||
@click.option("--list-id", required=True, type=int, help="ID listy.")
|
||||
@click.option("--owner", "owner_value", required=True, help="Nowy wlasciciel: username albo ID.")
|
||||
def lists_assign_owner_command(list_id, owner_value):
|
||||
with app.app_context():
|
||||
shopping_list = _load_list_for_cli(list_id)
|
||||
if not shopping_list:
|
||||
raise click.ClickException('Nie znaleziono listy.')
|
||||
owner = resolve_user_identifier(owner_value)
|
||||
if not owner:
|
||||
raise click.ClickException('Nie znaleziono docelowego wlasciciela.')
|
||||
previous_owner = shopping_list.owner.username if shopping_list.owner else shopping_list.owner_id
|
||||
assign_list_owner(shopping_list, owner)
|
||||
log_list_activity(shopping_list.id, 'list_owner_changed', actor_name='CLI', details=f'{previous_owner} -> {owner.username}')
|
||||
db.session.commit()
|
||||
click.echo(f'Zmieniono wlasciciela listy #{shopping_list.id} na {owner.username}.')
|
||||
|
||||
|
||||
@lists_cli.command("create-from-template")
|
||||
@click.option("--template-id", required=True, type=int, help="ID szablonu.")
|
||||
@click.option("--owner", "owner_value", required=True, help="Wlasciciel nowej listy: username albo ID.")
|
||||
@click.option("--when", "when_value", default=None, help="Termin utworzenia: YYYY-MM-DD lub YYYY-MM-DD HH:MM")
|
||||
@click.option("--title", default=None, help="Tytul nowej listy.")
|
||||
def lists_create_from_template_command(template_id, owner_value, when_value, title):
|
||||
with app.app_context():
|
||||
template = ListTemplate.query.options(joinedload(ListTemplate.items)).get(template_id)
|
||||
if not template:
|
||||
raise click.ClickException('Nie znaleziono szablonu.')
|
||||
owner = resolve_user_identifier(owner_value)
|
||||
if not owner:
|
||||
raise click.ClickException('Nie znaleziono docelowego wlasciciela.')
|
||||
try:
|
||||
scheduled_for = parse_cli_datetime(when_value) if when_value else datetime.now(timezone.utc)
|
||||
except ValueError as exc:
|
||||
raise click.ClickException(str(exc))
|
||||
new_list = create_list_from_template_at_schedule(template, owner=owner, scheduled_for=scheduled_for, title=title)
|
||||
log_list_activity(new_list.id, 'template_created', actor_name='CLI', details=f'create-from-template z szablonu #{template.id}')
|
||||
db.session.commit()
|
||||
click.echo(f'Utworzono liste z szablonu: nowa_id={new_list.id}, tytul={new_list.title}, created_at={new_list.created_at.isoformat()}')
|
||||
|
||||
|
||||
@lists_cli.command("delete")
|
||||
@click.option("--list-id", required=True, type=int, help="ID listy.")
|
||||
def lists_delete_command(list_id):
|
||||
with app.app_context():
|
||||
shopping_list = _load_list_for_cli(list_id)
|
||||
if not shopping_list:
|
||||
raise click.ClickException('Nie znaleziono listy.')
|
||||
title = shopping_list.title
|
||||
delete_list_with_relations(shopping_list)
|
||||
db.session.commit()
|
||||
click.echo(f'Usunieto liste #{list_id}: {title}')
|
||||
|
||||
|
||||
@lists_cli.command("rename")
|
||||
@click.option("--list-id", required=True, type=int, help="ID listy.")
|
||||
@click.option("--title", "new_title", required=True, help="Nowy tytul listy.")
|
||||
def lists_rename_command(list_id, new_title):
|
||||
with app.app_context():
|
||||
shopping_list = _load_list_for_cli(list_id)
|
||||
if not shopping_list:
|
||||
raise click.ClickException('Nie znaleziono listy.')
|
||||
old_title = shopping_list.title
|
||||
try:
|
||||
rename_list(shopping_list, new_title)
|
||||
except ValueError as exc:
|
||||
raise click.ClickException(str(exc))
|
||||
log_list_activity(shopping_list.id, 'list_renamed', actor_name='CLI', details=f'{old_title} -> {shopping_list.title}')
|
||||
db.session.commit()
|
||||
click.echo(f'Zmieniono tytul listy #{shopping_list.id} na: {shopping_list.title}')
|
||||
|
||||
|
||||
@lists_cli.command("duplicate-many")
|
||||
@click.option("--source-list-id", required=True, type=int, help="ID listy zrodlowej.")
|
||||
@click.option("--when-list", required=True, help="Lista terminow rozdzielona przecinkami.")
|
||||
@click.option("--owner", "owner_value", default=None, help="Nowy wlasciciel: username albo ID.")
|
||||
@click.option("--title-prefix", default=None, help="Prefiks tytulu dla nowych list.")
|
||||
def lists_duplicate_many_command(source_list_id, when_list, owner_value, title_prefix):
|
||||
with app.app_context():
|
||||
source_list = _load_list_for_cli(source_list_id)
|
||||
if not source_list:
|
||||
raise click.ClickException('Nie znaleziono listy zrodlowej.')
|
||||
owner = None
|
||||
if owner_value:
|
||||
owner = resolve_user_identifier(owner_value)
|
||||
if not owner:
|
||||
raise click.ClickException('Nie znaleziono docelowego wlasciciela.')
|
||||
try:
|
||||
schedule_values = _parse_many_when_values(when_list)
|
||||
except ValueError as exc:
|
||||
raise click.ClickException(str(exc))
|
||||
created_lists = duplicate_list_many(source_list, schedule_values=schedule_values, owner=owner, title_prefix=title_prefix)
|
||||
for new_list in created_lists:
|
||||
log_list_activity(new_list.id, 'list_duplicated', actor_name='CLI', details=f'duplicate-many ze zrodla #{source_list.id}')
|
||||
db.session.commit()
|
||||
click.echo('Utworzono listy: ' + ', '.join([f'#{row.id}@{row.created_at.isoformat()}' for row in created_lists]))
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
import os
|
||||
import sys
|
||||
import platform
|
||||
import socket
|
||||
from datetime import datetime
|
||||
|
||||
import psutil
|
||||
|
||||
try:
|
||||
from sqlalchemy import text
|
||||
except Exception:
|
||||
text = None
|
||||
|
||||
def mb(x):
|
||||
return int(x / 1024 / 1024)
|
||||
|
||||
|
||||
def get_db_type(app):
|
||||
uri = app.config.get("SQLALCHEMY_DATABASE_URI") or app.config.get("DATABASE_URL", "")
|
||||
|
||||
if not uri:
|
||||
return "NONE"
|
||||
|
||||
if uri.startswith("sqlite"):
|
||||
return "SQLite"
|
||||
if uri.startswith("mysql"):
|
||||
return "MySQL"
|
||||
if uri.startswith("postgresql"):
|
||||
return "PostgreSQL"
|
||||
|
||||
return "OTHER"
|
||||
|
||||
def print_startup_info(app):
|
||||
host = os.getenv("HOST", "127.0.0.1")
|
||||
port = int(os.getenv("PORT", "8000"))
|
||||
|
||||
rules = list(app.url_map.iter_rules())
|
||||
|
||||
cpu = psutil.cpu_percent(interval=0.2)
|
||||
ram = psutil.virtual_memory()
|
||||
proc = psutil.Process(os.getpid())
|
||||
|
||||
db_type = get_db_type(app)
|
||||
|
||||
print("\n" + "="*52)
|
||||
print(" APP START")
|
||||
print("="*52)
|
||||
|
||||
# SYSTEM
|
||||
print("\n[ SYSTEM ]")
|
||||
print(f"Time : {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
||||
print(f"OS : {platform.system()} {platform.release()} ({platform.machine()})")
|
||||
print(f"Python : {sys.version.split()[0]}")
|
||||
print(f"Host : {socket.gethostname()}")
|
||||
|
||||
# SERVER
|
||||
print("\n[ SERVER ]")
|
||||
print(f"Bind : {host}:{port}")
|
||||
print(f"URL : http://127.0.0.1:{port}")
|
||||
|
||||
# APP
|
||||
print("\n[ APP ]")
|
||||
print(f"Name : {app.name}")
|
||||
print(f"Mode : {'DEV' if app.debug else 'PROD'}")
|
||||
print(f"Debug : {app.debug}")
|
||||
|
||||
# RESOURCES
|
||||
print("\n[ RESOURCES ]")
|
||||
print(f"CPU : {cpu:>5.1f}%")
|
||||
print(f"RAM : {ram.percent:>5.1f}% ({mb(ram.used)} / {mb(ram.total)} MB)")
|
||||
print(f"PROC : {mb(proc.memory_info().rss)} MB")
|
||||
|
||||
# DATABASE
|
||||
print("\n[ DATABASE ]")
|
||||
print(f"Type : {db_type}")
|
||||
|
||||
# SECURITY
|
||||
print("\n[ SECURITY ]")
|
||||
print(f"Secret : {'OK' if app.config.get('SECRET_KEY') else 'MISSING'}")
|
||||
print(f"Talis : {'OFF' if app.config.get('TALISMAN_DISABLED') else 'ON'}")
|
||||
|
||||
# HEALTH
|
||||
print("\n[ HEALTH ]")
|
||||
print(f"Uploads: {'OK' if os.path.exists('uploads') else 'MISS'}")
|
||||
print(f"Static : {'OK' if os.path.exists(app.static_folder) else 'MISS'}")
|
||||
|
||||
# ROUTES
|
||||
print("\n[ ROUTES ]")
|
||||
print(f"Total : {len(rules)}")
|
||||
|
||||
# STATUS
|
||||
print("\n[ STATUS ]")
|
||||
print("READY")
|
||||
|
||||
print("="*52 + "\n")
|
||||
+1032
-577
File diff suppressed because it is too large
Load Diff
Binary file not shown.
@@ -1,416 +0,0 @@
|
||||
/* --- Rozmiary i kursory --- */
|
||||
.large-checkbox {
|
||||
width: 1.5em;
|
||||
height: 1.5em;
|
||||
}
|
||||
|
||||
.clickable-item {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
/* --- Kolory tła (nadpisane klasy Bootstrapa) --- */
|
||||
.bg-success {
|
||||
background-color: #1e7e34 !important;
|
||||
}
|
||||
|
||||
.btn-outline-light:hover {
|
||||
background-color: #ffc107 !important;
|
||||
color: #000 !important;
|
||||
border-color: #ffc107 !important;
|
||||
}
|
||||
|
||||
.progress-dark {
|
||||
background-color: #212529 !important;
|
||||
border-radius: 20px !important;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.progress-bar {
|
||||
border-radius: 0 !important;
|
||||
transition: width 0.4s ease, background-color 0.4s ease;
|
||||
}
|
||||
|
||||
.progress-bar:first-child {
|
||||
border-top-left-radius: 20px !important;
|
||||
border-bottom-left-radius: 20px !important;
|
||||
}
|
||||
|
||||
.progress-bar:last-child {
|
||||
border-top-right-radius: 20px !important;
|
||||
border-bottom-right-radius: 20px !important;
|
||||
}
|
||||
|
||||
|
||||
/* rodzic już ma position-relative */
|
||||
.progress-label {
|
||||
position: absolute;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
pointer-events: none;
|
||||
/* klikalne przyciski obok paska nie ucierpią */
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.progress-thin {
|
||||
height: 12px;
|
||||
}
|
||||
|
||||
.item-not-checked {
|
||||
background-color: #2c2f33 !important;
|
||||
color: white !important;
|
||||
}
|
||||
|
||||
/* --- Styl przycisku wyboru pliku --- */
|
||||
input[type="file"]::file-selector-button {
|
||||
background-color: #225d36;
|
||||
color: #fff;
|
||||
border: none;
|
||||
padding: 0.5em 1em;
|
||||
border-radius: 4px;
|
||||
font-weight: bold;
|
||||
cursor: pointer;
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
/* --- Ciemniejsze alerty Bootstrapa --- */
|
||||
.alert-success {
|
||||
background-color: #225d36 !important;
|
||||
color: #eaffea !important;
|
||||
border-color: #174428 !important;
|
||||
}
|
||||
|
||||
.alert-danger {
|
||||
background-color: #7a1f23 !important;
|
||||
color: #ffeaea !important;
|
||||
border-color: #531417 !important;
|
||||
}
|
||||
|
||||
.alert-info {
|
||||
background-color: #1d3a4d !important;
|
||||
color: #eaf6ff !important;
|
||||
border-color: #152837 !important;
|
||||
}
|
||||
|
||||
.alert-warning {
|
||||
background-color: #665c1e !important;
|
||||
color: #fffbe5 !important;
|
||||
border-color: #4d4415 !important;
|
||||
}
|
||||
|
||||
/* Badge - kolory pasujące do ciemnych alertów */
|
||||
.badge.bg-success,
|
||||
.badge.text-bg-success {
|
||||
background-color: #225d36 !important;
|
||||
color: #eaffea !important;
|
||||
}
|
||||
|
||||
.badge.bg-danger,
|
||||
.badge.text-bg-danger {
|
||||
background-color: #7a1f23 !important;
|
||||
color: #ffeaea !important;
|
||||
}
|
||||
|
||||
.badge.bg-info,
|
||||
.badge.text-bg-info {
|
||||
background-color: #1d3a4d !important;
|
||||
color: #eaf6ff !important;
|
||||
}
|
||||
|
||||
.badge.bg-warning,
|
||||
.badge.text-bg-warning {
|
||||
background-color: #665c1e !important;
|
||||
color: #fffbe5 !important;
|
||||
}
|
||||
|
||||
.badge.bg-secondary,
|
||||
.badge.text-bg-secondary {
|
||||
background-color: #343a40 !important;
|
||||
color: #e2e3e5 !important;
|
||||
}
|
||||
|
||||
.badge.bg-primary,
|
||||
.badge.text-bg-primary {
|
||||
background-color: #184076 !important;
|
||||
color: #e6f0ff !important;
|
||||
}
|
||||
|
||||
.badge.bg-light,
|
||||
.badge.text-bg-light {
|
||||
background-color: #444950 !important;
|
||||
color: #f8f9fa !important;
|
||||
}
|
||||
|
||||
.badge.bg-dark,
|
||||
.badge.text-bg-dark {
|
||||
background-color: #181a1b !important;
|
||||
color: #f8f9fa !important;
|
||||
}
|
||||
|
||||
/* --- Styl dla własnych checkboxów --- */
|
||||
input[type="checkbox"].large-checkbox {
|
||||
appearance: none;
|
||||
-webkit-appearance: none;
|
||||
-moz-appearance: none;
|
||||
width: 1.5em;
|
||||
height: 1.5em;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
outline: none;
|
||||
background: none;
|
||||
cursor: pointer;
|
||||
position: relative;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
input[type="checkbox"].large-checkbox::before {
|
||||
content: '✗';
|
||||
color: #dc3545;
|
||||
font-size: 1.5em;
|
||||
font-weight: bold;
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 50%;
|
||||
transform: translateY(-50%);
|
||||
line-height: 1;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
input[type="checkbox"].large-checkbox:checked::before {
|
||||
content: '✓';
|
||||
color: #ffffff;
|
||||
}
|
||||
|
||||
input[type="checkbox"].large-checkbox:disabled::before {
|
||||
opacity: 0.5;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
input[type="checkbox"].large-checkbox:disabled {
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
#tempToggle {
|
||||
border-top-left-radius: 0;
|
||||
border-bottom-left-radius: 0;
|
||||
}
|
||||
|
||||
input.form-control {
|
||||
border-top-right-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
|
||||
.info-bar-fixed {
|
||||
width: 100%;
|
||||
color: #f8f9fa;
|
||||
background-color: #212529;
|
||||
border-radius: 12px 12px 0 0;
|
||||
text-align: center;
|
||||
padding: 10px 10px;
|
||||
font-size: 0.95rem;
|
||||
box-sizing: border-box;
|
||||
margin-top: 2rem;
|
||||
box-shadow: 0 -1px 4px rgba(0, 0, 0, 0.25);
|
||||
}
|
||||
|
||||
@media (max-width: 768px) {
|
||||
.info-bar-fixed {
|
||||
position: static;
|
||||
font-size: 0.85rem;
|
||||
padding: 8px 4px;
|
||||
border-radius: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.table-responsive {
|
||||
overflow-x: auto;
|
||||
-webkit-overflow-scrolling: touch;
|
||||
}
|
||||
|
||||
.table-responsive table {
|
||||
min-width: 1000px;
|
||||
}
|
||||
|
||||
.bg-dark .form-control::placeholder {
|
||||
color: #ccc !important;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.toast-body {
|
||||
color: #ffffff !important;
|
||||
font-weight: 500 !important;
|
||||
}
|
||||
|
||||
.toast {
|
||||
animation: fadeInUp 0.5s ease;
|
||||
}
|
||||
|
||||
@keyframes fadeInUp {
|
||||
from {
|
||||
opacity: 0;
|
||||
transform: translateY(20px);
|
||||
}
|
||||
|
||||
to {
|
||||
opacity: 1;
|
||||
transform: translateY(0);
|
||||
}
|
||||
}
|
||||
|
||||
#mass-add-list li.active {
|
||||
background: #198754 !important;
|
||||
color: #fff !important;
|
||||
border: 1px solid #000000 !important;
|
||||
}
|
||||
|
||||
#mass-add-list li {
|
||||
transition: background 0.2s;
|
||||
}
|
||||
|
||||
.quantity-input {
|
||||
width: 60px;
|
||||
background: #343a40;
|
||||
color: #fff;
|
||||
border: 1px solid #495057;
|
||||
border-radius: 4px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.add-btn {
|
||||
margin-left: 10px;
|
||||
}
|
||||
|
||||
.quantity-controls {
|
||||
min-width: 120px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-end;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.list-group-item {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
#empty-placeholder {
|
||||
font-style: italic;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
#items li.hide-purchased {
|
||||
display: none !important;
|
||||
}
|
||||
|
||||
.list-group-item:first-child,
|
||||
.list-group-item:last-child {
|
||||
border-radius: 0 !important;
|
||||
}
|
||||
|
||||
.fade-out {
|
||||
opacity: 0;
|
||||
transition: opacity 0.5s ease;
|
||||
}
|
||||
|
||||
@media (pointer: fine) {
|
||||
.only-mobile {
|
||||
display: none !important;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
.ts-dropdown .active {
|
||||
background-color: #495057 !important;
|
||||
}
|
||||
|
||||
.pagination-dark .page-link {
|
||||
color: #fff;
|
||||
background-color: #212529;
|
||||
border: 1px solid #495057;
|
||||
}
|
||||
|
||||
.pagination-dark .page-link:hover {
|
||||
background-color: #343a40;
|
||||
border-color: #6c757d;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.pagination-dark .page-item.active .page-link {
|
||||
background-color: #0d6efd;
|
||||
border-color: #0d6efd;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.pagination-dark .page-item.disabled .page-link {
|
||||
background-color: #2b3035;
|
||||
border-color: #495057;
|
||||
color: #6c757d;
|
||||
}
|
||||
|
||||
.tom-dark .ts-control {
|
||||
background-color: #212529 !important;
|
||||
color: #fff !important;
|
||||
border: 1px solid #495057 !important;
|
||||
border-radius: 0.375rem;
|
||||
min-height: 38px;
|
||||
padding: 0.25rem 0.5rem;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.tom-dark .ts-control .item {
|
||||
background-color: #343a40 !important;
|
||||
color: #fff !important;
|
||||
border-radius: 0.25rem;
|
||||
padding: 2px 8px;
|
||||
margin-right: 4px;
|
||||
}
|
||||
|
||||
.ts-dropdown {
|
||||
background-color: #212529 !important;
|
||||
color: #fff !important;
|
||||
border: 1px solid #495057;
|
||||
border-radius: 0.375rem;
|
||||
z-index: 9999 !important;
|
||||
max-height: 300px;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
.ts-dropdown .active {
|
||||
background-color: #495057 !important;
|
||||
color: #fff !important;
|
||||
}
|
||||
|
||||
td select.tom-dark {
|
||||
width: 100%;
|
||||
max-width: 100%;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.table-dark.table-striped tbody tr:nth-of-type(odd) {
|
||||
background-color: rgba(255, 255, 255, 0.025);
|
||||
}
|
||||
|
||||
.table-dark tbody tr:hover {
|
||||
background-color: rgba(255, 255, 255, 0.04);
|
||||
}
|
||||
|
||||
.table-dark thead th {
|
||||
background-color: #1c1f22;
|
||||
color: #e1e1e1;
|
||||
font-weight: 500;
|
||||
border-bottom: 1px solid #3a3f44;
|
||||
}
|
||||
|
||||
.table-dark td,
|
||||
.table-dark th {
|
||||
padding: 0.6rem 0.75rem;
|
||||
vertical-align: middle;
|
||||
border-top: 1px solid #3a3f44;
|
||||
}
|
||||
|
||||
.card .table {
|
||||
border-radius: 0 !important;
|
||||
overflow: hidden;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
@@ -76,7 +76,7 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
}
|
||||
|
||||
// porzucenie zakresu
|
||||
document.querySelectorAll("#chartTab .range-btn").forEach(b => b.classList.remove("active"));
|
||||
document.querySelectorAll("#chartTab .chart-range-btn").forEach(b => b.classList.remove("active"));
|
||||
reloadRespectingSplit();
|
||||
});
|
||||
|
||||
@@ -90,9 +90,9 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
});
|
||||
|
||||
// ——— Predefiniowane zakresy pod wykresem ———
|
||||
document.querySelectorAll("#chartTab .range-btn").forEach((btn) => {
|
||||
document.querySelectorAll("#chartTab .chart-range-btn").forEach((btn) => {
|
||||
btn.addEventListener("click", function () {
|
||||
document.querySelectorAll("#chartTab .range-btn").forEach((b) => b.classList.remove("active"));
|
||||
document.querySelectorAll("#chartTab .chart-range-btn").forEach((b) => b.classList.remove("active"));
|
||||
this.classList.add("active");
|
||||
const r = this.getAttribute("data-range"); // last30days/currentmonth/monthly/quarterly/halfyearly/yearly
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
document.addEventListener('DOMContentLoaded', () => {
|
||||
const checkboxes = document.querySelectorAll('.list-checkbox');
|
||||
const totalEl = document.getElementById('listsTotal');
|
||||
const filterButtons = document.querySelectorAll('.range-btn');
|
||||
const filterButtons = document.querySelectorAll('#listsTab .table-range-btn');
|
||||
const rows = document.querySelectorAll('#listsTableBody tr');
|
||||
const categoryButtons = document.querySelectorAll('.category-filter');
|
||||
const applyCustomBtn = document.getElementById('applyCustomRange');
|
||||
@@ -136,7 +136,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
if (initialLoad) {
|
||||
filterByLast30Days();
|
||||
} else {
|
||||
const activeRange = document.querySelector('.range-btn.active');
|
||||
const activeRange = document.querySelector('#listsTab .table-range-btn.active');
|
||||
if (activeRange) filterByRange(activeRange.dataset.range);
|
||||
}
|
||||
applyExpenseFilter();
|
||||
@@ -158,7 +158,7 @@ document.addEventListener('DOMContentLoaded', () => {
|
||||
return;
|
||||
}
|
||||
initialLoad = false;
|
||||
document.querySelectorAll('.range-btn').forEach(b => b.classList.remove('active'));
|
||||
document.querySelectorAll('#listsTab .table-range-btn').forEach(b => b.classList.remove('active'));
|
||||
filterByCustomRange(startStr, endStr);
|
||||
applyExpenseFilter();
|
||||
applyCategoryFilter();
|
||||
|
||||
@@ -350,9 +350,12 @@ function renderItem(item, isShare = window.IS_SHARE, optionsOrShowEditOnly = fal
|
||||
if (item.not_purchased_reason) {
|
||||
infoParts.push(`<span class="text-dark">[ <b>Powód: ${escapeHtml(item.not_purchased_reason)}</b> ]</span>`);
|
||||
}
|
||||
const addedByDisplay = item.added_by_display;
|
||||
if (addedByDisplay) {
|
||||
infoParts.push(`<span class="text-info">[ Dodał/a: <b>${escapeHtml(addedByDisplay)}</b> ]</span>`);
|
||||
const addedByDisplay = item.added_by_display || (isShare ? item.added_by : '');
|
||||
const addedById = item.added_by_id != null ? Number(item.added_by_id) : null;
|
||||
const ownerId = item.owner_id != null ? Number(item.owner_id) : null;
|
||||
const shouldShowAddedBy = !!addedByDisplay && (addedById === null || ownerId === null || addedById !== ownerId);
|
||||
if (shouldShowAddedBy) {
|
||||
infoParts.push(`<span class="item-added-by-meta">· dodał/a: <b>${escapeHtml(addedByDisplay)}</b></span>`);
|
||||
}
|
||||
const infoHtml = infoParts.length
|
||||
? `<span class="info-line small" id="info-${item.id}">${infoParts.join(' ')}</span>`
|
||||
@@ -375,7 +378,7 @@ function renderItem(item, isShare = window.IS_SHARE, optionsOrShowEditOnly = fal
|
||||
|
||||
if (item.not_purchased) {
|
||||
actionButtons += `
|
||||
<button type="button" class="${wideBtn}" ${isArchived ? 'disabled' : `onclick="unmarkNotPurchased(${item.id})"`}>✅ Przywróć</button>`;
|
||||
<button type="button" class="${wideBtn}" ${isArchived ? 'disabled' : `onclick="unmarkNotPurchased(${item.id})"`}>Przywróć</button>`;
|
||||
} else if (!isShare || canShowShareActions || isOwner) {
|
||||
actionButtons += `
|
||||
<button type="button" class="${iconBtn}" ${canMarkNotPurchased ? `onclick="markNotPurchasedModal(event, ${item.id})"` : 'disabled'}>⚠️</button>`;
|
||||
@@ -386,7 +389,7 @@ function renderItem(item, isShare = window.IS_SHARE, optionsOrShowEditOnly = fal
|
||||
<button type="button" class="${iconBtn} shopping-action-btn--countdown" disabled data-countdown-for="${item.id}">${countdownSeconds}s</button>
|
||||
<button type="button" class="${iconBtn}" ${isArchived ? 'disabled' : `onclick='openEditItemModal(event, ${item.id}, ${nameForEdit}, ${quantity})'`}>✏️</button>
|
||||
<button type="button" class="${iconBtn}" ${isArchived ? 'disabled' : `onclick="deleteItem(${item.id})"`}>🗑️</button>`;
|
||||
} else if (canShowShareActions) {
|
||||
} else if (canShowShareActions || (!isShare && isOwner)) {
|
||||
actionButtons += `
|
||||
<button type="button" class="${iconBtn}" ${isArchived ? 'disabled' : `onclick="openNoteModal(event, ${item.id})"`}>📝</button>`;
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@ function toggleEmptyPlaceholder() {
|
||||
const li = document.createElement('li');
|
||||
li.id = 'empty-placeholder';
|
||||
li.className = 'list-group-item bg-dark text-secondary text-center w-100';
|
||||
li.textContent = 'Brak produktów w tej liście.';
|
||||
li.textContent = 'Brak produktów w tej liście.';
|
||||
list.appendChild(li);
|
||||
} else if (hasRealItems && placeholder) {
|
||||
placeholder.remove();
|
||||
@@ -206,7 +206,7 @@ function setupList(listId, username) {
|
||||
|
||||
const progressTitle = document.getElementById('progress-title');
|
||||
if (progressTitle) {
|
||||
progressTitle.textContent = `📊 Postęp listy — ${data.purchased_count}/${data.total_count} kupionych (${Math.round(data.percent)}%)`;
|
||||
progressTitle.textContent = `Postęp listy — ${data.purchased_count}/${data.total_count} kupionych (${Math.round(data.percent)}%)`;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -3,9 +3,9 @@ window.currentItemId = window.currentItemId ?? null;
|
||||
window.openNoteModal = function (event, itemId) {
|
||||
event.stopPropagation();
|
||||
window.currentItemId = itemId;
|
||||
const noteEl = document.querySelector(`#item-${itemId} small.text-danger`);
|
||||
const noteEl = document.querySelector(`#info-${itemId} .text-danger b`);
|
||||
document.getElementById('noteText').value = noteEl
|
||||
? noteEl.innerText.replace(/\[|\]|Powód:/g, "").trim()
|
||||
? noteEl.innerText.trim()
|
||||
: "";
|
||||
const modal = new bootstrap.Modal(document.getElementById('noteModal'));
|
||||
modal.show();
|
||||
|
||||
@@ -1,6 +1,69 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const modalElement = document.getElementById("productPreviewModal");
|
||||
if (!modalElement || typeof bootstrap === "undefined") return;
|
||||
|
||||
const modal = new bootstrap.Modal(modalElement);
|
||||
const modalTitle = document.getElementById("previewModalLabel");
|
||||
const productList = document.getElementById("product-list");
|
||||
|
||||
if (!modalTitle || !productList) return;
|
||||
|
||||
const renderState = (message, extraClass = "text-white") => {
|
||||
productList.innerHTML = "";
|
||||
|
||||
const wrapper = document.createElement("div");
|
||||
wrapper.className = "preview-modal-items";
|
||||
|
||||
const item = document.createElement("div");
|
||||
item.className = `preview-modal-list-item ${extraClass}`.trim();
|
||||
item.textContent = message;
|
||||
|
||||
wrapper.appendChild(item);
|
||||
productList.appendChild(wrapper);
|
||||
};
|
||||
|
||||
const createSection = (titleText) => {
|
||||
const section = document.createElement("section");
|
||||
section.className = "preview-product-section";
|
||||
|
||||
const title = document.createElement("h6");
|
||||
title.className = "preview-product-section-title";
|
||||
title.textContent = titleText;
|
||||
|
||||
const items = document.createElement("div");
|
||||
items.className = "preview-modal-items";
|
||||
|
||||
section.appendChild(title);
|
||||
section.appendChild(items);
|
||||
|
||||
return { section, items };
|
||||
};
|
||||
|
||||
const createItem = (itemData) => {
|
||||
const row = document.createElement("div");
|
||||
row.className = "preview-modal-list-item";
|
||||
|
||||
const name = document.createElement("span");
|
||||
name.className = "preview-modal-list-item__name";
|
||||
name.textContent = itemData.name;
|
||||
|
||||
const badge = document.createElement("span");
|
||||
badge.className = "badge";
|
||||
|
||||
if (itemData.purchased) {
|
||||
badge.classList.add("bg-success");
|
||||
} else if (itemData.not_purchased) {
|
||||
badge.classList.add("bg-warning", "text-dark");
|
||||
} else {
|
||||
badge.classList.add("bg-secondary");
|
||||
}
|
||||
|
||||
badge.textContent = `x${itemData.quantity}`;
|
||||
|
||||
row.appendChild(name);
|
||||
row.appendChild(badge);
|
||||
return row;
|
||||
};
|
||||
|
||||
modalElement.addEventListener("hidden.bs.modal", function () {
|
||||
document.querySelectorAll(".modal-backdrop").forEach((el) => el.remove());
|
||||
@@ -11,101 +74,66 @@ document.addEventListener("DOMContentLoaded", function () {
|
||||
document.querySelectorAll(".preview-btn").forEach((btn) => {
|
||||
btn.addEventListener("click", async () => {
|
||||
const listId = btn.dataset.listId;
|
||||
const modalTitle = document.getElementById("previewModalLabel");
|
||||
const productList = document.getElementById("product-list");
|
||||
|
||||
modalTitle.textContent = "Ładowanie...";
|
||||
productList.innerHTML = `
|
||||
<li class="list-group-item bg-dark text-white">
|
||||
⏳ Ładowanie produktów...
|
||||
</li>`;
|
||||
|
||||
renderState("⏳ Ładowanie produktów...");
|
||||
modal.show();
|
||||
|
||||
try {
|
||||
const res = await fetch(`/admin/list_items/${listId}`);
|
||||
if (!res.ok) {
|
||||
throw new Error(`HTTP ${res.status}`);
|
||||
}
|
||||
|
||||
const data = await res.json();
|
||||
const totalCount = Number(data.total_count || 0);
|
||||
const purchasedCount = Number(data.purchased_count || 0);
|
||||
const totalExpense = Number(data.total_expense || 0);
|
||||
const percent = totalCount > 0 ? Math.round((purchasedCount / totalCount) * 100) : 0;
|
||||
|
||||
modalTitle.textContent = `🛒 ${data.title}`;
|
||||
productList.innerHTML = "";
|
||||
|
||||
// 🔢 PODSUMOWANIE
|
||||
const summary = document.createElement("div");
|
||||
summary.className = "mb-3";
|
||||
|
||||
const percent =
|
||||
data.total_count > 0
|
||||
? Math.round((data.purchased_count / data.total_count) * 100)
|
||||
: 0;
|
||||
|
||||
summary.className = "preview-product-summary";
|
||||
summary.innerHTML = `
|
||||
<p class="mb-1">📦 <strong>${data.total_count}</strong> produktów</p>
|
||||
<p class="mb-1">✅ Kupione: <strong>${data.purchased_count}</strong> (${percent}%)</p>
|
||||
<p class="mb-1">💸 Wydatek: <strong>${data.total_expense.toFixed(2)} zł</strong></p>
|
||||
<hr class="my-2">
|
||||
`;
|
||||
<p class="mb-1">📦 <strong>${totalCount}</strong> produktów</p>
|
||||
<p class="mb-1">✅ Kupione: <strong>${purchasedCount}</strong> (${percent}%)</p>
|
||||
<p class="mb-0">💸 Wydatek: <strong>${totalExpense.toFixed(2)} zł</strong></p>`;
|
||||
productList.appendChild(summary);
|
||||
|
||||
// 🛒 LISTY PRODUKTÓW
|
||||
const purchasedList = document.createElement("ul");
|
||||
purchasedList.className = "list-group list-group-flush mb-3";
|
||||
|
||||
const notPurchasedList = document.createElement("ul");
|
||||
notPurchasedList.className = "list-group list-group-flush";
|
||||
const purchased = createSection("✔️ Kupione");
|
||||
const pending = createSection("🚫 Niekupione / Nieoznaczone");
|
||||
|
||||
let hasPurchased = false;
|
||||
let hasUnpurchased = false;
|
||||
let hasPending = false;
|
||||
|
||||
data.items.forEach((item) => {
|
||||
const li = document.createElement("li");
|
||||
li.className =
|
||||
"list-group-item bg-dark text-white d-flex justify-content-between";
|
||||
li.innerHTML = `
|
||||
<span>${item.name}</span>
|
||||
<span class="badge ${item.purchased
|
||||
? "bg-success"
|
||||
: item.not_purchased
|
||||
? "bg-warning text-dark"
|
||||
: "bg-secondary"
|
||||
}">
|
||||
x${item.quantity}
|
||||
</span>`;
|
||||
(data.items || []).forEach((item) => {
|
||||
const row = createItem(item);
|
||||
|
||||
if (item.purchased) {
|
||||
purchasedList.appendChild(li);
|
||||
purchased.items.appendChild(row);
|
||||
hasPurchased = true;
|
||||
} else {
|
||||
notPurchasedList.appendChild(li);
|
||||
hasUnpurchased = true;
|
||||
pending.items.appendChild(row);
|
||||
hasPending = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (hasPurchased) {
|
||||
const h5 = document.createElement("h6");
|
||||
h5.textContent = "✔️ Kupione";
|
||||
productList.appendChild(h5);
|
||||
productList.appendChild(purchasedList);
|
||||
productList.appendChild(purchased.section);
|
||||
}
|
||||
|
||||
if (hasUnpurchased) {
|
||||
const h5 = document.createElement("h6");
|
||||
h5.textContent = "🚫 Niekupione / Nieoznaczone";
|
||||
productList.appendChild(h5);
|
||||
productList.appendChild(notPurchasedList);
|
||||
if (hasPending) {
|
||||
productList.appendChild(pending.section);
|
||||
}
|
||||
|
||||
if (!hasPurchased && !hasUnpurchased) {
|
||||
productList.innerHTML = `
|
||||
<li class="list-group-item bg-dark text-muted fst-italic">
|
||||
Brak produktów
|
||||
</li>`;
|
||||
if (!hasPurchased && !hasPending) {
|
||||
renderState("Brak produktów", "text-muted fst-italic");
|
||||
}
|
||||
} catch (err) {
|
||||
} catch (error) {
|
||||
modalTitle.textContent = "Błąd";
|
||||
productList.innerHTML = `
|
||||
<li class="list-group-item bg-dark text-danger">
|
||||
❌ Błąd podczas ładowania
|
||||
</li>`;
|
||||
renderState("❌ Błąd podczas ładowania", "text-danger");
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,39 +1,55 @@
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const receiptSection = document.getElementById("receiptSection");
|
||||
const toggleBtn = document.querySelector('[data-bs-target="#receiptSection"]');
|
||||
const toggleEl = document.querySelector('[data-bs-target="#receiptSection"]');
|
||||
|
||||
if (!receiptSection || !toggleBtn) return;
|
||||
if (!receiptSection || !toggleEl) return;
|
||||
|
||||
const collapse = bootstrap.Collapse.getOrCreateInstance(receiptSection, { toggle: false });
|
||||
|
||||
if (localStorage.getItem("receiptSectionOpen") === "true") {
|
||||
new bootstrap.Collapse(receiptSection, { toggle: true });
|
||||
collapse.show();
|
||||
}
|
||||
|
||||
receiptSection.addEventListener('shown.bs.collapse', function () {
|
||||
localStorage.setItem("receiptSectionOpen", "true");
|
||||
});
|
||||
|
||||
receiptSection.addEventListener('hidden.bs.collapse', function () {
|
||||
localStorage.setItem("receiptSectionOpen", "false");
|
||||
});
|
||||
});
|
||||
|
||||
document.addEventListener("DOMContentLoaded", function () {
|
||||
const btn = document.getElementById("toggleReceiptBtn");
|
||||
const target = document.querySelector(btn.getAttribute("data-bs-target"));
|
||||
const titleEl = toggleEl.querySelector(".receipt-disclosure__title");
|
||||
|
||||
function updateUI() {
|
||||
const isShown = target.classList.contains("show");
|
||||
btn.innerHTML = isShown
|
||||
? "📄 Ukryj sekcję paragonów"
|
||||
: "📄 Pokaż sekcję paragonów";
|
||||
const isShown = receiptSection.classList.contains("show");
|
||||
|
||||
btn.classList.toggle("active", isShown);
|
||||
btn.classList.toggle("btn-outline-light", !isShown);
|
||||
btn.classList.toggle("btn-secondary", isShown);
|
||||
toggleEl.classList.toggle("is-open", isShown);
|
||||
toggleEl.setAttribute("aria-expanded", isShown ? "true" : "false");
|
||||
|
||||
if (titleEl) {
|
||||
titleEl.textContent = isShown
|
||||
? "Ukryj sekcję paragonów"
|
||||
: "Pokaż sekcję paragonów";
|
||||
}
|
||||
}
|
||||
|
||||
target.addEventListener("shown.bs.collapse", updateUI);
|
||||
target.addEventListener("hidden.bs.collapse", updateUI);
|
||||
function toggleSection() {
|
||||
collapse.toggle();
|
||||
}
|
||||
|
||||
toggleEl.addEventListener("click", function (event) {
|
||||
event.preventDefault();
|
||||
toggleSection();
|
||||
});
|
||||
|
||||
toggleEl.addEventListener("keydown", function (event) {
|
||||
if (event.key === "Enter" || event.key === " ") {
|
||||
event.preventDefault();
|
||||
toggleSection();
|
||||
}
|
||||
});
|
||||
|
||||
receiptSection.addEventListener("shown.bs.collapse", function () {
|
||||
localStorage.setItem("receiptSectionOpen", "true");
|
||||
updateUI();
|
||||
});
|
||||
|
||||
receiptSection.addEventListener("hidden.bs.collapse", function () {
|
||||
localStorage.setItem("receiptSectionOpen", "false");
|
||||
updateUI();
|
||||
});
|
||||
|
||||
updateUI();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
{% set total_count = total_count or 0 %}
|
||||
{% set purchased_count = purchased_count or 0 %}
|
||||
{% set not_purchased_count = not_purchased_count or 0 %}
|
||||
{% set accounted_count = purchased_count + not_purchased_count %}
|
||||
{% set remaining_count = (total_count - accounted_count) if total_count > accounted_count else 0 %}
|
||||
|
||||
{% set percent = ((purchased_count / total_count) * 100) if total_count > 0 else 0 %}
|
||||
{% set purchased_percent = ((purchased_count / total_count) * 100) if total_count > 0 else 0 %}
|
||||
{% set not_purchased_percent = ((not_purchased_count / total_count) * 100) if total_count > 0 else 0 %}
|
||||
{% set remaining_percent = ((remaining_count / total_count) * 100) if total_count > 0 else 0 %}
|
||||
|
||||
<div class="main-list-progress-wrap mt-2">
|
||||
<div class="main-list-progress progress progress-dark progress-thin position-relative"
|
||||
aria-label="Postęp listy {{ purchased_count }} z {{ total_count }} kupionych">
|
||||
<div class="progress-bar bg-success" role="progressbar"
|
||||
style="width: {{ '%.6f'|format(purchased_percent) }}%"
|
||||
aria-valuemin="0" aria-valuemax="100"
|
||||
aria-valuenow="{{ percent|round(0)|int }}"></div>
|
||||
|
||||
<div class="progress-bar bg-warning" role="progressbar"
|
||||
style="width: {{ '%.6f'|format(not_purchased_percent) }}%"
|
||||
aria-valuemin="0" aria-valuemax="100"></div>
|
||||
|
||||
<div class="progress-bar bg-transparent" role="progressbar"
|
||||
style="width: {{ '%.6f'|format(remaining_percent) }}%"
|
||||
aria-valuemin="0" aria-valuemax="100"></div>
|
||||
|
||||
<span class="progress-label main-list-progress__label small fw-bold {% if percent < 51 %}text-white{% else %}text-dark{% endif %}">
|
||||
Produkty: {{ purchased_count }}/{{ total_count }} ({{ percent|round(0)|int }}%)
|
||||
{% if total_expense > 0 %} — 💸 {{ '%.2f'|format(total_expense) }} PLN{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -328,7 +328,7 @@
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Zamknij"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ul id="product-list" class="list-group list-group-flush"></ul>
|
||||
<div id="product-list" class="preview-product-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -341,7 +341,7 @@
|
||||
checkboxes.forEach(cb => cb.checked = this.checked);
|
||||
});
|
||||
</script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='preview_list_modal.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'preview_list_modal.js') }}?v=3"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% endblock %}
|
||||
@@ -137,7 +137,7 @@
|
||||
aria-label="Zamknij"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<ul id="product-list" class="list-group list-group-flush"></ul>
|
||||
<div id="product-list" class="preview-product-list"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -146,6 +146,6 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='preview_list_modal.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='categories_select_admin.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'preview_list_modal.js') }}?v=3"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'categories_select_admin.js') }}"></script>
|
||||
{% endblock %}
|
||||
@@ -18,7 +18,7 @@
|
||||
<!-- Nazwa listy -->
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label">📝 Nazwa listy</label>
|
||||
<input type="text" class="form-control bg-dark text-white border-secondary rounded" id="title" name="title"
|
||||
<input type="text" class="form-control bg-dark text-white border-secondary ui-consistent-input" id="title" name="title"
|
||||
value="{{ list.title }}" required>
|
||||
</div>
|
||||
|
||||
@@ -26,13 +26,13 @@
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-6">
|
||||
<label for="amount" class="form-label">💰 Całkowity wydatek (PLN)</label>
|
||||
<input type="number" step="0.01" min="0" class="form-control bg-dark text-white border-secondary rounded"
|
||||
<input type="number" step="0.01" min="0" class="form-control bg-dark text-white border-secondary ui-consistent-input"
|
||||
id="amount" name="amount" value="{{ '%.2f'|format(total_expense) }}">
|
||||
</div>
|
||||
|
||||
<div class="col-md-6">
|
||||
<label for="owner_id" class="form-label">👤 Właściciel</label>
|
||||
<select class="form-select bg-dark text-white border-secondary" id="owner_id" name="owner_id">
|
||||
<select class="form-select bg-dark text-white border-secondary ui-consistent-input" id="owner_id" name="owner_id">
|
||||
{% for user in users %}
|
||||
<option value="{{ user.id }}" {% if list.owner_id==user.id %}selected{% endif %}>
|
||||
{{ user.username }}
|
||||
@@ -71,12 +71,12 @@
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-6">
|
||||
<label for="expires_date" class="form-label">📅 Data wygaśnięcia</label>
|
||||
<input type="date" class="form-control bg-dark text-white border-secondary rounded" id="expires_date"
|
||||
<input type="date" class="form-control bg-dark text-white border-secondary ui-consistent-input" id="expires_date"
|
||||
name="expires_date" value="{{ list.expires_at.strftime('%Y-%m-%d') if list.expires_at else '' }}">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="expires_time" class="form-label">⏰ Godzina wygaśnięcia</label>
|
||||
<input type="time" class="form-control bg-dark text-white border-secondary rounded" id="expires_time"
|
||||
<input type="time" class="form-control bg-dark text-white border-secondary ui-consistent-input" id="expires_time"
|
||||
name="expires_time" value="{{ list.expires_at.strftime('%H:%M') if list.expires_at else '' }}">
|
||||
</div>
|
||||
</div>
|
||||
@@ -94,7 +94,7 @@
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">📁 Przenieś do miesiąca (format: rok-miesiąc np 2026-01)</label>
|
||||
<input type="month" id="created_month" name="created_month"
|
||||
class="form-control bg-dark text-white border-secondary rounded">
|
||||
class="form-control bg-dark text-white border-secondary ui-consistent-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -102,7 +102,7 @@
|
||||
<div class="mb-4">
|
||||
<label for="categories" class="form-label">🏷️ Kategorie</label>
|
||||
<select id="categories" name="categories"
|
||||
class="form-select tom-dark bg-dark text-white border-secondary rounded">
|
||||
class="form-select tom-dark bg-dark text-white border-secondary ui-consistent-input">
|
||||
<option value="">– brak –</option>
|
||||
{% for cat in categories %}
|
||||
<option value="{{ cat.id }}" {% if cat.id in selected_categories %}selected{% endif %}>
|
||||
@@ -115,7 +115,7 @@
|
||||
<!-- Link udostępnienia -->
|
||||
<div class="mb-4">
|
||||
<label class="form-label">🔗 Link do udostępnienia</label>
|
||||
<input type="text" class="form-control bg-dark text-white border-secondary rounded" readonly
|
||||
<input type="text" class="form-control bg-dark text-white border-secondary ui-consistent-input" readonly
|
||||
value="{{ request.url_root }}share/{{ list.share_token }}">
|
||||
</div>
|
||||
|
||||
@@ -157,11 +157,11 @@
|
||||
<form method="post" class="row g-2 mb-3">
|
||||
<input type="hidden" name="action" value="add_item">
|
||||
<div class="col-md-8">
|
||||
<input type="text" class="form-control bg-dark text-white border-secondary rounded" name="item_name"
|
||||
<input type="text" class="form-control bg-dark text-white border-secondary ui-consistent-input" name="item_name"
|
||||
placeholder="Nazwa produktu" required>
|
||||
</div>
|
||||
<div class="col-md-1">
|
||||
<input type="number" class="form-control bg-dark text-white border-secondary rounded" name="quantity" min="1"
|
||||
<input type="number" class="form-control bg-dark text-white border-secondary ui-consistent-input" name="quantity" min="1"
|
||||
value="1">
|
||||
</div>
|
||||
<div class="col-md-3 d-grid">
|
||||
@@ -303,5 +303,5 @@
|
||||
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='select.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'select.js') }}"></script>
|
||||
{% endblock %}
|
||||
@@ -170,8 +170,8 @@
|
||||
</div>
|
||||
|
||||
{% block scripts %}
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='product_suggestion.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='table_search.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'product_suggestion.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'table_search.js') }}"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% endblock %}
|
||||
@@ -181,7 +181,7 @@
|
||||
|
||||
{% endblock %}
|
||||
{% block scripts %}
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='access_users.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='lists_access.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'access_users.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'lists_access.js') }}"></script>
|
||||
|
||||
{% endblock %}
|
||||
@@ -224,8 +224,8 @@
|
||||
endpoint: "/admin/crop_receipt"
|
||||
};
|
||||
</script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='receipt_crop.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='receipt_crop_logic.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'receipt_crop.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'receipt_crop_logic.js') }}"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% endblock %}
|
||||
@@ -153,6 +153,6 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<link rel="stylesheet" href="{{ url_for('static_bp.serve_css', filename='admin_settings.css') }}?v={{ APP_VERSION }}">
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='admin_settings.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<link rel="stylesheet" href="{{ static_asset_url('static_bp.serve_css', 'admin_settings.css') }}">
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'admin_settings.js') }}"></script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -18,13 +18,13 @@
|
||||
<div class="col-md-4">
|
||||
<label for="username" class="form-label text-white-50">Nazwa użytkownika</label>
|
||||
<input type="text" id="username" name="username"
|
||||
class="form-control bg-dark text-white border-secondary rounded" placeholder="np. jan" required>
|
||||
class="form-control bg-dark text-white border-secondary ui-consistent-input" placeholder="np. jan" required>
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<label for="password" class="form-label text-white-50">Hasło</label>
|
||||
<div class="input-group ui-password-group">
|
||||
<input type="password" id="password" name="password"
|
||||
class="form-control bg-dark text-white border-secondary rounded" placeholder="min. 6 znaków" required>
|
||||
class="form-control bg-dark text-white border-secondary ui-consistent-input" placeholder="min. 6 znaków" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-4 d-grid">
|
||||
@@ -109,7 +109,7 @@
|
||||
<p id="resetUsernameLabel">Dla użytkownika: <strong></strong></p>
|
||||
<div class="input-group ui-password-group">
|
||||
<input type="password" name="password" placeholder="Nowe hasło"
|
||||
class="form-control bg-dark text-white border-secondary rounded" required>
|
||||
class="form-control bg-dark text-white border-secondary ui-consistent-input" required>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer border-0">
|
||||
@@ -121,7 +121,7 @@
|
||||
</div>
|
||||
|
||||
{% block scripts %}
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='user_management.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'user_management.js') }}"></script>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
|
||||
@@ -2,29 +2,34 @@
|
||||
<html lang="pl">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
|
||||
<meta name="theme-color" content="#07111f">
|
||||
<meta name="apple-mobile-web-app-capable" content="yes">
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
|
||||
<title>{% block title %}Live Lista Zakupów{% endblock %}</title>
|
||||
<link rel="icon" type="image/svg+xml" href="{{ url_for('favicon') }}">
|
||||
|
||||
<link href="{{ url_for('static_bp.serve_css_lib', filename='bootstrap.min.css') }}?v={{ APP_VERSION }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static_bp.serve_css', filename='style.css') }}?v={{ APP_VERSION }}" rel="stylesheet">
|
||||
<link href="{{ static_asset_url('static_bp.serve_css_lib', 'bootstrap.min.css') }}" rel="stylesheet">
|
||||
<link href="{{ static_asset_url('static_bp.serve_css', 'style.css') }}" rel="stylesheet">
|
||||
|
||||
{% set hide_login_ui = request.path == '/system-auth' %}
|
||||
|
||||
{% set exclude_paths = ['/system-auth'] %}
|
||||
{% if (exclude_paths | select("in", request.path) | list | length == 0)
|
||||
and has_authorized_cookie
|
||||
and not is_blocked %}
|
||||
<link href="{{ url_for('static_bp.serve_css_lib', filename='glightbox.min.css') }}?v={{ APP_VERSION }}" rel="stylesheet">
|
||||
<link href="{{ url_for('static_bp.serve_css_lib', filename='sort_table.min.css') }}?v={{ APP_VERSION }}" rel="stylesheet">
|
||||
<link href="{{ static_asset_url('static_bp.serve_css_lib', 'glightbox.min.css') }}" rel="stylesheet">
|
||||
<link href="{{ static_asset_url('static_bp.serve_css_lib', 'sort_table.min.css') }}" rel="stylesheet">
|
||||
{% endif %}
|
||||
|
||||
{% set substrings_cropper = ['/admin/receipts', '/edit_my_list'] %}
|
||||
{% if substrings_cropper | select("in", request.path) | list | length > 0 %}
|
||||
<link href="{{ url_for('static_bp.serve_css_lib', filename='cropper.min.css') }}?v={{ APP_VERSION }}" rel="stylesheet">
|
||||
<link href="{{ static_asset_url('static_bp.serve_css_lib', 'cropper.min.css') }}" rel="stylesheet">
|
||||
{% endif %}
|
||||
|
||||
{% set substrings_tomselect = ['/edit_my_list', '/admin/edit_list', '/admin/edit_categories'] %}
|
||||
{% if substrings_tomselect | select("in", request.path) | list | length > 0 %}
|
||||
<link href="{{ url_for('static_bp.serve_css_lib', filename='tom-select.bootstrap5.min.css') }}?v={{ APP_VERSION }}" rel="stylesheet">
|
||||
<link href="{{ static_asset_url('static_bp.serve_css_lib', 'tom-select.bootstrap5.min.css') }}" rel="stylesheet">
|
||||
{% endif %}
|
||||
</head>
|
||||
|
||||
@@ -58,12 +63,28 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="dropdown d-lg-none app-mobile-menu ms-auto">
|
||||
<div class="d-lg-none app-navbar__meta app-navbar__meta--mobile ms-auto">
|
||||
{% if has_authorized_cookie and not is_blocked %}
|
||||
{% if current_user.is_authenticated %}
|
||||
<div class="app-user-chip app-user-chip--mobile">
|
||||
<span class="app-user-chip__label">Zalogowany</span>
|
||||
<span class="badge rounded-pill text-bg-success">{{ current_user.username }}</span>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="app-user-chip app-user-chip--guest app-user-chip--mobile">
|
||||
<span class="app-user-chip__label">Tryb</span>
|
||||
<span class="badge rounded-pill text-bg-info">gość</span>
|
||||
</div>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="dropdown d-lg-none app-mobile-menu">
|
||||
<button class="btn app-navbar-toggler app-mobile-menu__toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false" aria-label="Otwórz menu">
|
||||
<span class="navbar-toggler-icon"></span>
|
||||
</button>
|
||||
<div class="dropdown-menu dropdown-menu-end app-mobile-menu__panel">
|
||||
{% if not is_blocked and request.endpoint and request.endpoint != 'system_auth' %}
|
||||
{% if not is_blocked and not hide_login_ui %}
|
||||
{% if current_user.is_authenticated %}
|
||||
{% if current_user.is_admin %}
|
||||
<a href="{{ url_for('admin_panel') }}" class="dropdown-item app-mobile-menu__item">⚙️ <span>Panel</span></a>
|
||||
@@ -80,7 +101,7 @@
|
||||
|
||||
<div class="d-none d-lg-flex justify-content-end order-lg-3" id="appNavbarMenu">
|
||||
<div class="app-navbar__actions">
|
||||
{% if not is_blocked and request.endpoint and request.endpoint != 'system_auth' %}
|
||||
{% if not is_blocked and not hide_login_ui %}
|
||||
{% if current_user.is_authenticated %}
|
||||
{% if current_user.is_admin %}
|
||||
<a href="{{ url_for('admin_panel') }}" class="btn btn-outline-light btn-sm app-nav-action">⚙️ <span>Panel</span></a>
|
||||
@@ -116,14 +137,13 @@
|
||||
<p class="mb-1">
|
||||
<a href="https://git.linuxiarz.pl/gru/lista_zakupowa_live" target="_blank" class="link-success text-decoration-none">
|
||||
source code
|
||||
</a>
|
||||
</a> · v{{ APP_VERSION }}
|
||||
</p>
|
||||
<div class="small">v{{ APP_VERSION }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
<script src="{{ url_for('static_bp.serve_js_lib', filename='bootstrap.bundle.min.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js_lib', 'bootstrap.bundle.min.js') }}"></script>
|
||||
|
||||
{% if not is_blocked %}
|
||||
<script>
|
||||
@@ -147,16 +167,16 @@
|
||||
</script>
|
||||
|
||||
{% if request.endpoint != 'system_auth' %}
|
||||
<script src="{{ url_for('static_bp.serve_js_lib', filename='glightbox.min.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js_lib', filename='socket.io.min.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js_lib', filename='sort_table.min.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='functions.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='live.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='sockets.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js_lib', 'glightbox.min.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js_lib', 'socket.io.min.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js_lib', 'sort_table.min.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'functions.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'live.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'sockets.js') }}"></script>
|
||||
{% endif %}
|
||||
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='toasts.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='app_ui.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'toasts.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'app_ui.js') }}"></script>
|
||||
<script>
|
||||
if (typeof GLightbox === 'function') {
|
||||
let lightbox = GLightbox({ selector: '.glightbox' });
|
||||
@@ -165,15 +185,15 @@
|
||||
|
||||
{% set substrings = ['/admin/receipts', '/edit_my_list'] %}
|
||||
{% if substrings | select("in", request.path) | list | length > 0 %}
|
||||
<script src="{{ url_for('static_bp.serve_js_lib', filename='cropper.min.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js_lib', 'cropper.min.js') }}"></script>
|
||||
{% endif %}
|
||||
|
||||
{% set substrings = ['/edit_my_list', '/admin/edit_list', '/admin/edit_categories'] %}
|
||||
{% if substrings | select("in", request.path) | list | length > 0 %}
|
||||
<script src="{{ url_for('static_bp.serve_js_lib', filename='tom-select.complete.min.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js_lib', 'tom-select.complete.min.js') }}"></script>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
|
||||
{% block scripts %}{% endblock %}
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
@@ -16,7 +16,7 @@
|
||||
<!-- Nazwa listy -->
|
||||
<div class="mb-3">
|
||||
<label for="title" class="form-label">📝 Nazwa listy</label>
|
||||
<input type="text" class="form-control bg-dark text-white border-secondary rounded" id="title" name="title"
|
||||
<input type="text" class="form-control bg-dark text-white border-secondary ui-consistent-input" id="title" name="title"
|
||||
value="{{ list.title }}" required>
|
||||
</div>
|
||||
|
||||
@@ -48,12 +48,12 @@
|
||||
<div class="row mb-4">
|
||||
<div class="col-md-6">
|
||||
<label for="expires_date" class="form-label">📅 Data wygaśnięcia</label>
|
||||
<input type="date" class="form-control bg-dark text-white border-secondary rounded" id="expires_date"
|
||||
<input type="date" class="form-control bg-dark text-white border-secondary ui-consistent-input" id="expires_date"
|
||||
name="expires_date" value="{{ list.expires_at.strftime('%Y-%m-%d') if list.expires_at else '' }}">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label for="expires_time" class="form-label">⏰ Godzina wygaśnięcia</label>
|
||||
<input type="time" class="form-control bg-dark text-white border-secondary rounded" id="expires_time"
|
||||
<input type="time" class="form-control bg-dark text-white border-secondary ui-consistent-input" id="expires_time"
|
||||
name="expires_time" value="{{ list.expires_at.strftime('%H:%M') if list.expires_at else '' }}">
|
||||
</div>
|
||||
</div>
|
||||
@@ -71,7 +71,7 @@
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">📁 Przenieś do miesiąca (format: rok-miesiąc np 2026-01)</label>
|
||||
<input type="month" id="move_to_month" name="move_to_month"
|
||||
class="form-control bg-dark text-white border-secondary rounded">
|
||||
class="form-control bg-dark text-white border-secondary ui-consistent-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -79,7 +79,7 @@
|
||||
<div class="mb-4">
|
||||
<label for="categories" class="form-label">🏷️ Kategorie</label>
|
||||
<select id="categories" name="categories"
|
||||
class="form-select tom-dark bg-dark text-white border-secondary rounded">
|
||||
class="form-select tom-dark bg-dark text-white border-secondary ui-consistent-input">
|
||||
<option value="">– brak –</option>
|
||||
{% for cat in categories %}
|
||||
<option value="{{ cat.id }}" {% if cat.id in selected_categories %}selected{% endif %}>
|
||||
@@ -209,7 +209,7 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<p>Aby usunąć listę <strong>{{ list.title }}</strong>, wpisz <code>usuń</code> i poczekaj 2 sekundy:</p>
|
||||
<input type="text" id="confirm-delete-input" class="form-control bg-dark text-white border-warning rounded"
|
||||
<input type="text" id="confirm-delete-input" class="form-control bg-dark text-white border-warning ui-consistent-input"
|
||||
placeholder="">
|
||||
</div>
|
||||
<div class="modal-footer justify-content-between">
|
||||
@@ -260,9 +260,9 @@
|
||||
endpoint: "/user_crop_receipt"
|
||||
};
|
||||
</script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='confirm_delete.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='receipt_crop.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='receipt_crop_logic.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='select.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='access_users.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'confirm_delete.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'receipt_crop.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'receipt_crop_logic.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'select.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'access_users.js') }}"></script>
|
||||
{% endblock %}
|
||||
@@ -61,18 +61,18 @@
|
||||
<div class="tab-pane fade show active" id="listsTab" role="tabpanel">
|
||||
<div class="card bg-dark text-white mb-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex flex-wrap gap-2 mb-3 justify-content-center">
|
||||
<div class="btn-group btn-group-sm" role="group">
|
||||
<button class="btn btn-outline-light range-btn" data-range="day">🗓️ Dzień</button>
|
||||
<button class="btn btn-outline-light range-btn" data-range="week">📆 Tydzień</button>
|
||||
<button class="btn btn-outline-light range-btn active" data-range="month">📅 Miesiąc</button>
|
||||
<button class="btn btn-outline-light range-btn" data-range="year">📈 Rok</button>
|
||||
<button class="btn btn-outline-light range-btn" data-range="all">🌐 Wszystko</button>
|
||||
<div class="d-flex flex-wrap gap-2 mb-3 justify-content-center expenses-range-toolbar expenses-table-toolbar">
|
||||
<div class="btn-group btn-group-sm expenses-range-group" role="group">
|
||||
<button class="btn btn-outline-light range-btn table-range-btn" data-range="day">🗓️ Dzień</button>
|
||||
<button class="btn btn-outline-light range-btn table-range-btn" data-range="week">📆 Tydzień</button>
|
||||
<button class="btn btn-outline-light range-btn table-range-btn active" data-range="month">📅 Miesiąc</button>
|
||||
<button class="btn btn-outline-light range-btn table-range-btn" data-range="year">📈 Rok</button>
|
||||
<button class="btn btn-outline-light range-btn table-range-btn" data-range="all">🌐 Wszystko</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-center mb-3">
|
||||
<div class="input-group input-group-sm w-100" style="max-width: 570px;">
|
||||
<div class="input-group input-group-sm w-100 expenses-date-range" style="max-width: 570px;">
|
||||
<span class="input-group-text bg-secondary text-white border-secondary">Od</span>
|
||||
<input type="date" class="form-control bg-dark text-white border-secondary flex-grow-1"
|
||||
id="customStart">
|
||||
@@ -169,20 +169,20 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex flex-wrap gap-2 mb-3 justify-content-center">
|
||||
<div class="btn-group btn-group-sm" role="group">
|
||||
<button class="btn btn-outline-light range-btn" data-range="last30days">🗓️ Ostatnie 30
|
||||
<div class="d-flex flex-wrap gap-2 mb-3 justify-content-center expenses-range-toolbar expenses-chart-toolbar">
|
||||
<div class="btn-group btn-group-sm expenses-range-group" role="group">
|
||||
<button class="btn btn-outline-light range-btn chart-range-btn" data-range="last30days">🗓️ Ostatnie 30
|
||||
dni</button>
|
||||
<button class="btn btn-outline-light range-btn" data-range="currentmonth">📅 Bieżący miesiąc</button>
|
||||
<button class="btn btn-outline-light range-btn" data-range="monthly">📆 Miesięczne</button>
|
||||
<button class="btn btn-outline-light range-btn" data-range="quarterly">📊 Kwartalne</button>
|
||||
<button class="btn btn-outline-light range-btn" data-range="halfyearly">🗓️ Półroczne</button>
|
||||
<button class="btn btn-outline-light range-btn" data-range="yearly">📈 Roczne</button>
|
||||
<button class="btn btn-outline-light range-btn chart-range-btn" data-range="currentmonth">📅 Bieżący miesiąc</button>
|
||||
<button class="btn btn-outline-light range-btn chart-range-btn" data-range="monthly">📆 Miesięczne</button>
|
||||
<button class="btn btn-outline-light range-btn chart-range-btn" data-range="quarterly">📊 Kwartalne</button>
|
||||
<button class="btn btn-outline-light range-btn chart-range-btn" data-range="halfyearly">🗓️ Półroczne</button>
|
||||
<button class="btn btn-outline-light range-btn chart-range-btn" data-range="yearly">📈 Roczne</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="d-flex justify-content-center mb-4">
|
||||
<div class="input-group input-group-sm w-100" style="max-width: 570px;">
|
||||
<div class="input-group input-group-sm w-100 expenses-date-range" style="max-width: 570px;">
|
||||
<span class="input-group-text bg-secondary text-white border-secondary">Od</span>
|
||||
<input type="date" class="form-control bg-dark text-white border-secondary flex-grow-1" id="startDate">
|
||||
<span class="input-group-text bg-secondary text-white border-secondary">Do</span>
|
||||
@@ -213,13 +213,13 @@
|
||||
{% endblock %}
|
||||
|
||||
{% block scripts %}
|
||||
<script src="{{ url_for('static_bp.serve_js_lib', filename='chart.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='show_all_expense.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='expense_chart.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='expense_table.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='expense_tab.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='select_all_table.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='chart_controls.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='modal_chart.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='download_chart.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js_lib', 'chart.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'show_all_expense.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'expense_chart.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'expense_table.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'expense_tab.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'select_all_table.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'chart_controls.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'modal_chart.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'download_chart.js') }}"></script>
|
||||
{% endblock %}
|
||||
@@ -70,7 +70,7 @@
|
||||
<h5 id="progress-title" class="mb-2">
|
||||
Postęp listy —
|
||||
<span id="purchased-count">{{ purchased_count }}</span>/<span id="total-count">{{ total_count }}</span> kupionych
|
||||
(<span id="percent-value">{{ percent|int }}</span>%)
|
||||
(<span id="percent-value">{{ percent|round(0)|int }}</span>%)
|
||||
</h5>
|
||||
|
||||
<div class="progress progress-dark position-relative">
|
||||
@@ -121,7 +121,7 @@
|
||||
{% set info_parts = [] %}
|
||||
{% if item.note %}{% set _ = info_parts.append('<span class="text-danger">[ <b>' ~ item.note ~ '</b> ]</span>') %}{% endif %}
|
||||
{% if item.not_purchased_reason %}{% set _ = info_parts.append('<span class="text-dark">[ <b>Powód: ' ~ item.not_purchased_reason ~ '</b> ]</span>') %}{% endif %}
|
||||
{% if item.added_by_display %}{% set _ = info_parts.append('<span class="text-info">[ Dodał/a: <b>' ~ item.added_by_display ~ '</b> ]</span>') %}{% endif %}
|
||||
{% if item.added_by_display %}{% set _ = info_parts.append('<span class="item-added-by-meta">· dodał/a: <b>' ~ item.added_by_display ~ '</b></span>') %}{% endif %}
|
||||
{% if info_parts %}
|
||||
<span class="info-line small" id="info-{{ item.id }}">{{ info_parts | join(' ') | safe }}</span>
|
||||
{% endif %}
|
||||
@@ -136,11 +136,14 @@
|
||||
|
||||
{% if item.not_purchased %}
|
||||
<button type="button" class="btn btn-outline-light btn-sm shopping-action-btn shopping-action-btn--wide" {% if list.is_archived %}disabled{% else
|
||||
%}onclick="unmarkNotPurchased({{ item.id }})" {% endif %}>✅ Przywróć</button>
|
||||
%}onclick="unmarkNotPurchased({{ item.id }})" {% endif %}>Przywróć</button>
|
||||
{% elif not item.not_purchased %}
|
||||
<button type="button" class="btn btn-outline-light btn-sm shopping-action-btn" {% if list.is_archived %}disabled{% else
|
||||
%}onclick="markNotPurchasedModal(event, {{ item.id }})" {% endif %}>⚠️</button>
|
||||
{% endif %}
|
||||
|
||||
<button type="button" class="btn btn-outline-light btn-sm shopping-action-btn" {% if list.is_archived %}disabled{% else
|
||||
%}onclick="openNoteModal(event, {{ item.id }})" {% endif %}>📝</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -185,32 +188,57 @@
|
||||
</div>
|
||||
|
||||
{% if not list.is_archived %}
|
||||
<div class="list-action-block mb-3">
|
||||
<div class="list-action-row mb-2">
|
||||
<button class="btn btn-outline-light btn-sm list-action-row__btn" data-bs-toggle="modal" data-bs-target="#massAddModal">
|
||||
Dodaj produkty masowo
|
||||
|
||||
<div class="shopping-entry-card mb-3" aria-label="Sekcja dodawania produktu">
|
||||
<div class="shopping-entry-card__label">➕ Dodaj produkt</div>
|
||||
<div class="shopping-entry-card__hint">Wpisz nazwę produktu i ilość, potem kliknij Dodaj.</div>
|
||||
<div class="input-group mb-0 shopping-compact-input-group shopping-product-input-group">
|
||||
<input type="text" id="newItem" name="name"
|
||||
class="form-control bg-dark text-white border-secondary shopping-product-name-input"
|
||||
placeholder="Dodaj produkt" required>
|
||||
|
||||
<input type="number" id="newQuantity" name="quantity"
|
||||
class="form-control bg-dark text-white border-secondary shopping-qty-input"
|
||||
placeholder="Ilość" min="1" value="1">
|
||||
|
||||
<button type="button"
|
||||
class="btn btn-outline-success share-submit-btn shopping-compact-submit"
|
||||
onclick="addItem({{ list.id }})">
|
||||
<span class="shopping-btn-icon" aria-hidden="true">➕</span>
|
||||
<span class="shopping-btn-label">Dodaj</span>
|
||||
</button>
|
||||
<form method="post" action="{{ url_for('create_template_from_user_list', list_id=list.id) }}" class="list-action-row__form">
|
||||
<input type="hidden" name="template_name" value="{{ list.title }} - szablon">
|
||||
<button type="submit" class="btn btn-outline-primary btn-sm list-action-row__btn">🧩 Zapisz jako szablon</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="list-quick-actions mb-3" aria-label="Szybkie akcje listy">
|
||||
<div class="list-quick-actions__header">
|
||||
<div>
|
||||
<div class="list-quick-actions__eyebrow">Szybkie akcje</div>
|
||||
<div class="list-quick-actions__title">Dodawanie i zapis listy</div>
|
||||
</div>
|
||||
<div class="list-quick-actions__hint">Najczęściej używane akcje pod ręką.</div>
|
||||
</div>
|
||||
|
||||
<div class="input-group mb-2 shopping-compact-input-group shopping-product-input-group">
|
||||
<input type="text" id="newItem" name="name"
|
||||
class="form-control bg-dark text-white border-secondary shopping-product-name-input"
|
||||
placeholder="Dodaj produkt" required>
|
||||
<div class="list-quick-actions__grid">
|
||||
<button class="btn btn-outline-light list-quick-actions__action list-quick-actions__action--primary" data-bs-toggle="modal" data-bs-target="#massAddModal" type="button">
|
||||
<span class="list-quick-actions__icon" aria-hidden="true">➕</span>
|
||||
<span class="list-quick-actions__content">
|
||||
<span class="list-quick-actions__label">Dodaj produkty masowo</span>
|
||||
<span class="list-quick-actions__desc">Wklej kilka pozycji naraz i uzupełnij listę szybciej.</span>
|
||||
</span>
|
||||
</button>
|
||||
|
||||
<input type="number" id="newQuantity" name="quantity"
|
||||
class="form-control bg-dark text-white border-secondary shopping-qty-input"
|
||||
placeholder="Ilość" min="1" value="1">
|
||||
|
||||
<button type="button"
|
||||
class="btn btn-outline-success share-submit-btn shopping-compact-submit"
|
||||
onclick="addItem({{ list.id }})">
|
||||
<span class="shopping-btn-icon" aria-hidden="true">➕</span>
|
||||
<span class="shopping-btn-label">Dodaj</span>
|
||||
</button>
|
||||
<form method="post" action="{{ url_for('create_template_from_user_list', list_id=list.id) }}" class="list-quick-actions__form">
|
||||
<input type="hidden" name="template_name" value="{{ list.title }} - szablon">
|
||||
<button type="submit" class="btn btn-outline-primary list-quick-actions__action list-quick-actions__action--secondary">
|
||||
<span class="list-quick-actions__icon" aria-hidden="true">🧩</span>
|
||||
<span class="list-quick-actions__content">
|
||||
<span class="list-quick-actions__label">Zapisz jako szablon</span>
|
||||
<span class="list-quick-actions__desc">Zachowaj układ tej listy i użyj go ponownie.</span>
|
||||
</span>
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
@@ -221,7 +249,7 @@
|
||||
<h5 class="mb-0">🕘 Historia zmian listy</h5>
|
||||
<button class="btn btn-sm btn-outline-light" type="button" data-bs-toggle="collapse" data-bs-target="#activityHistory" aria-expanded="false" aria-controls="activityHistory">Pokaż / ukryj</button>
|
||||
</div>
|
||||
<div class="small text-secondary mb-3">Domyślnie ukryte. Zdarzeń: {{ activity_logs|length }}</div>
|
||||
<div class="small text-secondary mb-3">Rozwiń aby zobaczyć | Zdarzeń: {{ activity_logs|length }}</div>
|
||||
<div class="collapse" id="activityHistory">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-dark table-sm align-middle">
|
||||
@@ -244,23 +272,56 @@
|
||||
{% endif %}
|
||||
|
||||
{% set receipt_pattern = 'list_' ~ list.id %}
|
||||
<hr>
|
||||
<h5 class="mt-4">📸 Paragony dodane do tej listy</h5>
|
||||
|
||||
<div class="row g-3 mt-2" id="receiptGallery">
|
||||
{% if receipts %}
|
||||
{% for r in receipts %}
|
||||
<div class="col-6 col-md-4 col-lg-3 text-center">
|
||||
<a href="{{ url_for('uploaded_file', filename=r.filename) }}?v={{ r.version_token or '0' }}" class="glightbox"
|
||||
data-gallery="receipt-gallery">
|
||||
<img src="{{ url_for('uploaded_file', filename=r.filename) }}?v={{ r.version_token or '0' }}"
|
||||
class="img-fluid rounded shadow-sm border border-secondary" style="max-height: 200px; object-fit: cover;">
|
||||
</a>
|
||||
<div class="card bg-dark text-white border-secondary shadow-sm mt-4">
|
||||
<div class="card-body">
|
||||
<div class="d-flex flex-column flex-lg-row align-items-lg-center justify-content-between gap-2 mb-3">
|
||||
<div>
|
||||
<h5 class="mb-1">📄 Paragony dodane do tej listy</h5>
|
||||
<p class="text-secondary small mb-0">
|
||||
Tutaj możesz wygodnie przejrzeć wszystkie paragony przypisane do tej listy.
|
||||
</p>
|
||||
</div>
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
<span class="badge rounded-pill bg-secondary">{{ receipts|length }} plik{% if receipts|length != 1 %}i{% endif %}</span>
|
||||
<span class="badge rounded-pill bg-info text-dark">Tylko podgląd</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="border border-secondary rounded-3 p-3">
|
||||
<div class="d-flex justify-content-between align-items-center flex-wrap gap-2 mb-3">
|
||||
<h6 class="mb-0">📸 Galeria paragonów</h6>
|
||||
{% if receipts %}
|
||||
<span class="text-secondary small">Kliknij miniaturę, aby otworzyć podgląd</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<div class="row g-3" id="receiptGallery">
|
||||
{% if receipts %}
|
||||
{% for r in receipts %}
|
||||
<div class="col-6 col-md-4 col-xl-3">
|
||||
<a href="{{ url_for('uploaded_file', filename=r.filename) }}?v={{ r.version_token or '0' }}" class="glightbox text-decoration-none"
|
||||
data-gallery="receipt-gallery">
|
||||
<div class="card bg-black border-secondary h-100 overflow-hidden shadow-sm">
|
||||
<img src="{{ url_for('uploaded_file', filename=r.filename) }}?v={{ r.version_token or '0' }}"
|
||||
class="card-img-top img-fluid" style="height: 180px; object-fit: cover;" alt="Paragon {{ loop.index }}">
|
||||
<div class="card-body p-2">
|
||||
<div class="small text-truncate text-secondary">Paragon {{ loop.index }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="col-12">
|
||||
<div class="alert alert-info text-center mb-0" role="alert">
|
||||
ℹ️ Brak wgranych paragonów do tej listy
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="alert alert-info text-center w-100" role="alert">ℹ️ Brak wgranych paragonów do tej listy</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- MODAL: KATEGORIA (pojedynczy wybór) -->
|
||||
@@ -393,8 +454,31 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="noteModal" tabindex="-1" aria-hidden="true">
|
||||
<div class="modal-dialog modal-lg modal-dialog-scrollable">
|
||||
<div class="modal-content bg-dark text-white">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title">Dodaj notatkę</h5>
|
||||
<button type="button" class="btn-close btn-close-white" data-bs-dismiss="modal" aria-label="Zamknij"></button>
|
||||
</div>
|
||||
<form id="noteForm" onsubmit="submitNote(event)">
|
||||
<div class="modal-body">
|
||||
<textarea id="noteText" class="form-control" rows="4" placeholder="Np. 'Jak nie kupisz to po Tobie!'"></textarea>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-outline-light btn-sm" data-bs-dismiss="modal">❌ Anuluj</button>
|
||||
<button type="submit" class="btn btn-outline-light btn-sm"><span class="shopping-btn-icon" aria-hidden="true">💾</span>
|
||||
<span class="shopping-btn-label">Zapisz</span></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% block scripts %}
|
||||
<script src="{{ url_for('static_bp.serve_js_lib', filename='Sortable.min.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js_lib', 'Sortable.min.js') }}"></script>
|
||||
<script>
|
||||
const isShare = document.getElementById('items').dataset.isShare === 'true';
|
||||
window.IS_SHARE = isShare;
|
||||
@@ -402,11 +486,12 @@
|
||||
window.IS_ARCHIVED = {{ 'true' if list.is_archived else 'false' }};
|
||||
window.IS_OWNER = {{ 'true' if is_owner else 'false' }};
|
||||
</script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='mass_add.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='receipt_upload.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='sort_mode.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='access_users.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='category_modal.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'mass_add.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'receipt_upload.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'sort_mode.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'access_users.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'category_modal.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'notes.js') }}"></script>
|
||||
<script>
|
||||
setupList({{ list.id }}, '{{ current_user.username if current_user.is_authenticated else 'Gość' }}');
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@
|
||||
{% set info_parts = [] %}
|
||||
{% if item.note %}{% set _ = info_parts.append('<span class="text-danger">[ <b>' ~ item.note ~ '</b> ]</span>') %}{% endif %}
|
||||
{% if item.not_purchased_reason %}{% set _ = info_parts.append('<span class="text-dark">[ <b>Powód: ' ~ item.not_purchased_reason ~ '</b> ]</span>') %}{% endif %}
|
||||
{% if item.added_by_display %}{% set _ = info_parts.append('<span class="text-info">[ Dodał/a: <b>' ~ item.added_by_display ~ '</b> ]</span>') %}{% endif %}
|
||||
{% if item.added_by_display %}{% set _ = info_parts.append('<span class="item-added-by-meta">· dodał/a: <b>' ~ item.added_by_display ~ '</b></span>') %}{% endif %}
|
||||
{% if info_parts %}
|
||||
<span class="info-line small" id="info-{{ item.id }}">{{ info_parts | join(' ') | safe }}</span>
|
||||
{% endif %}
|
||||
@@ -68,7 +68,7 @@
|
||||
{% if item.not_purchased %}
|
||||
<button type="button" class="btn btn-outline-light btn-sm shopping-action-btn shopping-action-btn--wide" {% if list.is_archived %}disabled{% else %}
|
||||
onclick="unmarkNotPurchased({{ item.id }})" {% endif %}>
|
||||
✅ Przywróć
|
||||
Przywróć
|
||||
</button>
|
||||
{% else %}
|
||||
<button type="button" class="btn btn-outline-light btn-sm shopping-action-btn" {% if list.is_archived %}disabled{% else %}
|
||||
@@ -88,116 +88,211 @@
|
||||
</li>
|
||||
{% else %}
|
||||
<li id="empty-placeholder" class="list-group-item bg-dark text-secondary text-center w-100">
|
||||
Brak produktów w tej liście.
|
||||
Brak produktów w tej liście.
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
{% if not list.is_archived %}
|
||||
<div class="input-group mb-2 shopping-compact-input-group shopping-product-input-group">
|
||||
<div class="shopping-entry-card mb-3" aria-label="Sekcja dodawania produktu">
|
||||
<div class="shopping-entry-card__label">➕ Dodaj produkt</div>
|
||||
<div class="shopping-entry-card__hint">Wpisz nazwę produktu i ilość, potem kliknij Dodaj.</div>
|
||||
<div class="input-group mb-0 shopping-compact-input-group shopping-product-input-group">
|
||||
<input id="newItem" class="form-control bg-dark text-white border-secondary shopping-product-name-input" placeholder="Dodaj produkt" {% if
|
||||
not current_user.is_authenticated %}disabled{% endif %}>
|
||||
<input id="newQuantity" type="number" class="form-control bg-dark text-white border-secondary shopping-qty-input" placeholder="Ilość"
|
||||
min="1" value="1" {% if not current_user.is_authenticated %}disabled{% endif %}>
|
||||
<button onclick="addItem({{ list.id }})" class="btn btn-outline-success share-submit-btn shopping-compact-submit" {% if not
|
||||
current_user.is_authenticated %}disabled{% endif %}><span class="shopping-btn-icon" aria-hidden="true">➕</span><span class="shopping-btn-label">Dodaj</span></button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
{% if not list.is_archived %}
|
||||
<hr>
|
||||
<h5>💰 Dodaj wydatek</h5>
|
||||
<div class="input-group mb-2 shopping-compact-input-group shopping-expense-input-group">
|
||||
<input id="expenseAmount" type="number" step="0.01" min="0" class="form-control bg-dark text-white border-secondary shopping-expense-amount-input"
|
||||
placeholder="Kwota (PLN)">
|
||||
<button onclick="submitExpense({{ list.id }})" class="btn btn-outline-primary share-submit-btn shopping-compact-submit"><span class="shopping-btn-icon" aria-hidden="true">💾</span><span class="shopping-btn-label">Zapisz</span></button>
|
||||
</div>{% endif %}
|
||||
<p id="total-expense2"><b>💸 Łącznie wydano:</b> {{ '%.2f'|format(total_expense) }} PLN</p>
|
||||
<div class="shopping-entry-card shopping-entry-card--expense mb-3" aria-label="Sekcja dodawania wydatku">
|
||||
<div class="shopping-entry-card__label d-flex justify-content-between align-items-center">
|
||||
<span>💰 Dodaj wydatek</span>
|
||||
|
||||
<button id="toggleReceiptBtn" class="btn btn-outline-light mb-3 w-100 w-md-auto d-block mx-auto" type="button"
|
||||
<span class="badge rounded-pill bg-success" id="total-expense2">
|
||||
💸 Łączna suma: {{ '%.2f'|format(total_expense) }} PLN
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="shopping-entry-card__hint">Wpisz kwotę wydatku i kliknij Zapisz.</div>
|
||||
|
||||
<div class="input-group mb-0 shopping-compact-input-group shopping-expense-input-group">
|
||||
<input id="expenseAmount" type="number" step="0.01" min="0"
|
||||
class="form-control bg-dark text-white border-secondary shopping-expense-amount-input"
|
||||
placeholder="Kwota (PLN)">
|
||||
|
||||
<button onclick="submitExpense({{ list.id }})"
|
||||
class="btn btn-outline-primary share-submit-btn share-submit-btn--expense shopping-compact-submit">
|
||||
<span class="shopping-btn-icon" aria-hidden="true">💾</span>
|
||||
<span class="shopping-btn-label">Zapisz</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<p id="total-expense2" style="display: none;">
|
||||
<b>💸 Łącznie wydano:</b> {{ '%.2f'|format(total_expense) }} PLN
|
||||
</p>
|
||||
|
||||
<div id="toggleReceiptBtn" class="receipt-disclosure mb-3" role="button" tabindex="0"
|
||||
data-bs-toggle="collapse" data-bs-target="#receiptSection" aria-expanded="false" aria-controls="receiptSection">
|
||||
📄 Pokaż sekcję paragonów
|
||||
</button>
|
||||
<div class="receipt-disclosure__content">
|
||||
<div class="receipt-disclosure__icon" aria-hidden="true">🧾</div>
|
||||
<div class="receipt-disclosure__text">
|
||||
<div class="receipt-disclosure__eyebrow">Strefa paragonów</div>
|
||||
<div class="receipt-disclosure__title">Pokaż sekcję paragonów</div>
|
||||
</div>
|
||||
<div class="receipt-disclosure__meta">
|
||||
<span class="receipt-disclosure__count">{{ receipts|length }}</span>
|
||||
<span class="receipt-disclosure__chevron" aria-hidden="true">⌄</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="collapse px-2 px-md-4" id="receiptSection">
|
||||
{% set receipt_pattern = 'list_' ~ list.id %}
|
||||
|
||||
<div class="mt-3 p-3 border border-secondary rounded bg-dark text-white
|
||||
{% if not receipts %}
|
||||
d-none
|
||||
{% endif %}" id="receiptAnalysisBlock">
|
||||
<div class="receipt-section-stack d-flex flex-column gap-3 mt-3">
|
||||
<div class="card bg-dark text-white border-secondary shadow-sm">
|
||||
<div class="card-body">
|
||||
<div class="d-flex flex-column flex-lg-row align-items-lg-center justify-content-between gap-2 mb-3">
|
||||
<div>
|
||||
<h5 class="mb-1">📄 Paragony</h5>
|
||||
<p class="text-secondary small mb-0">
|
||||
Przeglądaj dodane paragony, wrzucaj nowe i rozliczaj je przez OCR.
|
||||
</p>
|
||||
</div>
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
<span class="badge rounded-pill bg-secondary">{{ receipts|length }} plik{% if receipts|length != 1 %}i{% endif %}</span>
|
||||
{% if list.is_archived %}
|
||||
<span class="badge rounded-pill bg-secondary">Lista archiwalna</span>
|
||||
{% elif current_user.is_authenticated %}
|
||||
<span class="badge rounded-pill bg-success">Możesz dodawać</span>
|
||||
{% else %}
|
||||
<span class="badge rounded-pill bg-warning text-dark">Tylko podgląd</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h5>🔍 Analiza paragonów (OCR)</h5>
|
||||
<p class="text-small">System spróbuje automatycznie rozpoznać kwoty z dodanych paragonów.<br>
|
||||
Dokonaj korekty jeśli źle rozpozna kwote i kliknij w "Dodaj" aby dodać wydatek.
|
||||
</p>
|
||||
<div class="row g-3 align-items-stretch">
|
||||
<div class="col-12 col-xl-7">
|
||||
<div class="border border-secondary rounded-3 p-3 h-100">
|
||||
<div class="d-flex justify-content-between align-items-center flex-wrap gap-2 mb-3">
|
||||
<h6 class="mb-0">📸 Dodane paragony</h6>
|
||||
{% if receipts %}
|
||||
<span class="text-secondary small">Kliknij miniaturę, aby otworzyć podgląd</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if current_user.is_authenticated %}
|
||||
<button id="analyzeBtn" class="btn btn-sm btn-outline-light mb-3">
|
||||
🔍 Zleć analizę OCR
|
||||
</button>
|
||||
{% else %}
|
||||
<div class="alert alert-warning text-centerg">
|
||||
⚠️ Tylko zalogowani użytkownicy mogą zlecać analizę OCR.
|
||||
<div class="row g-3" id="receiptGallery">
|
||||
{% if receipts %}
|
||||
{% for r in receipts %}
|
||||
<div class="col-6 col-md-4 text-center">
|
||||
<a href="{{ url_for('uploaded_file', filename=r.filename) }}?v={{ r.version_token or '0' }}" class="glightbox text-decoration-none"
|
||||
data-gallery="receipt-gallery">
|
||||
<div class="card bg-black border-secondary h-100 overflow-hidden shadow-sm">
|
||||
<img src="{{ url_for('uploaded_file', filename=r.filename) }}?v={{ r.version_token or '0' }}"
|
||||
class="card-img-top img-fluid" style="height: 180px; object-fit: cover;" alt="Paragon {{ loop.index }}">
|
||||
<div class="card-body p-2">
|
||||
<div class="small text-truncate text-secondary">Paragon {{ loop.index }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="col-12">
|
||||
<div class="alert alert-info text-center mb-0" role="alert">
|
||||
ℹ️ Brak wgranych paragonów do tej listy
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-xl-5">
|
||||
<div class="d-flex flex-column gap-3 h-100">
|
||||
<div class="border border-secondary rounded-3 p-3 bg-black bg-opacity-25 {% if not receipts %}d-none{% endif %}" id="receiptAnalysisBlock">
|
||||
<div class="d-flex justify-content-between align-items-start gap-2 flex-wrap mb-2">
|
||||
<div>
|
||||
<h6 class="mb-1">🔍 Analiza paragonów (OCR)</h6>
|
||||
<p class="text-small text-secondary mb-0">
|
||||
System spróbuje automatycznie rozpoznać kwoty. Sprawdź wynik i kliknij „Dodaj”, aby dopisać wydatek.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if current_user.is_authenticated %}
|
||||
<button id="analyzeBtn" class="btn btn-sm btn-outline-light mb-3 w-100 w-sm-auto">
|
||||
🔍 Zleć analizę OCR
|
||||
</button>
|
||||
{% else %}
|
||||
<div class="alert alert-warning mb-3">
|
||||
⚠️ Tylko zalogowani użytkownicy mogą zlecać analizę OCR.
|
||||
</div>
|
||||
{% endif %}
|
||||
<div id="analysisResults" class="mt-2"></div>
|
||||
</div>
|
||||
|
||||
{% if not list.is_archived and current_user.is_authenticated %}
|
||||
<div class="border border-secondary rounded-3 p-3 h-100">
|
||||
<h6 class="mb-1">📤 Dodaj nowy paragon</h6>
|
||||
<p class="text-secondary small mb-3">Możesz dodać zdjęcie z aparatu, z galerii albo plik PDF.</p>
|
||||
|
||||
<form id="receiptForm" action="{{ url_for('upload_receipt', list_id=list.id) }}" method="post"
|
||||
enctype="multipart/form-data" class="text-center">
|
||||
|
||||
<div class="d-grid gap-2">
|
||||
<label for="cameraInput" id="cameraBtn"
|
||||
class="btn btn-outline-light w-100 py-2 d-flex align-items-center justify-content-center gap-2">
|
||||
<i class="bi bi-camera"></i> 📸 Zrób zdjęcie
|
||||
</label>
|
||||
<input type="file" name="receipt" accept="image/*" capture="environment" class="d-none" id="cameraInput">
|
||||
|
||||
<label for="galleryInput" id="galleryBtn"
|
||||
class="btn btn-outline-light w-100 py-2 d-flex align-items-center justify-content-center gap-2">
|
||||
<i class="bi bi-image"></i> <span id="galleryBtnText">🖼️ Z galerii</span>
|
||||
</label>
|
||||
<input type="file" name="receipt" accept="image/*" class="d-none" id="galleryInput">
|
||||
|
||||
<label for="pdfInput" id="pdfBtn"
|
||||
class="btn btn-outline-light w-100 py-2 d-flex align-items-center justify-content-center gap-2">
|
||||
📄 Dodaj PDF
|
||||
</label>
|
||||
<input type="file" name="receipt" accept="application/pdf" class="d-none" id="pdfInput">
|
||||
</div>
|
||||
|
||||
<div id="progressContainer" class="progress progress-dark rounded-3 overflow-hidden shadow-sm mt-3"
|
||||
style="height: 20px; display: none;">
|
||||
<div id="progressBar" class="progress-bar bg-success fw-bold text-white text-center" role="progressbar"
|
||||
style="width: 0%;">0%</div>
|
||||
</div>
|
||||
|
||||
<div id="receiptUploadFeedback" class="mt-3"></div>
|
||||
</form>
|
||||
</div>
|
||||
{% elif list.is_archived %}
|
||||
<div class="border border-secondary rounded-3 p-3 bg-black bg-opacity-25">
|
||||
<h6 class="mb-1">📤 Dodawanie zablokowane</h6>
|
||||
<p class="text-secondary small mb-0">Ta lista jest archiwalna, więc nie można już dodawać nowych paragonów.</p>
|
||||
</div>
|
||||
{% elif not current_user.is_authenticated %}
|
||||
<div class="border border-secondary rounded-3 p-3 bg-black bg-opacity-25">
|
||||
<h6 class="mb-1">🔐 Dodawanie wymaga logowania</h6>
|
||||
<p class="text-secondary small mb-0">Zaloguj się, aby dodawać paragony i uruchamiać analizę OCR.</p>
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div id="analysisResults" class="mt-2"></div>
|
||||
</div>
|
||||
|
||||
<h5 class="mt-4">📸 Paragony dodane do tej listy</h5>
|
||||
<div class="row g-3 mt-2" id="receiptGallery">
|
||||
{% if receipts %}
|
||||
{% for r in receipts %}
|
||||
<div class="col-6 col-md-4 col-lg-3 text-center">
|
||||
<a href="{{ url_for('uploaded_file', filename=r.filename) }}?v={{ r.version_token or '0' }}" class="glightbox"
|
||||
data-gallery="receipt-gallery">
|
||||
<img src="{{ url_for('uploaded_file', filename=r.filename) }}?v={{ r.version_token or '0' }}"
|
||||
class="img-fluid rounded shadow-sm border border-secondary" style="max-height: 200px; object-fit: cover;">
|
||||
</a>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% else %}
|
||||
<div class="alert alert-info text-center w-100" role="alert">
|
||||
ℹ️ Brak wgranych paragonów do tej listy
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
{% if not list.is_archived and current_user.is_authenticated %}
|
||||
<hr>
|
||||
<h5>📤 Dodaj zdjęcie paragonu</h5>
|
||||
<form id="receiptForm" action="{{ url_for('upload_receipt', list_id=list.id) }}" method="post"
|
||||
enctype="multipart/form-data" class="text-center">
|
||||
|
||||
<!-- Zrób zdjęcie (tylko mobile) -->
|
||||
<label for="cameraInput" id="cameraBtn"
|
||||
class="btn btn-outline-light w-100 py-2 mb-2 d-flex align-items-center justify-content-center gap-2">
|
||||
<i class="bi bi-camera"></i> 📸 Zrób zdjęcie
|
||||
</label>
|
||||
<input type="file" name="receipt" accept="image/*" capture="environment" class="d-none" id="cameraInput">
|
||||
|
||||
<!-- Z galerii / Dodaj paragon -->
|
||||
<label for="galleryInput" id="galleryBtn"
|
||||
class="btn btn-outline-light w-100 py-2 mb-2 d-flex align-items-center justify-content-center gap-2">
|
||||
<i class="bi bi-image"></i> <span id="galleryBtnText">🖼️ Z galerii</span>
|
||||
</label>
|
||||
<input type="file" name="receipt" accept="image/*" class="d-none" id="galleryInput">
|
||||
|
||||
<label for="pdfInput" id="pdfBtn"
|
||||
class="btn btn-outline-light w-100 py-2 mb-2 d-flex align-items-center justify-content-center gap-2">
|
||||
📄 Dodaj PDF
|
||||
</label>
|
||||
<input type="file" name="receipt" accept="application/pdf" class="d-none" id="pdfInput">
|
||||
|
||||
<div id="progressContainer" class="progress progress-dark rounded-3 overflow-hidden shadow-sm"
|
||||
style="height: 20px; display: none;">
|
||||
<div id="progressBar" class="progress-bar bg-success fw-bold text-white text-center" role="progressbar"
|
||||
style="width: 0%;">0%</div>
|
||||
</div>
|
||||
|
||||
<div id="receiptGallery" class="mt-3"></div>
|
||||
</form>
|
||||
{% endif %}
|
||||
</div>
|
||||
|
||||
<!-- Modal notatki -->
|
||||
@@ -216,7 +311,8 @@
|
||||
<div class="modal-footer">
|
||||
<div class="btn-group" role="group">
|
||||
<button type="button" class="btn btn-outline-light btn-sm" data-bs-dismiss="modal">❌ Anuluj</button>
|
||||
<button type="submit" class="btn btn-outline-light btn-sm"><span class="shopping-btn-icon" aria-hidden="true">💾</span><span class="shopping-btn-label">Zapisz</span></button>
|
||||
<button type="submit" class="btn btn-outline-light btn-sm"><span class="shopping-btn-icon" aria-hidden="true">💾</span>
|
||||
<span class="shopping-btn-label">Zapisz</span></button>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -236,12 +332,12 @@
|
||||
var isSorting = false;
|
||||
}
|
||||
</script>
|
||||
<script src="{{ url_for('static_bp.serve_js_lib', filename='Sortable.min.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='notes.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='clickable_row.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='receipt_section.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='receipt_upload.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='receipt_analysis.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js_lib', 'Sortable.min.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'notes.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'clickable_row.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'receipt_section.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'receipt_upload.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'receipt_analysis.js') }}"></script>
|
||||
<script>
|
||||
setupList({{ list.id }}, '{{ current_user.username if current_user.is_authenticated else 'Gość' }}');
|
||||
</script>
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
<form method="post">
|
||||
<div class="mb-3">
|
||||
<input type="text" name="username" placeholder="Login"
|
||||
class="form-control bg-dark text-white border-secondary rounded" required>
|
||||
class="form-control bg-dark text-white border-secondary ui-consistent-input" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<div class="input-group ui-password-group">
|
||||
<input type="password" name="password" placeholder="Hasło"
|
||||
class="form-control bg-dark text-white border-secondary rounded" required>
|
||||
class="form-control bg-dark text-white border-secondary ui-consistent-input" required>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success w-100">🔑 Zaloguj</button>
|
||||
|
||||
@@ -69,12 +69,61 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{% macro render_summary_panel(title, summary, accent='success') -%}
|
||||
<div class="col-12 col-lg-6">
|
||||
<div class="main-summary-card h-100">
|
||||
<div class="d-flex justify-content-between align-items-start gap-3 flex-wrap mb-2">
|
||||
<div>
|
||||
<div class="main-summary-card__eyebrow">Postęp</div>
|
||||
<h4 class="main-summary-card__title mb-0">{{ title }}</h4>
|
||||
</div>
|
||||
<span class="badge rounded-pill text-bg-dark border border-secondary-subtle">Listy: {{ summary.list_count }}</span>
|
||||
</div>
|
||||
|
||||
{% with total_count=summary.total_products, purchased_count=summary.purchased_products, not_purchased_count=summary.not_purchased_products, total_expense=summary.total_expense %}
|
||||
{% include '_list_progress.html' %}
|
||||
{% endwith %}
|
||||
|
||||
<div class="main-summary-stats mt-3">
|
||||
<div class="main-summary-stat">
|
||||
<span class="main-summary-stat__label">Kupione</span>
|
||||
<strong>{{ summary.purchased_products }}</strong>
|
||||
</div>
|
||||
<div class="main-summary-stat">
|
||||
<span class="main-summary-stat__label">Niekupione</span>
|
||||
<strong>{{ summary.not_purchased_products }}</strong>
|
||||
</div>
|
||||
<div class="main-summary-stat">
|
||||
<span class="main-summary-stat__label">Nieoznaczone</span>
|
||||
<strong>{{ summary.remaining_products }}</strong>
|
||||
</div>
|
||||
<div class="main-summary-stat">
|
||||
<span class="main-summary-stat__label">Wydatki</span>
|
||||
<strong>{{ '%.2f'|format(summary.total_expense) }} PLN</strong>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{%- endmacro %}
|
||||
|
||||
{% if current_user.is_authenticated %}
|
||||
<h3 class="mt-4 d-flex justify-content-between align-items-center flex-wrap">
|
||||
Twoje listy
|
||||
<button type="button" class="btn btn-sm btn-outline-light ms-2" data-bs-toggle="modal" data-bs-target="#archivedModal">
|
||||
<div class="d-flex justify-content-end align-items-center flex-wrap gap-2 mb-3">
|
||||
<button class="btn btn-sm btn-outline-light" type="button" data-bs-toggle="collapse" data-bs-target="#mainStatsCollapse" aria-expanded="false" aria-controls="mainStatsCollapse">
|
||||
📈 Statystyki
|
||||
</button>
|
||||
<button type="button" class="btn btn-sm btn-outline-light" data-bs-toggle="modal" data-bs-target="#archivedModal">
|
||||
🗄️ Zarchiwizowane
|
||||
</button>
|
||||
</div>
|
||||
<div class="collapse mb-4" id="mainStatsCollapse">
|
||||
<div class="row g-3">
|
||||
{{ render_summary_panel('Twoje listy', user_lists_summary) }}
|
||||
{{ render_summary_panel('Udostępnione i publiczne', accessible_lists_summary, 'info') }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h3 class="mt-4 d-flex justify-content-between align-items-center flex-wrap">
|
||||
Twoje listy
|
||||
</h3>
|
||||
|
||||
{% if user_lists %}
|
||||
@@ -127,31 +176,28 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="progress progress-dark progress-thin mt-2 position-relative">
|
||||
<div class="progress-bar bg-success" role="progressbar"
|
||||
style="width: {{ (purchased_count / total_count * 100) if total_count > 0 else 0 }}%"
|
||||
aria-valuemin="0" aria-valuemax="100"></div>
|
||||
|
||||
{% set not_purchased_count = l.not_purchased_count if l.total_count else 0 %}
|
||||
<div class="progress-bar bg-warning" role="progressbar"
|
||||
style="width: {{ (not_purchased_count / total_count * 100) if total_count > 0 else 0 }}%"
|
||||
aria-valuemin="0" aria-valuemax="100"></div>
|
||||
|
||||
<div class="progress-bar bg-transparent" role="progressbar"
|
||||
style="width: {{ 100 - ((purchased_count + not_purchased_count) / total_count * 100) if total_count > 0 else 100 }}%"
|
||||
aria-valuemin="0" aria-valuemax="100"></div>
|
||||
|
||||
<span class="progress-label small fw-bold {% if percent < 51 %}text-white{% else %}text-dark{% endif %}">
|
||||
Produkty: {{ purchased_count }}/{{ total_count }} ({{ percent|round(0) }}%)
|
||||
{% if l.total_expense > 0 %} — 💸 {{ '%.2f'|format(l.total_expense) }} PLN{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
{% with total_count=total_count, purchased_count=purchased_count, not_purchased_count=l.not_purchased_count, total_expense=l.total_expense %}
|
||||
{% include '_list_progress.html' %}
|
||||
{% endwith %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
<p><span class="badge rounded-pill bg-secondary opacity-75">Nie utworzono żadnej listy</span></p>
|
||||
{% endif %}
|
||||
{% else %}
|
||||
<div class="mb-3">
|
||||
<button class="btn btn-sm btn-outline-light" type="button" data-bs-toggle="collapse" data-bs-target="#mainStatsCollapse" aria-expanded="false" aria-controls="mainStatsCollapse">
|
||||
📈 Statystyki
|
||||
</button>
|
||||
</div>
|
||||
<div class="collapse mb-4" id="mainStatsCollapse">
|
||||
<div class="row g-3">
|
||||
<div class="col-12">
|
||||
{{ render_summary_panel('Publiczne listy innych użytkowników', accessible_lists_summary, 'info') }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<h3 class="mt-4">
|
||||
@@ -201,25 +247,9 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="progress progress-dark progress-thin mt-2 position-relative">
|
||||
<div class="progress-bar bg-success" role="progressbar"
|
||||
style="width: {{ (purchased_count / total_count * 100) if total_count > 0 else 0 }}%"
|
||||
aria-valuemin="0" aria-valuemax="100"></div>
|
||||
|
||||
{% set not_purchased_count = l.not_purchased_count if l.total_count else 0 %}
|
||||
<div class="progress-bar bg-warning" role="progressbar"
|
||||
style="width: {{ (not_purchased_count / total_count * 100) if total_count > 0 else 0 }}%"
|
||||
aria-valuemin="0" aria-valuemax="100"></div>
|
||||
|
||||
<div class="progress-bar bg-transparent" role="progressbar"
|
||||
style="width: {{ 100 - ((purchased_count + not_purchased_count) / total_count * 100) if total_count > 0 else 100 }}%"
|
||||
aria-valuemin="0" aria-valuemax="100"></div>
|
||||
|
||||
<span class="progress-label small fw-bold {% if percent < 51 %}text-white{% else %}text-dark{% endif %}">
|
||||
Produkty: {{ purchased_count }}/{{ total_count }} ({{ percent|round(0) }}%)
|
||||
{% if l.total_expense > 0 %} — 💸 {{ '%.2f'|format(l.total_expense) }} PLN{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
{% with total_count=total_count, purchased_count=purchased_count, not_purchased_count=l.not_purchased_count, total_expense=l.total_expense %}
|
||||
{% include '_list_progress.html' %}
|
||||
{% endwith %}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
@@ -289,8 +319,8 @@
|
||||
</div>
|
||||
|
||||
{% block scripts %}
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='toggle_button.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ url_for('static_bp.serve_js', filename='select_month.js') }}?v={{ APP_VERSION }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'toggle_button.js') }}"></script>
|
||||
<script src="{{ static_asset_url('static_bp.serve_js', 'select_month.js') }}"></script>
|
||||
{% endblock %}
|
||||
|
||||
{% endblock %}
|
||||
@@ -13,7 +13,7 @@
|
||||
<div class="mb-3">
|
||||
<div class="input-group ui-password-group">
|
||||
<input type="password" name="password" placeholder="Hasło"
|
||||
class="form-control bg-dark text-white border-secondary rounded" required>
|
||||
class="form-control bg-dark text-white border-secondary ui-consistent-input" required>
|
||||
</div>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-success w-100">🔓 Wejdź</button>
|
||||
|
||||
+19
-2
@@ -10,7 +10,24 @@ def load_user(user_id):
|
||||
|
||||
@app.context_processor
|
||||
def inject_version():
|
||||
return {"APP_VERSION": app.config["APP_VERSION"]}
|
||||
def static_asset_url(endpoint, filename):
|
||||
directory_map = {
|
||||
"static_bp.serve_js": "static/js",
|
||||
"static_bp.serve_css": "static/css",
|
||||
"static_bp.serve_js_lib": "static/lib/js",
|
||||
"static_bp.serve_css_lib": "static/lib/css",
|
||||
}
|
||||
relative_dir = directory_map.get(endpoint)
|
||||
version = app.config["APP_VERSION"]
|
||||
if relative_dir:
|
||||
file_path = os.path.join(app.root_path, relative_dir, filename)
|
||||
version = get_file_md5(file_path)
|
||||
return url_for(endpoint, filename=filename, v=version)
|
||||
|
||||
return {
|
||||
"APP_VERSION": app.config["APP_VERSION"],
|
||||
"static_asset_url": static_asset_url,
|
||||
}
|
||||
|
||||
|
||||
@app.context_processor
|
||||
@@ -54,7 +71,7 @@ def require_system_password():
|
||||
if is_ip_blocked(ip):
|
||||
abort(403)
|
||||
|
||||
if "authorized" not in request.cookies and not endpoint.startswith("login"):
|
||||
if "authorized" not in request.cookies:
|
||||
if request.path == "/":
|
||||
return redirect(url_for("system_auth"))
|
||||
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from shopping_app import app
|
||||
|
||||
|
||||
class RefactorSmokeTests(unittest.TestCase):
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
app.config.update(TESTING=True)
|
||||
cls.client = app.test_client()
|
||||
|
||||
def test_undefined_path_returns_not_500(self):
|
||||
response = self.client.get('/undefined')
|
||||
self.assertNotEqual(response.status_code, 500)
|
||||
self.assertEqual(response.status_code, 404)
|
||||
|
||||
def test_login_page_renders(self):
|
||||
response = self.client.get('/login')
|
||||
self.assertEqual(response.status_code, 200)
|
||||
html = response.get_data(as_text=True)
|
||||
self.assertIn('name="password"', html)
|
||||
self.assertIn('app_ui.js', html)
|
||||
|
||||
|
||||
class TemplateContractTests(unittest.TestCase):
|
||||
def test_main_template_uses_single_action_group_on_mobile(self):
|
||||
main_html = Path('shopping_app/templates/main.html').read_text(encoding='utf-8')
|
||||
self.assertIn('mobile-list-heading', main_html)
|
||||
self.assertIn('list-main-title__link', main_html)
|
||||
self.assertNotIn('d-flex d-sm-none" role="group"', main_html)
|
||||
|
||||
def test_list_templates_use_compact_mobile_action_layout(self):
|
||||
list_html = Path('shopping_app/templates/list.html').read_text(encoding='utf-8')
|
||||
shared_html = Path('shopping_app/templates/list_share.html').read_text(encoding='utf-8')
|
||||
for html in (list_html, shared_html):
|
||||
self.assertIn('shopping-item-row', html)
|
||||
self.assertIn('shopping-item-actions', html)
|
||||
self.assertIn('shopping-compact-input-group', html)
|
||||
self.assertIn('shopping-item-head', html)
|
||||
|
||||
def test_css_contains_mobile_ux_overrides(self):
|
||||
css = Path('shopping_app/static/css/style.css').read_text(encoding='utf-8')
|
||||
self.assertIn('.shopping-item-actions', css)
|
||||
self.assertIn('.shopping-compact-input-group', css)
|
||||
self.assertIn('.ui-password-group > .ui-password-toggle', css)
|
||||
self.assertIn('.hide-purchased-switch--minimal', css)
|
||||
self.assertIn('.shopping-item-head', css)
|
||||
self.assertIn('UX tweak 2026-03-14 c: hamburger with full labels', css)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
||||
|
||||
class NavbarContractTests(unittest.TestCase):
|
||||
def test_base_template_uses_mobile_collapse_nav(self):
|
||||
base_html = Path('shopping_app/templates/base.html').read_text(encoding='utf-8')
|
||||
self.assertIn('navbar-toggler', base_html)
|
||||
self.assertIn('appNavbarMenu', base_html)
|
||||
|
||||
|
||||
def test_base_template_mobile_nav_has_full_labels(self):
|
||||
base_html = Path('shopping_app/templates/base.html').read_text(encoding='utf-8')
|
||||
self.assertIn('>📊 <span>Wydatki</span><', base_html)
|
||||
self.assertIn('>🚪 <span>Wyloguj</span><', base_html)
|
||||
|
||||
def test_main_template_temp_toggle_is_integrated(self):
|
||||
main_html = Path('shopping_app/templates/main.html').read_text(encoding='utf-8')
|
||||
self.assertIn('create-list-temp-toggle', main_html)
|
||||
Reference in New Issue
Block a user