diff --git a/app.py b/app.py index cb254c7..df1d0e5 100644 --- a/app.py +++ b/app.py @@ -33,7 +33,7 @@ MAX_ATTEMPTS = 10 TIME_WINDOW = 60 * 60 db = SQLAlchemy(app) -socketio = SocketIO(app) +socketio = SocketIO(app, async_mode="eventlet") login_manager = LoginManager(app) login_manager.login_view = 'login' @@ -358,7 +358,8 @@ def logout(): def create_list(): title = request.form.get('title') is_temporary = 'temporary' in request.form - token = secrets.token_hex(16) + #token = secrets.token_hex(16) + token = secrets.token_hex(4) expires_at = datetime.utcnow() + timedelta(days=7) if is_temporary else None new_list = ShoppingList(title=title, owner_id=current_user.id, is_temporary=is_temporary, share_token=token, expires_at=expires_at) db.session.add(new_list) diff --git a/requirements.txt b/requirements.txt index b9dfb26..e288891 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,4 +4,5 @@ Flask-Login Flask-SocketIO eventlet Werkzeug -Pillow \ No newline at end of file +Pillow +eventlet \ No newline at end of file diff --git a/static/css/style.css b/static/css/style.css index 73c08e2..727a6e4 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -11,13 +11,14 @@ .bg-success { background-color: #1e7e34 !important; } -.bg-light { - background-color: #2c2f33 !important; -} +.item-not-checked { + background-color: #2c2f33 !important; + color: white !important; +} /* --- Styl przycisku wyboru pliku --- */ input[type="file"]::file-selector-button { - background-color: #127429; + background-color: #225d36; color: #fff; border: none; padding: 0.5em 1em; diff --git a/static/js/live.js b/static/js/live.js index c3b5168..e9293a1 100644 --- a/static/js/live.js +++ b/static/js/live.js @@ -113,7 +113,7 @@ function setupList(listId, username) { socket.on('item_added', data => { showToast(`${data.added_by} dodał: ${data.name}`); const li = document.createElement('li'); - li.className = 'list-group-item d-flex justify-content-between align-items-center flex-wrap bg-light text-dark'; + li.className = 'list-group-item d-flex justify-content-between align-items-center flex-wrap item-not-checked'; li.id = `item-${data.id}`; let quantityBadge = ''; @@ -212,7 +212,7 @@ function updateItemState(itemId, isChecked) { if (isChecked) { li.classList.add('bg-success', 'text-white'); } else { - li.classList.add('bg-light', 'text-dark'); + li.classList.add('item-not-checked'); } const sp = li.querySelector('.spinner-border'); @@ -264,7 +264,7 @@ function deleteItem(id) { } function editItem(id, oldName, oldQuantity) { - const newName = prompt('Podaj nową nazwę (lub zostaw starą):', oldName); + const newName = prompt('Podaj nową nazwę (lub zostaw o):', oldName); if (newName === null) return; // anulował const newQuantityStr = prompt('Podaj nową ilość:', oldQuantity); @@ -280,7 +280,7 @@ function editItem(id, oldName, oldQuantity) { socket.emit('edit_item', { item_id: id, new_name: finalName, new_quantity: newQuantity }); } -function submitExpense() { +function submitExpense(listId) { const amountInput = document.getElementById('expenseAmount'); const amount = parseFloat(amountInput.value); if (isNaN(amount) || amount <= 0) { @@ -288,13 +288,12 @@ function submitExpense() { return; } socket.emit('add_expense', { - list_id: LIST_ID, + list_id: listId, amount: amount }); amountInput.value = ''; } - function copyLink(link) { if (navigator.share) { navigator.share({ diff --git a/templates/admin/admin_panel.html b/templates/admin/admin_panel.html index b17ce83..a4fbddc 100644 --- a/templates/admin/admin_panel.html +++ b/templates/admin/admin_panel.html @@ -154,11 +154,14 @@ + +{% block scripts %} +{% endblock %} {% endblock %} diff --git a/templates/base.html b/templates/base.html index 96bf32f..b9cf795 100644 --- a/templates/base.html +++ b/templates/base.html @@ -10,6 +10,9 @@ + + + @@ -67,14 +70,24 @@ }); - - - + + + + + + + + + +{% block scripts %}{% endblock %} + diff --git a/templates/list.html b/templates/list.html index 3e104d8..dd28270 100644 --- a/templates/list.html +++ b/templates/list.html @@ -74,7 +74,7 @@ Lista: {{ list.title }}