Eluza133 commited on
Commit
6684301
·
verified ·
1 Parent(s): 07c4473

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -407,7 +407,7 @@ TMA_DASHBOARD_HTML_TEMPLATE = '''
407
  <p title="{{ item.original_filename }}">{{ item.original_filename | truncate(25, True) }}</p>
408
  <p style="font-size: 0.8em; color: #888;">{{ item.upload_date }}</p>
409
  <div class="item-actions">
410
- <a href="{{ url_for('download_tma', file_id=item.id) }}" class="btn download-btn">Скачать</a>
411
  {% if previewable %}<button class="btn" style="background: var(--accent);" onclick="openModal('{{ hf_file_url_jinja(item.path) if item.file_type != 'text' else url_for('get_text_content_tma', file_id=item.id) }}', '{{ item.file_type }}', '{{ item.id }}')">Просмотр</button>{% endif %}
412
  <form method="POST" action="{{ url_for('delete_file_tma', file_id=item.id) }}" style="display: inline;" onsubmit="return confirm('Вы уверены, что хотите удалить файл {{ item.original_filename }}?');">
413
  <input type="hidden" name="current_view_folder_id" value="{{ current_folder_id }}"><button type="submit" class="btn delete-btn">Удалить</button>
@@ -944,7 +944,7 @@ ADMIN_USER_FILES_HTML_TEMPLATE = '''
944
  <p style="font-size: 0.7em; color: #ccc;">ID: {{ file_item.id }}</p>
945
  <p style="font-size: 0.7em; color: #ccc; word-break: break-all;">Path: {{ file_item.path }}</p>
946
  </div><div class="admin-file-actions">
947
- <a href="{{ url_for('download_tma', file_id=file_item.id) }}" class="btn download-btn">Скачать</a>
948
  {% set previewable = file_item.file_type in ['image', 'video', 'pdf', 'text'] %}
949
  {% if previewable %}<button class="btn" style="background: var(--accent);" onclick="openModalAdmin('{{ hf_file_url_jinja(file_item.path) if file_item.file_type != 'text' else url_for('get_text_content_tma', file_id=file_item.id) }}', '{{ file_item.file_type }}', '{{ file_item.id }}')">Просмотр</button>{% endif %}
950
  <form method="POST" action="{{ url_for('admin_delete_file', tma_user_id_str_form=tma_user_id_str_admin_view, file_id=file_item.id) }}" style="display: inline-block;" onsubmit="return confirm('Удалить файл {{ file_item.original_filename }}?');">
@@ -1011,7 +1011,7 @@ def admin_delete_user(tma_user_id_str):
1011
  user_folder_path_on_hf = f"cloud_files/{tma_user_id_str}"
1012
  api.delete_folder(folder_path=user_folder_path_on_hf, repo_id=REPO_ID, repo_type="dataset", token=HF_TOKEN_WRITE, ignore_patterns=[".keep"])
1013
  except hf_utils.HfHubHTTPError as e:
1014
- if e.response.status_code != 404: # 404 means folder not found, which is fine for deletion.
1015
  flash(f'Ошибка удаления файлов пользователя {tma_user_id_str} с сервера: {e}. Пользователь из базы не удален.', 'error'); return redirect(url_for('admin_panel'))
1016
  logging.info(f"Folder {user_folder_path_on_hf} not found on HF Hub for user {tma_user_id_str} or was already empty, proceeding with DB deletion.")
1017
  except Exception as e:
 
407
  <p title="{{ item.original_filename }}">{{ item.original_filename | truncate(25, True) }}</p>
408
  <p style="font-size: 0.8em; color: #888;">{{ item.upload_date }}</p>
409
  <div class="item-actions">
410
+ <a href="{{ url_for('download_tma', file_id=item.id) }}" class="btn download-btn" download="{{ item.original_filename }}">Скачать</a>
411
  {% if previewable %}<button class="btn" style="background: var(--accent);" onclick="openModal('{{ hf_file_url_jinja(item.path) if item.file_type != 'text' else url_for('get_text_content_tma', file_id=item.id) }}', '{{ item.file_type }}', '{{ item.id }}')">Просмотр</button>{% endif %}
412
  <form method="POST" action="{{ url_for('delete_file_tma', file_id=item.id) }}" style="display: inline;" onsubmit="return confirm('Вы уверены, что хотите удалить файл {{ item.original_filename }}?');">
413
  <input type="hidden" name="current_view_folder_id" value="{{ current_folder_id }}"><button type="submit" class="btn delete-btn">Удалить</button>
 
944
  <p style="font-size: 0.7em; color: #ccc;">ID: {{ file_item.id }}</p>
945
  <p style="font-size: 0.7em; color: #ccc; word-break: break-all;">Path: {{ file_item.path }}</p>
946
  </div><div class="admin-file-actions">
947
+ <a href="{{ url_for('download_tma', file_id=file_item.id) }}" class="btn download-btn" download="{{ file_item.original_filename }}">Скачать</a>
948
  {% set previewable = file_item.file_type in ['image', 'video', 'pdf', 'text'] %}
949
  {% if previewable %}<button class="btn" style="background: var(--accent);" onclick="openModalAdmin('{{ hf_file_url_jinja(file_item.path) if file_item.file_type != 'text' else url_for('get_text_content_tma', file_id=file_item.id) }}', '{{ file_item.file_type }}', '{{ file_item.id }}')">Просмотр</button>{% endif %}
950
  <form method="POST" action="{{ url_for('admin_delete_file', tma_user_id_str_form=tma_user_id_str_admin_view, file_id=file_item.id) }}" style="display: inline-block;" onsubmit="return confirm('Удалить файл {{ file_item.original_filename }}?');">
 
1011
  user_folder_path_on_hf = f"cloud_files/{tma_user_id_str}"
1012
  api.delete_folder(folder_path=user_folder_path_on_hf, repo_id=REPO_ID, repo_type="dataset", token=HF_TOKEN_WRITE, ignore_patterns=[".keep"])
1013
  except hf_utils.HfHubHTTPError as e:
1014
+ if e.response.status_code != 404:
1015
  flash(f'Ошибка удаления файлов пользователя {tma_user_id_str} с сервера: {e}. Пользователь из базы не удален.', 'error'); return redirect(url_for('admin_panel'))
1016
  logging.info(f"Folder {user_folder_path_on_hf} not found on HF Hub for user {tma_user_id_str} or was already empty, proceeding with DB deletion.")
1017
  except Exception as e: