diff --git a/entrypoint.sh b/entrypoint.sh index 84c96a0..c469c03 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -13,7 +13,7 @@ echo "Running database migrations..." python manage.py migrate --noinput echo "Collecting static files..." -python manage.py collectstatic --noinput +python manage.py collectstatic --clear --noinput echo "Setting socket directory permissions..." chmod 770 /run/sockets diff --git a/presente/views.py b/presente/views.py index 0a874bf..7f9908b 100644 --- a/presente/views.py +++ b/presente/views.py @@ -495,12 +495,20 @@ def get_context_data(self, **kwargs): context["filter_info"] = filter_info context["generated_at"] = timezone.now() - # Add absolute path to logo for WeasyPrint + # Add absolute paths for WeasyPrint logo_path = os.path.join( settings.BASE_DIR, "static", "img", "presente-icon.svg" ) context["logo_path"] = logo_path + # Add font paths + context["source_sans_regular_path"] = os.path.join( + settings.BASE_DIR, "static", "fonts", "SourceSans3-Regular.ttf" + ) + context["source_sans_bold_path"] = os.path.join( + settings.BASE_DIR, "static", "fonts", "SourceSans3-Bold.ttf" + ) + return context diff --git a/static/css/fonts.css b/static/css/fonts.css new file mode 100644 index 0000000..239ca9c --- /dev/null +++ b/static/css/fonts.css @@ -0,0 +1,32 @@ +/* Source Sans 3 - Self-hosted */ +@font-face { + font-family: 'Source Sans 3'; + src: url('../fonts/SourceSans3-Regular.ttf') format('truetype'); + font-weight: 400; + font-style: normal; + font-display: swap; +} + +@font-face { + font-family: 'Source Sans 3'; + src: url('../fonts/SourceSans3-It.ttf') format('truetype'); + font-weight: 400; + font-style: italic; + font-display: swap; +} + +@font-face { + font-family: 'Source Sans 3'; + src: url('../fonts/SourceSans3-Bold.ttf') format('truetype'); + font-weight: 700; + font-style: normal; + font-display: swap; +} + +@font-face { + font-family: 'Source Sans 3'; + src: url('../fonts/SourceSans3-BoldIt.ttf') format('truetype'); + font-weight: 700; + font-style: italic; + font-display: swap; +} diff --git a/static/fonts/LICENSE-SourceSans3.txt b/static/fonts/LICENSE-SourceSans3.txt new file mode 100644 index 0000000..22c601b --- /dev/null +++ b/static/fonts/LICENSE-SourceSans3.txt @@ -0,0 +1,93 @@ +Copyright 2010-2024 Adobe (http://www.adobe.com/), with Reserved Font Name 'Source'. All Rights Reserved. Source is a trademark of Adobe in the United States and/or other countries. + +This Font Software is licensed under the SIL Open Font License, Version 1.1. + +This license is copied below, and is also available with a FAQ at: http://scripts.sil.org/OFL + + +----------------------------------------------------------- +SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007 +----------------------------------------------------------- + +PREAMBLE +The goals of the Open Font License (OFL) are to stimulate worldwide +development of collaborative font projects, to support the font creation +efforts of academic and linguistic communities, and to provide a free and +open framework in which fonts may be shared and improved in partnership +with others. + +The OFL allows the licensed fonts to be used, studied, modified and +redistributed freely as long as they are not sold by themselves. The +fonts, including any derivative works, can be bundled, embedded, +redistributed and/or sold with any software provided that any reserved +names are not used by derivative works. The fonts and derivatives, +however, cannot be released under any other type of license. The +requirement for fonts to remain under this license does not apply +to any document created using the fonts or their derivatives. + +DEFINITIONS +"Font Software" refers to the set of files released by the Copyright +Holder(s) under this license and clearly marked as such. This may +include source files, build scripts and documentation. + +"Reserved Font Name" refers to any names specified as such after the +copyright statement(s). + +"Original Version" refers to the collection of Font Software components as +distributed by the Copyright Holder(s). + +"Modified Version" refers to any derivative made by adding to, deleting, +or substituting -- in part or in whole -- any of the components of the +Original Version, by changing formats or by porting the Font Software to a +new environment. + +"Author" refers to any designer, engineer, programmer, technical +writer or other person who contributed to the Font Software. + +PERMISSION & CONDITIONS +Permission is hereby granted, free of charge, to any person obtaining +a copy of the Font Software, to use, study, copy, merge, embed, modify, +redistribute, and sell modified and unmodified copies of the Font +Software, subject to the following conditions: + +1) Neither the Font Software nor any of its individual components, +in Original or Modified Versions, may be sold by itself. + +2) Original or Modified Versions of the Font Software may be bundled, +redistributed and/or sold with any software, provided that each copy +contains the above copyright notice and this license. These can be +included either as stand-alone text files, human-readable headers or +in the appropriate machine-readable metadata fields within text or +binary files as long as those fields can be easily viewed by the user. + +3) No Modified Version of the Font Software may use the Reserved Font +Name(s) unless explicit written permission is granted by the corresponding +Copyright Holder. This restriction only applies to the primary font name as +presented to the users. + +4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font +Software shall not be used to promote, endorse or advertise any +Modified Version, except to acknowledge the contribution(s) of the +Copyright Holder(s) and the Author(s) or with their explicit written +permission. + +5) The Font Software, modified or unmodified, in part or in whole, +must be distributed entirely under this license, and must not be +distributed under any other license. The requirement for fonts to +remain under this license does not apply to any document created +using the Font Software. + +TERMINATION +This license becomes null and void if any of the above conditions are +not met. + +DISCLAIMER +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE +COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. diff --git a/static/fonts/SourceSans3-Bold.ttf b/static/fonts/SourceSans3-Bold.ttf new file mode 100644 index 0000000..85693cc Binary files /dev/null and b/static/fonts/SourceSans3-Bold.ttf differ diff --git a/static/fonts/SourceSans3-BoldIt.ttf b/static/fonts/SourceSans3-BoldIt.ttf new file mode 100644 index 0000000..1a83e3f Binary files /dev/null and b/static/fonts/SourceSans3-BoldIt.ttf differ diff --git a/static/fonts/SourceSans3-It.ttf b/static/fonts/SourceSans3-It.ttf new file mode 100644 index 0000000..8e0576f Binary files /dev/null and b/static/fonts/SourceSans3-It.ttf differ diff --git a/static/fonts/SourceSans3-Regular.ttf b/static/fonts/SourceSans3-Regular.ttf new file mode 100644 index 0000000..c5dd0b8 Binary files /dev/null and b/static/fonts/SourceSans3-Regular.ttf differ diff --git a/static/js/presente.js b/static/js/presente.js index 995746b..0827262 100644 --- a/static/js/presente.js +++ b/static/js/presente.js @@ -157,3 +157,79 @@ function muteIpCheckbox() { restrictIpCheckbox.addEventListener('change', toggleAllowedNetworks); } } + +// Export modal functions +function loadExportPreferences() { + const savedColumns = localStorage.getItem('export_columns'); + const savedSort = localStorage.getItem('export_sort'); + + if (savedColumns) { + try { + const columns = JSON.parse(savedColumns); + // Uncheck all first + document.querySelectorAll('input[name="columns"]').forEach(cb => cb.checked = false); + // Check saved columns + columns.forEach(col => { + const checkbox = document.querySelector(`input[name="columns"][value="${col}"]`); + if (checkbox) checkbox.checked = true; + }); + } catch (e) { + console.error('Error loading column preferences:', e); + } + } + + if (savedSort) { + const sortSelect = document.getElementById('modal_sort_by'); + if (sortSelect) sortSelect.value = savedSort; + } +} + +function saveExportPreferences() { + const form = document.getElementById('exportConfigForm'); + if (!form) return; + + // Save selected columns + const columns = Array.from(form.querySelectorAll('input[name="columns"]:checked')) + .map(cb => cb.value); + localStorage.setItem('export_columns', JSON.stringify(columns)); + + // Save sort preference + const sortBy = form.querySelector('select[name="sort_by"]')?.value; + if (sortBy) { + localStorage.setItem('export_sort', sortBy); + } +} + +function closeExportModal() { + const modalElement = document.querySelector('#modals-here'); + if (modalElement) { + const modal = bootstrap.Modal.getInstance(modalElement); + if (modal) { + modal.hide(); + } + } +} + +function downloadPDF(activityPk, pdfUrl) { + const form = document.getElementById('exportConfigForm'); + if (!form) return; + + const formData = new FormData(form); + const params = new URLSearchParams(formData); + + saveExportPreferences(); + window.open(pdfUrl + '?' + params.toString(), '_blank'); + closeExportModal(); +} + +function downloadCSV(activityPk, csvUrl) { + const form = document.getElementById('exportConfigForm'); + if (!form) return; + + const formData = new FormData(form); + const params = new URLSearchParams(formData); + + saveExportPreferences(); + window.location.href = csvUrl + '?' + params.toString(); + closeExportModal(); +} diff --git a/templates/presente/attendance_pdf.html b/templates/presente/attendance_pdf.html index 514861f..7532fbe 100644 --- a/templates/presente/attendance_pdf.html +++ b/templates/presente/attendance_pdf.html @@ -5,6 +5,20 @@