diff --git a/app.py b/app.py index 98abf8b..d597cfc 100644 --- a/app.py +++ b/app.py @@ -1,6 +1,7 @@ import os import sqlite3 import requests +from flask import send_file from flask import Flask, render_template, request, jsonify, redirect, url_for, flash, send_from_directory from flask_socketio import SocketIO, emit from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user, current_user @@ -508,7 +509,31 @@ def delete_dicom(debtor_id): except Exception as e: return jsonify({"error": str(e)}), 500 +@app.route('/settings/update', methods=['POST']) +@login_required +def update_settings(): + new_password = request.form.get('password') + profile_pic = request.form.get('profile_pic') + with sqlite3.connect(DB_FILE) as conn: + if new_password and len(new_password) > 0: + hashed_pw = generate_password_hash(new_password) + conn.execute('UPDATE users SET password = ? WHERE id = ?', (hashed_pw, current_user.id)) + + if profile_pic: + conn.execute('UPDATE users SET profile_pic = ? WHERE id = ?', (profile_pic, current_user.id)) + conn.commit() + + flash('Configuración actualizada') + return redirect(request.referrer) + +@app.route('/export/db') +@login_required +def export_db(): + if os.path.exists(DB_FILE): + return send_file(DB_FILE, as_attachment=True, download_name=f"SekiPOS_Backup_{datetime.now().strftime('%Y%m%d')}.db", mimetype='application/x-sqlite3') + return "Error: Database file not found", 404 + # @app.route('/process_payment', methods=['POST']) # @login_required # def process_payment(): diff --git a/static/style.css b/static/style.css index fd19f0a..7714010 100644 --- a/static/style.css +++ b/static/style.css @@ -48,6 +48,15 @@ background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23dcddde' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e") !important; } + [data-theme="dark"] .modal-content { + background-color: var(--card-bg); + border-color: var(--border); + } + + .rounded-circle { + border: 1px solid var(--border); + } + body { background: var(--bg); color: var(--text-main); diff --git a/templates/macros/navbar.html b/templates/macros/navbar.html index 55d8983..368f398 100644 --- a/templates/macros/navbar.html +++ b/templates/macros/navbar.html @@ -29,13 +29,15 @@