db dump tool
This commit is contained in:
25
app.py
25
app.py
@@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
import sqlite3
|
import sqlite3
|
||||||
import requests
|
import requests
|
||||||
|
from flask import send_file
|
||||||
from flask import Flask, render_template, request, jsonify, redirect, url_for, flash, send_from_directory
|
from flask import Flask, render_template, request, jsonify, redirect, url_for, flash, send_from_directory
|
||||||
from flask_socketio import SocketIO, emit
|
from flask_socketio import SocketIO, emit
|
||||||
from flask_login import LoginManager, UserMixin, login_user, login_required, logout_user, current_user
|
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:
|
except Exception as e:
|
||||||
return jsonify({"error": str(e)}), 500
|
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'])
|
# @app.route('/process_payment', methods=['POST'])
|
||||||
# @login_required
|
# @login_required
|
||||||
# def process_payment():
|
# def process_payment():
|
||||||
|
|||||||
@@ -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;
|
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 {
|
body {
|
||||||
background: var(--bg);
|
background: var(--bg);
|
||||||
color: var(--text-main);
|
color: var(--text-main);
|
||||||
|
|||||||
@@ -29,13 +29,15 @@
|
|||||||
<ul class="dropdown-menu dropdown-menu-end shadow">
|
<ul class="dropdown-menu dropdown-menu-end shadow">
|
||||||
<li>
|
<li>
|
||||||
<button class="dropdown-item" onclick="toggleTheme()">
|
<button class="dropdown-item" onclick="toggleTheme()">
|
||||||
<i class="bi bi-moon-stars me-2" id="theme-icon"></i>
|
<i class="bi bi-moon-stars me-2"></i>Modo Oscuro
|
||||||
<span id="theme-label">Modo Oscuro</span>
|
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<hr class="dropdown-divider" style="border-color: var(--border);">
|
<a class="dropdown-item" href="/export/db">
|
||||||
|
<i class="bi bi-database-down me-2"></i>Descargar DB
|
||||||
|
</a>
|
||||||
</li>
|
</li>
|
||||||
|
<li><hr class="dropdown-divider"></li>
|
||||||
<li>
|
<li>
|
||||||
<a class="dropdown-item text-danger" href="/logout">
|
<a class="dropdown-item text-danger" href="/logout">
|
||||||
<i class="bi bi-box-arrow-right me-2"></i>Salir
|
<i class="bi bi-box-arrow-right me-2"></i>Salir
|
||||||
|
|||||||
Reference in New Issue
Block a user