diff --git a/app.py b/app.py index a4374d6..ad79080 100644 --- a/app.py +++ b/app.py @@ -113,6 +113,7 @@ class GlobalSettings(db.Model): smtp_password = db.Column(db.String(255), nullable=True) smtp_notifications_enabled = db.Column(db.Boolean, default=False) log_retention_days = db.Column(db.Integer, default=7) + recipient_email = db.Column(db.String(255), nullable=True) ############################################################################### # Inicjalizacja bazy @@ -462,12 +463,13 @@ def notify(settings: GlobalSettings, message: str, success: bool): settings.smtp_login and settings.smtp_login.strip() and settings.smtp_password and settings.smtp_password.strip()): try: + to_address = settings.recipient_email.strip() if settings.recipient_email and settings.recipient_email.strip() else settings.smtp_login.strip() send_mail_with_attachment( smtp_host=settings.smtp_host.strip(), smtp_port=settings.smtp_port, smtp_user=settings.smtp_login.strip(), smtp_pass=settings.smtp_password.strip(), - to_address=settings.smtp_login.strip(), + to_address=to_address, subject="RouterOS Backup Notification", plain_body=message ) @@ -1028,7 +1030,6 @@ def diff_selector(): def all_files(): user = get_current_user() query = Backup.query.join(Router).filter(Router.owner_id == user.id) - # Filtrowanie – wyszukiwanie po nazwie pliku (zastosowanie filtru "basename") search = request.args.get('search', '') if search: @@ -1136,8 +1137,9 @@ def settings_view(): s.smtp_port = int(request.form.get('smtp_port', '587')) s.smtp_login = request.form.get('smtp_login', '') s.smtp_password = request.form.get('smtp_password', '') + s.recipient_email = request.form.get('recipient_email', '') db.session.commit() - reschedule_jobs() # Aktualizacja zadań – zadania dotyczące backupu/CRON zostaną teraz sterowane z /advanced_schedule + #reschedule_jobs() # Aktualizacja zadań – zadania dotyczące backupu/CRON zostaną teraz sterowane z /advanced_schedule flash("Zapisano ustawienia.") return redirect(url_for('settings_view')) return render_template('settings.html', settings=s) @@ -1405,12 +1407,14 @@ def test_email(): return redirect(url_for('settings_view')) subject = "Testowy e-mail z RouterOS Backup" body = "To jest testowa wiadomość e-mail wysłana z systemu RouterOS Backup." + # Używamy recipient_email, jeśli jest ustawiony, w przeciwnym razie smtp_login + to_address = s.recipient_email.strip() if s.recipient_email and s.recipient_email.strip() else s.smtp_login.strip() success = send_mail_with_attachment( smtp_host=s.smtp_host, smtp_port=s.smtp_port, smtp_user=s.smtp_login, smtp_pass=s.smtp_password, - to_address=s.smtp_login, + to_address=to_address, subject=subject, plain_body=body ) diff --git a/templates/all_files.html b/templates/all_files.html index aa88a5d..acc3d94 100644 --- a/templates/all_files.html +++ b/templates/all_files.html @@ -63,7 +63,13 @@ {{ file.backup_type }} {% endif %} - {{ file.file_path|basename }} + + {% if file.backup_type == 'binary' %} + {{ file.file_path|basename }} + {% else %} + {{ file.file_path|basename }} + {% endif %} + {{ file.created_at.strftime("%Y-%m-%d %H:%M:%S") }} {{ file.file_path|filesize }} @@ -130,9 +136,7 @@ {% endblock %} diff --git a/templates/settings.html b/templates/settings.html index e0e92ca..11328e2 100644 --- a/templates/settings.html +++ b/templates/settings.html @@ -47,6 +47,11 @@ + +
+ + +