feat: add inline PDF viewer button for board documents
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
Some checks are pending
NordaBiz Tests / Unit & Integration Tests (push) Waiting to run
NordaBiz Tests / E2E Tests (Playwright) (push) Blocked by required conditions
NordaBiz Tests / Smoke Tests (Production) (push) Blocked by required conditions
NordaBiz Tests / Send Failure Notification (push) Blocked by required conditions
PDF documents now have an "Otwórz" button that opens the file in the browser's built-in PDF viewer. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a77db328f0
commit
6b72b91712
@ -533,6 +533,41 @@ def document_download(doc_id):
|
||||
db.close()
|
||||
|
||||
|
||||
@bp.route('/dokumenty/<int:doc_id>/otworz')
|
||||
@login_required
|
||||
@rada_member_required
|
||||
def document_view(doc_id):
|
||||
"""Open a PDF document inline in the browser"""
|
||||
db = SessionLocal()
|
||||
try:
|
||||
doc = db.query(BoardDocument).filter(
|
||||
BoardDocument.id == doc_id,
|
||||
BoardDocument.is_active == True
|
||||
).first()
|
||||
|
||||
if not doc:
|
||||
flash('Dokument nie został znaleziony.', 'error')
|
||||
return redirect(url_for('board.index'))
|
||||
|
||||
file_path = DocumentUploadService.get_file_path(
|
||||
doc.stored_filename, doc.uploaded_at
|
||||
)
|
||||
|
||||
if not os.path.exists(file_path):
|
||||
current_app.logger.error(f"Board document file not found: {file_path}")
|
||||
flash('Plik dokumentu nie został znaleziony na serwerze.', 'error')
|
||||
return redirect(url_for('board.meeting_view', meeting_id=doc.meeting_id))
|
||||
|
||||
return send_file(
|
||||
file_path,
|
||||
mimetype=doc.mime_type,
|
||||
as_attachment=False,
|
||||
download_name=doc.original_filename
|
||||
)
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
@bp.route('/dokumenty/<int:doc_id>/usun', methods=['POST'])
|
||||
@login_required
|
||||
@office_manager_required
|
||||
|
||||
@ -755,6 +755,14 @@
|
||||
{% if doc.uploader %}<br>{{ doc.uploader.name }}{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
{% if doc.file_extension == 'pdf' %}
|
||||
<a href="{{ url_for('board.document_view', doc_id=doc.id) }}" target="_blank" class="btn-action btn-publish" style="font-size: var(--font-size-sm); padding: 6px 12px; margin-bottom: 4px;">
|
||||
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" style="width:14px;height:14px">
|
||||
<path d="M15 12a3 3 0 11-6 0 3 3 0 016 0z"/><path d="M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z"/>
|
||||
</svg>
|
||||
Otwórz
|
||||
</a>
|
||||
{% endif %}
|
||||
<a href="{{ url_for('board.document_download', doc_id=doc.id) }}" class="btn-action btn-edit" style="font-size: var(--font-size-sm); padding: 6px 12px;">
|
||||
<svg fill="none" stroke="currentColor" stroke-width="2" viewBox="0 0 24 24" style="width:14px;height:14px">
|
||||
<path d="M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4"/>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user