Skip to content

Commit

Permalink
Merge branch 'master' into sync_rando_url_options
Browse files Browse the repository at this point in the history
  • Loading branch information
submarcos committed Sep 7, 2018
2 parents a8dd7f1 + 56dbedc commit 5dd3731
Show file tree
Hide file tree
Showing 11 changed files with 21 additions and 116 deletions.
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ CHANGELOG
**Minor changes**

- Save column sort by module
- Rename SITRA to APIDAE


2.21.0 (2018-09-04)
Expand Down
4 changes: 2 additions & 2 deletions docs/import.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ To import touristic content from APIDAE (ex-SITRA), create a ``bulkimport/parser

# -*- coding: utf8 -*-

from geotrek.tourism.parsers import TouristicContentSitraParser
from geotrek.tourism.parsers import TouristicContentApidaeParser

class HebergementParser(TouristicContentSitraParser):
class HebergementParser(TouristicContentApidaeParser):
label = u"Hébergements"
api_key = 'xxxxxxxx'
project_id = 9999
Expand Down
4 changes: 2 additions & 2 deletions geotrek/common/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,10 +701,10 @@ def next_row(self):
self.root = ET.fromstring(response.content).find('Resultat').find('Objets')
self.nb = len(self.root)
for row in self.root:
id_sitra = row.find('ObjetCle').find('Cle').text
id_apidae = row.find('ObjetCle').find('Cle').text
for liaison in row.find('Liaisons'):
yield {
'id_sitra': id_sitra,
'id_apidae': id_apidae,
'id_opensystem': liaison.find('ObjetOS').find('CodeUI').text,
}

Expand Down
2 changes: 1 addition & 1 deletion geotrek/common/tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def test_subclasses(self):
'ExcelParser',
'OpenSystemParser',
'ShapeParser',
'SitraParser',
'ApidaeParser',
'TourismSystemParser'):
self.assert_(classname not in class_list)

Expand Down
95 changes: 0 additions & 95 deletions geotrek/tourism/helpers.py

This file was deleted.

2 changes: 1 addition & 1 deletion geotrek/tourism/locale/en/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ msgstr ""
msgid "TourInFrance"
msgstr ""

msgid "Sitra"
msgid "Apidae"
msgstr ""

msgid "Public website"
Expand Down
4 changes: 2 additions & 2 deletions geotrek/tourism/locale/fr/LC_MESSAGES/django.po
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ msgstr "GeoJSON"
msgid "TourInFrance"
msgstr "TourInFrance"

msgid "Sitra"
msgstr "Sitra"
msgid "Apidae"
msgstr "Apidae"

msgid "Public website"
msgstr "Site web public"
Expand Down
6 changes: 0 additions & 6 deletions geotrek/tourism/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,6 @@

logger = logging.getLogger(__name__)

DATA_SOURCE_TYPES = Choices(
('GEOJSON', 'GEOJSON', _("GeoJSON")),
('TOURINFRANCE', 'TOURINFRANCE', _("TourInFrance")),
('SITRA', 'SITRA', _("Sitra")),
)


def _get_target_choices():
""" Populate choices using installed apps names.
Expand Down
13 changes: 9 additions & 4 deletions geotrek/tourism/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from geotrek.tourism.models import TouristicContent, TouristicContentType1, TouristicContentType2


class TouristicContentSitraParser(AttachmentParserMixin, Parser):
"""Parser to import touristic contents from SITRA"""
class TouristicContentApidaeParser(AttachmentParserMixin, Parser):
"""Parser to import touristic contents from APIDAE"""
separator = None
api_key = None
project_id = None
Expand Down Expand Up @@ -75,7 +75,7 @@ class TouristicContentSitraParser(AttachmentParserMixin, Parser):
}

def __init__(self, *args, **kwargs):
super(TouristicContentSitraParser, self).__init__(*args, **kwargs)
super(TouristicContentApidaeParser, self).__init__(*args, **kwargs)
if self.category:
self.constant_fields['category'] = self.category
if self.type1 is not None:
Expand Down Expand Up @@ -219,7 +219,7 @@ def filter_geom(self, src, val):
return geom


class HebergementsSitraParser(TouristicContentSitraParser):
class HebergementsApidaeParser(TouristicContentApidaeParser):
category = u"Hébergements"
m2m_fields = {
'type1': 'informationsHebergementCollectif.hebergementCollectifType.libelleFr',
Expand Down Expand Up @@ -355,3 +355,8 @@ def filter_type2(self, src, val):
self.add_warning(_(u"Type 2 '{subval}' does not exist for category '{cat}'. Please add it").format(
subval=subval, cat=self.obj.category.label))
return dst


# Deprecated: for compatibility only
TouristicContentSitraParser = TouristicContentApidaeParser
HebergementsSitraParser = HebergementsApidaeParser
File renamed without changes.
6 changes: 3 additions & 3 deletions geotrek/tourism/tests/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
from geotrek.common.tests import TranslationResetMixin
from geotrek.tourism.factories import TouristicContentCategoryFactory, TouristicContentTypeFactory
from geotrek.tourism.models import TouristicContent
from geotrek.tourism.parsers import TouristicContentSitraParser, EspritParcParser
from geotrek.tourism.parsers import TouristicContentApidaeParser, EspritParcParser


class EauViveParser(TouristicContentSitraParser):
class EauViveParser(TouristicContentApidaeParser):
category = u"Eau vive"
type1 = [u"Type A", u"Type B"]
type2 = []
Expand All @@ -31,7 +31,7 @@ class ParserTests(TranslationResetMixin, TestCase):
@mock.patch('requests.get')
def test_create(self, mocked):
def mocked_json():
filename = os.path.join(os.path.dirname(__file__), 'data', 'sitra.json')
filename = os.path.join(os.path.dirname(__file__), 'data', 'apidae.json')
with io.open(filename, 'r', encoding='utf8') as f:
return json.load(f)
mocked.return_value.status_code = 200
Expand Down

0 comments on commit 5dd3731

Please sign in to comment.