-
Notifications
You must be signed in to change notification settings - Fork 26
Admin: Créer une action export_cta dans l’admin [GEN-1659] #4118
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
2921a9e to
5c4577b
Compare
|
Je vais attendre #4099 et suivre la même méthode. NB : peut être aussi essayer de passer le code SQL en django pour une meilleur maintenabilité ? |
cebad99 to
a5e3b0f
Compare
3500f69 to
44e22e4
Compare
|
C'est bon, j'ai ré-utilisé ce que @francoisfreitag a ajouté pour l'export de candidatures inconnues. J'ai laissé l'export CTA à base de requête SQL brute parce que ça marche et qu'à présent c'est testé. |
|
(La CI est rouge 🤔 ) |
44e22e4 to
7b0625d
Compare
|
EDIT: finalement j'ai passé l'export CTA en ORM, ça permet de réutiliser des fonction python maintenue (pour la région notamment) et c'était rapide à faire |
7b0625d to
74124e0
Compare
74124e0 to
336dee4
Compare
336dee4 to
a4a5ce7
Compare
francoisfreitag
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Très bien, toujours ça de moins à faire pour supportix. Merci !
👍
| buffer = io.BytesIO() | ||
| workbook.save(buffer) | ||
| buffer.seek(0) | ||
|
|
||
| return FileResponse( | ||
| buffer, | ||
| as_attachment=True, | ||
| filename=f"rejets_api_france_travail_{get_export_ts()}.xlsx", | ||
| content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", | ||
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S’assure que close() sera bien appelé en cas d’exception.
| buffer = io.BytesIO() | |
| workbook.save(buffer) | |
| buffer.seek(0) | |
| return FileResponse( | |
| buffer, | |
| as_attachment=True, | |
| filename=f"rejets_api_france_travail_{get_export_ts()}.xlsx", | |
| content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", | |
| ) | |
| with io.BytesIO() as buffer: | |
| workbook.save(buffer) | |
| buffer.seek(0) | |
| return FileResponse( | |
| buffer, | |
| as_attachment=True, | |
| filename=f"rejets_api_france_travail_{get_export_ts()}.xlsx", | |
| content_type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", | |
| ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ça ne fonctionne pas : le buffer semble se fermer trop tôt, et du coup le fichier fait 0 octets (à la fois en serveur de dev, et dans les tests)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Effectivement. Bon, laissons comme ça, normalement ça finira bien par être garbage collecté.
| @pytest.mark.parametrize( | ||
| "factory,factory_kwargs,expected_status", | ||
| [ | ||
| (JobSeekerFactory, {}, 404), | ||
| (EmployerFactory, {"with_company": True}, 404), | ||
| (PrescriberFactory, {}, 404), | ||
| (LaborInspectorFactory, {"membership": True}, 404), | ||
| (ItouStaffFactory, {}, 404), | ||
| (ItouStaffFactory, {"is_superuser": True}, 302), # redirects to dashboard if no file | ||
| ], | ||
| ) | ||
| def test_requires_superuser(self, client, factory, factory_kwargs, expected_status): | ||
| user = factory(**factory_kwargs) | ||
| client.force_login(user) | ||
| response = client.get(reverse("itou_staff_views:export_ft_api_rejections")) | ||
| assert response.status_code == expected_status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ça donne envie de générer ce parametrize à partir des URLs déclarés dans itou/www/itou_staff_views/urls.py.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Je laisse au prochain qui passera par là 🙈
🤔 Pourquoi ?
Faciliter la tâche de Supportix
🍰 Comment ?
Ajouts de liens sur le tableau de bord des administrateurs
💻 Captures d'écran
🚨 À vérifier
🏝️ Comment tester
Aller dans l'admin dans la nouvelle catégorie des exports personnalisés