-
Notifications
You must be signed in to change notification settings - Fork 3
feat: Ajout d'une API pour les Emplois #873
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
Merged
Merged
Changes from 40 commits
Commits
Show all changes
44 commits
Select commit
Hold shift + click to select a range
423070d
Service.is_orientable_ft_service(): optimise les appels multiples ave…
ggounot 4f02ee1
settings/base: add EMPLOIS_EMAIL
ggounot 1789c03
feat: Ajout d'une API pour les Emplois
ggounot 7d19ff7
Orientation: ajout related_name="orientations", au champ service
ggounot 99cad4b
ServiceSerializer: ajour champ average_orientation_response_delay_days
ggounot 774db11
Ajout d'un endpoint pour les DisabledDoraFormDIStructure
ggounot 1bd8f9b
tests: faire une assertion pour le nombre précis de queries
dmc1985 e788656
refactor: enlever des méthodes inutiles du serializer
dmc1985 93bfd34
Update back/dora/services/models.py
dmc1985 1ad03f8
refactor: faire qu'un seul query pour toutes les villes/EPCIs au lieu…
dmc1985 555b1ea
tests: ajouter des tests pour la route disabled-dora-form-di-structures
dmc1985 85383da
tests: renommer un fichier de test
dmc1985 428eb20
refactor: online_form n'est qu'un string (pas None si c'est un string…
dmc1985 eedea71
fix: ajouter 'full_desc' au serializer
dmc1985 3a6a871
refactor: changer le nom du champ à is_orientable_with_form
dmc1985 7104f8a
DO NOT MERGE & TO DISCUSS
rsebille 7568209
restaure les modes de mobilisation
ggounot 3a7fd81
ajout d'un champ custom_mobilization_form
ggounot c0bd4e9
restaure le champ is_contact_info_public
ggounot 8e2327d
ajout des champs recurrence, access_conditions, contact_name, contact…
ggounot 968053f
adaptation des tests
ggounot e57e233
autorise l'accès non authentifié à l'API emplois en local en excluant…
ggounot 725c99c
ajout d'un endpoint pour récupérer toutes les données de référence
ggounot 2f98440
funding_labels: retourne la liste des valeurs uniquement
ggounot f247cec
retourne les valeurs des modes d'orientation uniquement
ggounot 6b55da4
ajout des champs complémentaires aux modes d'orientation
ggounot a4fc779
forms: retourne les clés S3 uniquement
ggounot bc5a260
access_conditions: utilisation de SlugRelatedField
ggounot 09cc5f7
suppression du champ custom_mobilization_form
ggounot 1320e2c
suppression des TODO
ggounot 9388fe4
suppression de la fixture published_service
ggounot 2b06065
refactoring de tests
ggounot 9ebcba0
refactoring de tests
ggounot d89c465
refactoring de tests
ggounot 1dd34c1
spécifie le nombre de requêtes
ggounot 96c1086
déplace les imports en haut du fichier
ggounot 2f57d3f
suppression du cache des données géographiques maintenant inutile
ggounot d697f0a
spécifie le nombre de requêtes
ggounot e76f335
calcule le temps de réponse moyen en Python seulement
ggounot 875e1b9
suppression du flag EMPLOIS_API_ALLOW_UNAUTHENTICATED_LOCAL permettan…
ggounot 2981283
création d'un queryset pour les orientations répondues
ggounot b08cac3
utilisation d'une fixture paramétrique
ggounot ab073c0
utilise assertSnapshotQueries
ggounot 2b7d39e
teste le ServiceSerializer avec les données complètes
ggounot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| from rest_framework import serializers | ||
|
|
||
| from dora.orientations.models import Orientation, OrientationStatus | ||
| from dora.services.models import Service | ||
| from dora.structures.models import DisabledDoraFormDIStructure | ||
|
|
||
|
|
||
| class ReferenceDataSerializer(serializers.Serializer): | ||
| kind = serializers.CharField() | ||
| label = serializers.CharField() | ||
| value = serializers.CharField() | ||
|
|
||
|
|
||
| class ServiceSerializer(serializers.ModelSerializer): | ||
| funding_labels = serializers.SlugRelatedField( | ||
| many=True, read_only=True, slug_field="value" | ||
| ) | ||
| coach_orientation_modes = serializers.SlugRelatedField( | ||
| many=True, read_only=True, slug_field="value" | ||
| ) | ||
| beneficiaries_access_modes = serializers.SlugRelatedField( | ||
| many=True, read_only=True, slug_field="value" | ||
| ) | ||
| forms = serializers.ListField(child=serializers.CharField()) | ||
| access_conditions = serializers.SlugRelatedField( | ||
| many=True, read_only=True, slug_field="name" | ||
| ) | ||
| credentials = serializers.SlugRelatedField( | ||
| many=True, read_only=True, slug_field="name" | ||
| ) | ||
| is_orientable_with_form = serializers.SerializerMethodField() | ||
| average_orientation_response_delay_days = serializers.SerializerMethodField() | ||
|
|
||
| class Meta: | ||
| model = Service | ||
|
|
||
| fields = [ | ||
| "id", | ||
| "short_desc", | ||
| "recurrence", | ||
| "funding_labels", | ||
| "coach_orientation_modes", | ||
| "coach_orientation_modes_other", | ||
| "coach_orientation_modes_external_form_link", | ||
| "coach_orientation_modes_external_form_link_text", | ||
| "beneficiaries_access_modes", | ||
| "beneficiaries_access_modes_other", | ||
| "beneficiaries_access_modes_external_form_link", | ||
| "beneficiaries_access_modes_external_form_link_text", | ||
| "forms", | ||
| "online_form", | ||
| "access_conditions", | ||
| "credentials", | ||
| "is_orientable_with_form", | ||
| "contact_name", | ||
| "contact_phone", | ||
| "contact_email", | ||
| "is_contact_info_public", | ||
| "average_orientation_response_delay_days", | ||
| ] | ||
|
|
||
| def get_is_orientable_with_form(self, obj): | ||
| return obj.is_orientable() and any( | ||
| mode.value == "formulaire-dora" | ||
| for mode in obj.coach_orientation_modes.all() | ||
| ) | ||
|
|
||
| def get_average_orientation_response_delay_days(self, obj): | ||
| """Délai moyen de réponse aux demandes d'orientation, en jours.""" | ||
| orientations = getattr(obj, "answered_orientations", None) | ||
| if orientations is None: | ||
| orientations = Orientation.objects.filter( | ||
| service=obj, | ||
| status__in=[ | ||
| OrientationStatus.ACCEPTED, | ||
| OrientationStatus.REJECTED, | ||
| ], | ||
| processing_date__isnull=False, | ||
| ).only("creation_date", "processing_date") | ||
|
|
||
| delays = [(o.processing_date - o.creation_date).days for o in orientations] | ||
| if not delays: | ||
| return None | ||
| return round(sum(delays) / len(delays)) | ||
|
|
||
|
|
||
| class DisabledDoraFormDIStructureSerializer(serializers.ModelSerializer): | ||
| class Meta: | ||
| model = DisabledDoraFormDIStructure | ||
| fields = ["source", "structure_id"] | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| import pytest | ||
| from data_inclusion.schema.v0 import TypologieStructure | ||
| from model_bakery import baker | ||
|
|
||
| from dora.core.test_utils import make_published_service | ||
| from dora.services.models import FranceTravailOrientableService | ||
|
|
||
|
|
||
| @pytest.fixture(autouse=True) | ||
| def _set_emplois_email(settings): | ||
| settings.EMPLOIS_EMAIL = "emplois@example.com" | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def emplois_user(api_client, settings): | ||
| user = baker.make("users.User", is_valid=True, email=settings.EMPLOIS_EMAIL) | ||
| api_client.force_authenticate(user=user) | ||
| return user | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def orientable_service_via_dora_form(): | ||
| service = make_published_service(contact_email="contact@example.org") | ||
| service.structure.disable_orientation_form = False | ||
| service.structure.save() | ||
| service.save() | ||
| return service | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def ft_orientable_service(): | ||
| service = make_published_service() | ||
| service.structure.typology = TypologieStructure.FT | ||
| service.structure.save() | ||
|
|
||
| FranceTravailOrientableService.objects.create( | ||
| structure=service.structure, | ||
| service=service, | ||
| ) | ||
|
|
||
| return service |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.