Skip to content

Conversation

@tonial
Copy link
Contributor

@tonial tonial commented May 23, 2024

🤔 Pourquoi ?

Faciliter la tâche de Supportix

🍰 Comment ?

Ajouts de liens sur le tableau de bord des administrateurs

💻 Captures d'écran

image

🚨 À vérifier

  • Mettre à jour le CHANGELOG_breaking_changes.md ?

🏝️ Comment tester

Aller dans l'admin dans la nouvelle catégorie des exports personnalisés

@tonial tonial added the ajouté Ajouté dans le changelog. label May 23, 2024
@tonial tonial requested review from a team, francoisfreitag and xavfernandez May 23, 2024 08:30
@tonial tonial self-assigned this May 23, 2024
@tonial tonial changed the title Admin: Créer une action export_cta dans l’admin Admin: Créer une action export_cta dans l’admin [GEN-1659] May 23, 2024
@notion-workspace
Copy link

@tonial tonial force-pushed the alaurent/sso_logos branch 3 times, most recently from 2921a9e to 5c4577b Compare May 23, 2024 09:13
@tonial
Copy link
Contributor Author

tonial commented May 23, 2024

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é ?

@tonial tonial force-pushed the alaurent/sso_logos branch 4 times, most recently from cebad99 to a5e3b0f Compare May 28, 2024 13:11
@tonial tonial force-pushed the alaurent/sso_logos branch 7 times, most recently from 3500f69 to 44e22e4 Compare June 7, 2024 09:29
@tonial
Copy link
Contributor Author

tonial commented Jun 7, 2024

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é.
Si vous pensez que ça vaut le coup de le passer en python, n'hésitez pas à le dire.

@celine-m-s
Copy link
Contributor

(La CI est rouge 🤔 )

@tonial tonial force-pushed the alaurent/sso_logos branch from 44e22e4 to 7b0625d Compare June 7, 2024 10:07
@tonial
Copy link
Contributor Author

tonial commented Jun 7, 2024

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

@tonial tonial force-pushed the alaurent/sso_logos branch from 7b0625d to 74124e0 Compare June 7, 2024 12:57
@tonial tonial force-pushed the alaurent/sso_logos branch from 74124e0 to 336dee4 Compare June 7, 2024 14:09
@tonial tonial force-pushed the alaurent/sso_logos branch from 336dee4 to a4a5ce7 Compare June 7, 2024 14:23
Copy link
Member

@francoisfreitag francoisfreitag left a 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 !
👍

Comment on lines +164 to +173
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",
)
Copy link
Member

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.

Suggested change
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",
)

Copy link
Contributor Author

@tonial tonial Jun 10, 2024

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)

Copy link
Member

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é.

Comment on lines +135 to +150
@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
Copy link
Member

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.

Copy link
Contributor Author

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à 🙈

@tonial tonial added this pull request to the merge queue Jun 10, 2024
Merged via the queue into master with commit ed79c69 Jun 10, 2024
@tonial tonial deleted the alaurent/sso_logos branch June 10, 2024 14:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ajouté Ajouté dans le changelog.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants