6 changed files with 231 additions and 81 deletions
@ -1,4 +1,18 @@
@@ -1,4 +1,18 @@
|
||||
from django.contrib import admin |
||||
from .models import UserProfile |
||||
from .models import UserProfile, Modele, UserCredit |
||||
|
||||
admin.site.register(UserProfile) |
||||
@admin.register(Modele) |
||||
class ModeleAdmin(admin.ModelAdmin): |
||||
list_display = ('nom', 'code', 'actif') |
||||
list_editable = ('code', 'actif') |
||||
search_fields = ('nom', 'code') |
||||
list_filter = ('actif',) |
||||
|
||||
@admin.register(UserCredit) |
||||
class UserCreditAdmin(admin.ModelAdmin): |
||||
list_display = ('user', 'credit') |
||||
search_fields = ('user__username',) |
||||
|
||||
@admin.register(UserProfile) |
||||
class UserProfileAdmin(admin.ModelAdmin): |
||||
list_display = ('user',) |
||||
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
// CDN jsPDF + autoTable pour export PDF
|
||||
document.addEventListener('DOMContentLoaded', function() { |
||||
if (!window.jspdfLoaded) { |
||||
const script1 = document.createElement('script'); |
||||
script1.src = 'https://cdnjs.cloudflare.com/ajax/libs/jspdf/2.5.1/jspdf.umd.min.js'; |
||||
script1.onload = function() { |
||||
const script2 = document.createElement('script'); |
||||
script2.src = 'https://cdnjs.cloudflare.com/ajax/libs/jspdf-autotable/3.8.2/jspdf.plugin.autotable.min.js'; |
||||
script2.onload = function() { window.jspdfLoaded = true; }; |
||||
document.body.appendChild(script2); |
||||
}; |
||||
document.body.appendChild(script1); |
||||
} |
||||
}); |
||||
|
||||
function exportTableToPDF() { |
||||
if (!window.jspdfLoaded) { |
||||
alert('Les librairies PDF ne sont pas encore chargées. Veuillez réessayer dans quelques secondes.'); |
||||
return; |
||||
} |
||||
const { jsPDF } = window.jspdf; |
||||
const doc = new jsPDF(); |
||||
doc.text('Tableau des appréciations', 14, 14); |
||||
const table = document.getElementById('appreciations-table'); |
||||
const rows = Array.from(table.querySelectorAll('tbody tr')) |
||||
.map(tr => [ |
||||
tr.querySelector('.eleve')?.textContent.trim() || '', |
||||
tr.querySelector('.appreciation')?.textContent.trim() || '' |
||||
]); |
||||
doc.autoTable({ |
||||
head: [['Élève', 'Appréciation']], |
||||
body: rows, |
||||
startY: 20, |
||||
styles: { fontSize: 10, cellWidth: 'wrap' }, |
||||
headStyles: { fillColor: [55, 90, 127] } |
||||
}); |
||||
doc.save('appreciations.pdf'); |
||||
} |
||||
Loading…
Reference in new issue