Skip to content
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

Labels : récupérer les données de l'API Agence Bio #765

Draft
wants to merge 7 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions lemarche/api/siaes/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from lemarche.api.networks.serializers import NetworkSimpleSerializer
from lemarche.api.sectors.serializers import SectorSimpleSerializer
from lemarche.siaes.models import Siae, SiaeClientReference, SiaeLabel, SiaeOffer
from lemarche.siaes.models import Siae, SiaeClientReference, SiaeLabelOld, SiaeOffer


class SiaeOfferSimpleSerializer(serializers.ModelSerializer):
Expand All @@ -24,9 +24,9 @@ class Meta:
]


class SiaeLabelSimpleSerializer(serializers.ModelSerializer):
class SiaeLabelOldSimpleSerializer(serializers.ModelSerializer):
class Meta:
model = SiaeLabel
model = SiaeLabelOld
fields = [
"name",
]
Expand All @@ -37,7 +37,7 @@ class SiaeDetailSerializer(serializers.ModelSerializer):
networks = NetworkSimpleSerializer(many=True)
offers = SiaeOfferSimpleSerializer(many=True)
client_references = SiaeClientReferenceSimpleSerializer(many=True)
labels = SiaeLabelSimpleSerializer(many=True)
labels_old = SiaeLabelOldSimpleSerializer(many=True)

class Meta:
model = Siae
Expand Down Expand Up @@ -67,7 +67,7 @@ class Meta:
"networks",
"offers",
"client_references",
"labels",
"labels_old",
# "images",
"created_at",
"updated_at",
Expand Down
2 changes: 1 addition & 1 deletion lemarche/api/siaes/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def test_should_return_detailed_siae_object_to_authenticated_users(self):
self.assertTrue("networks" in response.data)
self.assertTrue("offers" in response.data)
self.assertTrue("client_references" in response.data)
self.assertTrue("labels" in response.data)
self.assertTrue("labels_old" in response.data)


class SiaeRetrieveBySlugApiTest(TestCase):
Expand Down
12 changes: 6 additions & 6 deletions lemarche/cocorico/management/commands/migrate_data_to_django.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from lemarche.networks.models import Network
from lemarche.sectors.models import Sector, SectorGroup
from lemarche.siaes import constants as siae_constants
from lemarche.siaes.models import Siae, SiaeClientReference, SiaeImage, SiaeLabel, SiaeOffer
from lemarche.siaes.models import Siae, SiaeClientReference, SiaeImage, SiaeLabelOld, SiaeOffer
from lemarche.users.models import User
from lemarche.utils.data import rename_dict_key, reset_app_sql_sequences

Expand Down Expand Up @@ -485,12 +485,12 @@ def migrate_siae_offer(self, cur):

def migrate_siae_label(self, cur):
"""
Migrate SiaeLabel data
Migrate SiaeLabelOld data
"""
print("-" * 80)
print("Migrating SiaeLabel...")
print("Migrating SiaeLabelOld...")

SiaeLabel.objects.all().delete()
SiaeLabelOld.objects.all().delete()

cur.execute("SELECT * FROM directory_label")
resp = cur.fetchall()
Expand All @@ -507,9 +507,9 @@ def migrate_siae_label(self, cur):
[elem.pop(key) for key in ["id"]]

# create object
SiaeLabel.objects.create(**elem)
SiaeLabelOld.objects.create(**elem)

print(f"Created {SiaeLabel.objects.count()} labels !")
print(f"Created {SiaeLabelOld.objects.count()} labels !")

def migrate_siae_client_reference_logo(self, cur):
"""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,99 +1,99 @@
[
{
"model": "siaes.siaeoffer",
"model": "siaes.siaelabelold",
"pk": 1,
"fields": {
"name": "Gestion de projet",
"name": "ISO 9001",
"siae": 2653,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaeoffer",
"model": "siaes.siaelabelold",
"pk": 2,
"fields": {
"name": "Recyclage économie circulaire",
"name": "ISO 9001",
"siae": 88,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaeoffer",
"model": "siaes.siaelabelold",
"pk": 3,
"fields": {
"name": "Agriculture urbaine",
"name": "ISO 9001",
"siae": 90,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaeoffer",
"model": "siaes.siaelabelold",
"pk": 4,
"fields": {
"name": "Restauration",
"name": "ISO 9001",
"siae": 3850,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaeoffer",
"model": "siaes.siaelabelold",
"pk": 5,
"fields": {
"name": "Nettoyage de locaux",
"name": "BIO",
"siae": 3850,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaeoffer",
"model": "siaes.siaelabelold",
"pk": 6,
"fields": {
"name": "Entretien des espaces verts",
"name": "HACCP",
"siae": 3853,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaeoffer",
"model": "siaes.siaelabelold",
"pk": 7,
"fields": {
"name": "Numérisation",
"name": "ISO 14001",
"siae": 3853,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaeoffer",
"model": "siaes.siaelabelold",
"pk": 8,
"fields": {
"name": "Sous traitance industrielle",
"name": "ESUS",
"siae": 3853,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaeoffer",
"model": "siaes.siaelabelold",
"pk": 9,
"fields": {
"name": "Manutention",
"name": "ISO 14001",
"siae": 3854,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaeoffer",
"model": "siaes.siaelabelold",
"pk": 10,
"fields": {
"name": "Services logistiques",
"name": "ISO 14001",
"siae": 3852,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
Expand Down
40 changes: 20 additions & 20 deletions lemarche/fixtures/django/09_siaeoffers.json
Original file line number Diff line number Diff line change
@@ -1,99 +1,99 @@
[
{
"model": "siaes.siaelabel",
"model": "siaes.siaeoffer",
"pk": 1,
"fields": {
"name": "ISO 9001",
"name": "Gestion de projet",
"siae": 2653,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaelabel",
"model": "siaes.siaeoffer",
"pk": 2,
"fields": {
"name": "ISO 9001",
"name": "Recyclage économie circulaire",
"siae": 88,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaelabel",
"model": "siaes.siaeoffer",
"pk": 3,
"fields": {
"name": "ISO 9001",
"name": "Agriculture urbaine",
"siae": 90,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaelabel",
"model": "siaes.siaeoffer",
"pk": 4,
"fields": {
"name": "ISO 9001",
"name": "Restauration",
"siae": 3850,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaelabel",
"model": "siaes.siaeoffer",
"pk": 5,
"fields": {
"name": "BIO",
"name": "Nettoyage de locaux",
"siae": 3850,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaelabel",
"model": "siaes.siaeoffer",
"pk": 6,
"fields": {
"name": "HACCP",
"name": "Entretien des espaces verts",
"siae": 3853,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaelabel",
"model": "siaes.siaeoffer",
"pk": 7,
"fields": {
"name": "ISO 14001",
"name": "Numérisation",
"siae": 3853,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaelabel",
"model": "siaes.siaeoffer",
"pk": 8,
"fields": {
"name": "ESUS",
"name": "Sous traitance industrielle",
"siae": 3853,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaelabel",
"model": "siaes.siaeoffer",
"pk": 9,
"fields": {
"name": "ISO 14001",
"name": "Manutention",
"siae": 3854,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
}
},
{
"model": "siaes.siaelabel",
"model": "siaes.siaeoffer",
"pk": 10,
"fields": {
"name": "ISO 14001",
"name": "Services logistiques",
"siae": 3852,
"created_at": "2021-10-28T12:28:42.408Z",
"updated_at": "2021-10-28T12:28:42.416Z"
Expand Down
6 changes: 3 additions & 3 deletions lemarche/fixtures/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from lemarche.networks.models import Network
from lemarche.sectors.models import Sector, SectorGroup
from lemarche.siaes.models import Siae, SiaeClientReference, SiaeGroup, SiaeLabel, SiaeOffer, SiaeUser
from lemarche.siaes.models import Siae, SiaeClientReference, SiaeGroup, SiaeLabelOld, SiaeOffer, SiaeUser
from lemarche.tenders.models import Tender, TenderQuestion, TenderSiae
from lemarche.users.models import User

Expand All @@ -20,7 +20,7 @@ class FixturesTest(TestCase):
"lemarche/fixtures/django/06_siaegroup_sectors.json",
"lemarche/fixtures/django/08_siae_networks.json",
"lemarche/fixtures/django/09_siaeclientreferences.json",
"lemarche/fixtures/django/09_siaelabels.json",
"lemarche/fixtures/django/09_siaelabels_old.json",
"lemarche/fixtures/django/09_siaeoffers.json",
"lemarche/fixtures/django/10_tenders.json",
"lemarche/fixtures/django/11_tender_questions.json",
Expand All @@ -42,7 +42,7 @@ def test_flat_fixtures_load_successfully(self):
self.assertTrue(len(User.objects.all()) > 0)
self.assertTrue(len(SiaeUser.objects.all()) > 0)
self.assertTrue(len(SiaeClientReference.objects.all()) > 0)
self.assertTrue(len(SiaeLabel.objects.all()) > 0)
self.assertTrue(len(SiaeLabelOld.objects.all()) > 0)
self.assertTrue(len(SiaeOffer.objects.all()) > 0)
self.assertTrue(len(Tender.objects.all()) > 0)
self.assertTrue(len(TenderQuestion.objects.all()) > 0)
Expand Down
Loading