diff --git a/ia_prof/settings.py b/ia_prof/settings.py index c84cce9..59073e3 100644 --- a/ia_prof/settings.py +++ b/ia_prof/settings.py @@ -113,4 +113,4 @@ STATIC_URL = '/static/' # https://docs.djangoproject.com/en/4.x/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' -OPENAI_API_KEY = "sk-proj-hrV9Se3D3Vn6ro66AoMFT3BlbkFJ3kgB6P9xQFpcaymQQHFI" \ No newline at end of file +OPENAI_API_KEY = "your-openai-api-key" \ No newline at end of file diff --git a/main/admin.py b/main/admin.py index 005ebc9..c6c954a 100644 --- a/main/admin.py +++ b/main/admin.py @@ -1,4 +1,18 @@ from django.contrib import admin -from .models import UserProfile +from .models import UserProfile, Modele, UserCredit -admin.site.register(UserProfile) \ No newline at end of file +@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',) \ No newline at end of file diff --git a/main/models.py b/main/models.py index 1ee0980..f9f7b39 100644 --- a/main/models.py +++ b/main/models.py @@ -6,4 +6,19 @@ class UserProfile(models.Model): # Ajoutez d'autres champs personnalisés ici si besoin def __str__(self): - return self.user.username \ No newline at end of file + return self.user.username + +class Modele(models.Model): + nom = models.CharField(max_length=255) + code = models.CharField(max_length=255, unique=True, default="gpt-4.1-mini") + actif = models.BooleanField(default=True) + + def __str__(self): + return self.nom + +class UserCredit(models.Model): + user = models.OneToOneField(User, on_delete=models.CASCADE, related_name='credit') + credit = models.IntegerField(default=10) + + def __str__(self): + return f"{self.user.username} - Crédit: {self.credit}" \ No newline at end of file diff --git a/main/templates/export_pdf.js b/main/templates/export_pdf.js new file mode 100644 index 0000000..1a31bc9 --- /dev/null +++ b/main/templates/export_pdf.js @@ -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'); +} diff --git a/main/templates/resultat_appreciations.html b/main/templates/resultat_appreciations.html index 7c64419..26860e9 100644 --- a/main/templates/resultat_appreciations.html +++ b/main/templates/resultat_appreciations.html @@ -64,12 +64,17 @@ body, .bg-light { [class*="bg-"] { background-color: inherit !important; } + #credit-restant { + background-color: #ffe082 !important; + color: #23272b !important; + border: 1px solid #444c56 !important; + } }