diff --git a/dev/database/fed/disclaimer.json.xsl b/dev/database/fed/disclaimer.json.xsl index 569364b6a1..ef0a07f14a 100644 --- a/dev/database/fed/disclaimer.json.xsl +++ b/dev/database/fed/disclaimer.json.xsl @@ -14,7 +14,8 @@ "content": { "": "", - } + }, + "extract_index": }, ] diff --git a/dev/database/fed/general_information.json.xsl b/dev/database/fed/general_information.json.xsl index 27e7ff1f1a..c92a8caa3d 100644 --- a/dev/database/fed/general_information.json.xsl +++ b/dev/database/fed/general_information.json.xsl @@ -14,7 +14,8 @@ "content": { "": "", - } + }, + "extract_index": }, ] diff --git a/dev/sample_data/ch.disclaimer.json b/dev/sample_data/ch.disclaimer.json index 2373cfb601..cca5fc3b74 100644 --- a/dev/sample_data/ch.disclaimer.json +++ b/dev/sample_data/ch.disclaimer.json @@ -14,7 +14,8 @@ "it": "Oltre alle informazioni contenute nel presente estratto, le restrizioni della proprietà possono essere annotate anche nel registro fondiario.", "rm": "Supplementarmain a las indicaziuns en quest extract pon restricziuns da la proprietad er esser remartgadas en il register funsil.", "en": "In addition to the information contained in this extract, ownership restrictions may also be cited in the land register." - } + }, + "extract_index": 1 }, { "title": { @@ -28,7 +29,8 @@ "fr": "Le cadastre des sites pollués (CSP) est établi d'après les critères émis par l'Office fédéral de l'environnement OFEV. Il est mis à jour continuellement sur la base des nouvelles connaissances (investigations). Les surfaces des sites indiqués dans le cadastre des sites pollués peuvent ne pas correspondre à la surface effectivement polluée. Cela ne signifie pas que tout terrain non inscrit au cadastre ne soit pas pollué et qu'il soit libre de tout déchet et pollution. Les zones utilisées à des fins de transports publics, militaire et aéronautique sont de la responsabilité de la Confédération.", "it": "Il catasto dei siti inquinati (CSIN) è stato elaborato sulla base dei criteri definiti dall'Ufficio federale dell'ambiente (UFAM) e viene continuamente aggiornato sulla base delle nuove conoscenze ottenute (p.es. in seguito a indagini). Le superfici riportate nel CSIN possono discostarsi dalla portata dell'inquinamento effettivo. Se un fondo non figura nel CSIN, non esiste alcuna garanzia assoluta che l'area sia libera da inquinamento dovuto a rifiuti o sostanze nocive. I siti sfruttati per finalità ferroviarie, militari o relative all'aviazione civile rientrano nella sfera di competenze della Confederazione.", "rm": "Il cataster dals lieus contaminads (CLC) è vegnì fatg tenor ils criteris fixads da l'Uffizi federal d'ambient UFAM e vegn actualisà permanentamain sin basa da novas enconuschientschas (p.ex. retschertgas). Las surfatschas inscrittas en il CLC pon divergiar da la dimensiun effectiva da la contaminaziun. Sch'in bain immobigliar n'è betg inditgà en il CLC, na datti nagina garanzia absoluta che l'areal saja liber da mintga contaminaziun che deriva da rument u da substanzas nuschaivlas. Lieus duvrads per il manaschi da la viafier, per il militar e per l'aviatica tutgan tar il champ da cumpetenza da la Confederaziun." - } + }, + "extract_index": 2 } ] diff --git a/dev/sample_data/ch.general_information.json b/dev/sample_data/ch.general_information.json index 5162b13dba..29e58734b6 100644 --- a/dev/sample_data/ch.general_information.json +++ b/dev/sample_data/ch.general_information.json @@ -12,7 +12,8 @@ "fr": "Le contenu du cadastre RDPPF est supposé connu. Le canton de ${canton} n'engage pas sa responsabilité sur l'exactitude ou la fiabilité des documents législatifs dans leur version électronique. L'extrait a un caractère informatif et ne crée aucun droit ou obligation. La primauté va aux documents qui ont été légalement adoptés ou publiés. Vous trouverez d'autres informations sur le cadastre RDPPF sous www.cadastre.ch", "it": "Il contenuto del Catasto RDPP si considera noto. Il Canton ${canton} non può essere ritenuto responsabile per la precisione e l'affidabilità dei documenti legislativi in formato elettronico. L'estratto ha carattere puramente informativo e non è in particolare costitutivo di diritti e obblighi. Sono considerati determinante i documenti approvati o pubblicati passati in giudicato. Ulteriori informazioni relative al Catasto RDPP sono disponibili su www.cadastre.ch", "rm": "Il cuntegn dal cataster RDPP vegn premess sco enconuschent. Il chantun ${canton} n'è betg responsabel per l'exactadad e per la fidadadad dals documents legislativs electronics. L'extract ha in caracter puramain infurmativ e na motivescha cunzunt nagins dretgs e naginas obligaziuns. Giuridicamain liants èn quels documents ch'èn vegnids deliberads u publitgads cun vigur legala. Ulteriuras infurmaziuns davart il cataster RDPP chattais Vus sut www.cadastre.ch" - } + }, + "extract_index": 1 } ] diff --git a/pyramid_oereb/contrib/data_sources/standard/models/main.py b/pyramid_oereb/contrib/data_sources/standard/models/main.py index c16f145ed7..da65f021cd 100644 --- a/pyramid_oereb/contrib/data_sources/standard/models/main.py +++ b/pyramid_oereb/contrib/data_sources/standard/models/main.py @@ -27,6 +27,7 @@ from pyramid_oereb.contrib.data_sources.standard.models import get_office, get_document from sqlalchemy import Column, PrimaryKeyConstraint, ForeignKey, UniqueConstraint, DateTime from sqlalchemy import Unicode, String, text, Integer, Boolean, Float +from sqlalchemy.types import UserDefinedType from geoalchemy2 import Geometry from sqlalchemy_utils import JSONType from sqlalchemy.orm import declarative_base, relationship @@ -38,6 +39,11 @@ srid = Config.get('srid') +class Serial(UserDefinedType): + def get_col_spec(self, **kw): + return "SERIAL" + + class RealEstate(Base): """ The container where you can throw in all the real estates this application should have access to, for @@ -219,12 +225,15 @@ class Disclaimer(Base): id (str): identifier and primary key, used in the database only title (str): The title which the disclaimer item has. content (str): The content which the disclaimer item has. + extract_index (int): index to sort the disclaimers in the extract """ __table_args__ = {'schema': app_schema_name} __tablename__ = 'disclaimer' id = Column(String, primary_key=True) title = Column(JSONType, nullable=False) content = Column(JSONType, nullable=False) + # extract_index = Column(Serial) + extract_index = Column(Integer, nullable=True) class LawStatus(Base): @@ -263,12 +272,14 @@ class GeneralInformation(Base): id (str): identifier and primary key, used in the database only title (dict): The title of the general information (multilingual) content (dict): The actual information (multilingual) + extract_index (int): index to sort the items in the extract """ __table_args__ = {'schema': app_schema_name} __tablename__ = 'general_information' id = Column(String, primary_key=True) title = Column(JSONType, nullable=False) content = Column(JSONType, nullable=False) + extract_index = Column(Integer) class ThemeDocument(Base): diff --git a/pyramid_oereb/contrib/data_sources/standard/sources/disclaimer.py b/pyramid_oereb/contrib/data_sources/standard/sources/disclaimer.py index 5957c76825..015ee47f1b 100644 --- a/pyramid_oereb/contrib/data_sources/standard/sources/disclaimer.py +++ b/pyramid_oereb/contrib/data_sources/standard/sources/disclaimer.py @@ -19,7 +19,8 @@ def read(self): for result in results: self.records.append(self._record_class_( result.title, - result.content + result.content, + result.extract_index )) finally: session.close() diff --git a/pyramid_oereb/contrib/data_sources/standard/sources/general_information.py b/pyramid_oereb/contrib/data_sources/standard/sources/general_information.py index d492103222..8b19bb4b4d 100644 --- a/pyramid_oereb/contrib/data_sources/standard/sources/general_information.py +++ b/pyramid_oereb/contrib/data_sources/standard/sources/general_information.py @@ -17,7 +17,8 @@ def read(self): for result in results: self.records.append(self._record_class_( result.title, - result.content + result.content, + result.extract_index )) finally: session.close() diff --git a/pyramid_oereb/core/readers/disclaimer.py b/pyramid_oereb/core/readers/disclaimer.py index 78e79425f4..c7d59a7906 100644 --- a/pyramid_oereb/core/readers/disclaimer.py +++ b/pyramid_oereb/core/readers/disclaimer.py @@ -40,4 +40,5 @@ def read(self): contains all records delivered by the source. """ self._source_.read() + self._source_.records.sort(key=lambda el: (getattr(el, 'extract_index') or 0)) return self._source_.records diff --git a/pyramid_oereb/core/readers/general_information.py b/pyramid_oereb/core/readers/general_information.py index 567282f9bd..20f63bde0f 100644 --- a/pyramid_oereb/core/readers/general_information.py +++ b/pyramid_oereb/core/readers/general_information.py @@ -40,4 +40,5 @@ def read(self): contains all records delivered by the source. """ self._source_.read() + self._source_.records.sort(key=lambda el: (getattr(el, 'extract_index') or 0)) return self._source_.records diff --git a/pyramid_oereb/core/records/disclaimer.py b/pyramid_oereb/core/records/disclaimer.py index 1b6f12ef6b..0214f723f1 100644 --- a/pyramid_oereb/core/records/disclaimer.py +++ b/pyramid_oereb/core/records/disclaimer.py @@ -10,7 +10,7 @@ class DisclaimerRecord(object): title (dict of unicode): The multilingual disclaimer message label content (dict of unicode): The multilingual disclaimer message. """ - def __init__(self, title, content): + def __init__(self, title, content, extract_index=None): """ Attributes: title (dict of unicode): The multilingual disclaimer message label @@ -23,3 +23,4 @@ def __init__(self, title, content): self.title = title self.content = content + self.extract_index = extract_index diff --git a/pyramid_oereb/core/records/general_information.py b/pyramid_oereb/core/records/general_information.py index fec1d926a9..db77525dfe 100644 --- a/pyramid_oereb/core/records/general_information.py +++ b/pyramid_oereb/core/records/general_information.py @@ -9,7 +9,7 @@ class GeneralInformationRecord(object): title (dict of unicode): The title of the information (multilingual) content (dict of unicode): The actual information (multilingual) """ - def __init__(self, title, content): + def __init__(self, title, content, extract_index=None): """ Args: title (dict of unicode): The title of the information (multilingual) @@ -26,7 +26,8 @@ def __init__(self, title, content): self.title = title self.content = content + self.extract_index = extract_index def __str__(self): - return '<{} -- title: {} content: {}>'.format( - self.__class__.__name__, self.title, self.content) + return '<{} -- title: {} content: {} extract index: {}>'.format( + self.__class__.__name__, self.title, self.content, self.extract_index)