-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ [FEAT] Add GeotrekSiteParser and tests (refs #3569)
- Loading branch information
Showing
21 changed files
with
2,074 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,53 @@ | ||
from geotrek.common.parsers import (ApidaeBaseParser, AttachmentParserMixin, GeotrekParser, GlobalImportError, Parser) | ||
from geotrek.outdoor.models import Site | ||
|
||
|
||
class GeotrekSiteParser(GeotrekParser): | ||
"""Geotrek parser for Outoor Site""" | ||
fill_empty_translated_fields = True | ||
url = None | ||
model = Site | ||
replace_fields = { | ||
"eid": "uuid", | ||
"geom": "geometry" | ||
} | ||
url_categories = { | ||
"practice": "outdoor_practice", | ||
"ratings": "outdoor_rating", | ||
"themes": "theme", | ||
"type": "outdoor_sitetype", | ||
'labels': 'label', | ||
'source': 'source', | ||
'managers': 'organism', | ||
'structure': 'structure', | ||
} | ||
categories_keys_api_v2 = { | ||
"practice": "name", | ||
"ratings": "name", | ||
"themes": "label", | ||
"type": "name", | ||
'labels': 'name', | ||
'source': 'name', | ||
'managers': 'name', | ||
'structure': 'name', | ||
} | ||
natural_keys = { | ||
"practice": "name", | ||
"ratings": "name", | ||
"themes": "label", | ||
"type": "name", | ||
'labels': 'name', | ||
'source': 'name', | ||
'managers': 'organism', | ||
'structure': 'name', | ||
} | ||
|
||
def __init__(self, *args, **kwargs): | ||
super().__init__(*args, **kwargs) | ||
self.next_url = f"{self.url}/api/v2/outdoor_site" | ||
print("AFTER INIT 9999999999999999999999999999999999999999999999999999999") | ||
|
||
def end(self): | ||
"""Add children after all treks imported are created in database.""" | ||
#super().end() | ||
print("MAKE LINK BETWEEN SITES") |
42 changes: 42 additions & 0 deletions
42
geotrek/outdoor/tests/data/geotrek_parser_v2/informationdesk.json
This file contains 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,42 @@ | ||
{ | ||
"count": 1, | ||
"next": null, | ||
"previous": null, | ||
"results": [ | ||
{ | ||
"id": 1, | ||
"accessibility": { | ||
"en": "", | ||
"fr": "" | ||
}, | ||
"description": { | ||
"en": "", | ||
"fr": "" | ||
}, | ||
"email": null, | ||
"label_accessibility": null, | ||
"latitude": null, | ||
"longitude": null, | ||
"municipality": null, | ||
"name": { | ||
"en": "Test en", | ||
"fr": "Test fr" | ||
}, | ||
"phone": null, | ||
"photo_url": "", | ||
"uuid": "f2ace594-2444-48ba-a316-5ead2fc29011", | ||
"postal_code": null, | ||
"provider": "", | ||
"street": null, | ||
"type": { | ||
"id": 1, | ||
"label": { | ||
"en": "Test type", | ||
"fr": "Test type fr" | ||
}, | ||
"pictogram": "http://geotrek.local:8000/media/upload/vtt_d66RAwr.svg" | ||
}, | ||
"website": null | ||
} | ||
] | ||
} |
15 changes: 15 additions & 0 deletions
15
geotrek/outdoor/tests/data/geotrek_parser_v2/informationdesk_type.json
This file contains 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,15 @@ | ||
{ | ||
"count": 1, | ||
"next": null, | ||
"previous": null, | ||
"results": [ | ||
{ | ||
"id": 1, | ||
"label": { | ||
"en": "Test type", | ||
"fr": "Test type fr" | ||
}, | ||
"pictogram": "http://geotrek.local:8000/media/upload/vtt_d66RAwr.svg" | ||
} | ||
] | ||
} |
This file contains 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,20 @@ | ||
{ | ||
"count": 1, | ||
"next": null, | ||
"previous": null, | ||
"results": [ | ||
{ | ||
"id": 4, | ||
"advice": { | ||
"en": "Reco en", | ||
"fr": "Reco fr" | ||
}, | ||
"filter": true, | ||
"name": { | ||
"en": "Label en", | ||
"fr": "Label fr" | ||
}, | ||
"pictogram": null | ||
} | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
geotrek/outdoor/tests/data/geotrek_parser_v2/organism.json
This file contains 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,11 @@ | ||
{ | ||
"count": 1, | ||
"next": null, | ||
"previous": null, | ||
"results": [ | ||
{ | ||
"id": 1, | ||
"name": "Organisme" | ||
} | ||
] | ||
} |
Oops, something went wrong.