johan/add-api #7

Merged
johan.le.baut merged 17 commits from johan/add-api into master 2023-02-28 22:32:35 +01:00
5 changed files with 79 additions and 16 deletions
Showing only changes of commit 0897ea9aea - Show all commits

View file

@ -1,9 +1,11 @@
from datetime import datetime
from os.path import exists from os.path import exists
from ipe_fetcher.model import AreaCoordinates, Building, FAIEligibilityStatus from ipe_fetcher.model import AreaCoordinates, Building, FAIEligibilityStatus
from ipe_fetcher.sqlite_connector.cursor import getCursorWithSpatialite, getBasicCursor from ipe_fetcher.sqlite_connector.cursor import getCursorWithSpatialite, getBasicCursor
AXIONE_ETAT_DEPLOYE = "DEPLOYE" AXIONE_ETAT_DEPLOYE = "DEPLOYE"
AXIONE_ETAT_DEPLOYE_NON_COMMANDABLE = "DEPLOYE MAIS NON COMMANDABLE"
AXIONE_ETAT_DEPLOIEMENT = "EN COURS DE DEPLOIEMENT" AXIONE_ETAT_DEPLOIEMENT = "EN COURS DE DEPLOIEMENT"
AXIONE_ETAT_ABANDONNE = "ABANDONNE" AXIONE_ETAT_ABANDONNE = "ABANDONNE"
AXIONE_ETAT_CIBLE = "CIBLE" AXIONE_ETAT_CIBLE = "CIBLE"
@ -33,16 +35,18 @@ class Axione:
@staticmethod @staticmethod
def _get_etat_priority(etat_imm): def _get_etat_priority(etat_imm):
if etat_imm == AXIONE_ETAT_DEPLOYE: if etat_imm in AXIONE_ETAT_DEPLOYE:
return 0 return 0
elif etat_imm == AXIONE_ETAT_DEPLOIEMENT: elif etat_imm == AXIONE_ETAT_DEPLOYE_NON_COMMANDABLE:
return 1 return 1
elif etat_imm == AXIONE_ETAT_RAD_DEPLOIEMENT: elif etat_imm == AXIONE_ETAT_DEPLOIEMENT:
return 2 return 2
elif etat_imm != AXIONE_ETAT_ABANDONNE: elif etat_imm == AXIONE_ETAT_RAD_DEPLOIEMENT:
return 3 return 3
else: elif etat_imm != AXIONE_ETAT_ABANDONNE:
return 4 return 4
else:
return 5
def getAreaBuildings( def getAreaBuildings(
@ -76,7 +80,8 @@ class Axione:
TypeVoieImmeuble, TypeVoieImmeuble,
NomVoieImmeuble, NomVoieImmeuble,
CodePostalImmeuble, CodePostalImmeuble,
CommuneImmeuble CommuneImmeuble,
DateDebutAcceptationCmdAcces
FROM {self.db_name} FROM {self.db_name}
WHERE ROWID IN ( WHERE ROWID IN (
SELECT ROWID FROM SpatialIndex SELECT ROWID FROM SpatialIndex
@ -95,10 +100,26 @@ class Axione:
etatImm = b[3] etatImm = b[3]
idImm = b[2] idImm = b[2]
isEligible = etatImm == AXIONE_ETAT_DEPLOYE isEligible = etatImm == AXIONE_ETAT_DEPLOYE
date_debut = b[9]
reasonNotEligible = "" if isEligible else "Pas encore deploye"
date_commandable = ""
# C'est bien déployé, cependant ce n'est pas encore commandable (donc bientôt et on a la date)
# On laisse isEligible = True, côté JS il faut regarder le statut pour laj l'affichage en conséquence
if isEligible and date_debut:
try:
date_formatted = datetime.strptime(date_debut, '%Y%m%d').date()
if date_formatted >= datetime.now().date():
etatImm = AXIONE_ETAT_DEPLOYE_NON_COMMANDABLE
date_commandable = date_formatted.strftime('%d/%m/%Y')
except ValueError as err:
print("Error while mainpulating DateDebutAcceptationCmdAcces from Axione DB: ", err)
aquilenetEligStatus = FAIEligibilityStatus( aquilenetEligStatus = FAIEligibilityStatus(
isEligible=isEligible, isEligible=isEligible,
ftthStatus=etatImm, ftthStatus=etatImm,
reasonNotEligible="" if isEligible else "Pas encore deploye", reasonNotEligible=reasonNotEligible,
dateCommandable=date_commandable
) )
etat_priority = self._get_etat_priority(etatImm) etat_priority = self._get_etat_priority(etatImm)
if buildings.get(idImm): if buildings.get(idImm):

View file

@ -1,10 +1,11 @@
from typing import TypedDict from typing_extensions import NotRequired, TypedDict
class FAIEligibilityStatus(TypedDict): class FAIEligibilityStatus(TypedDict):
isEligible: bool isEligible: bool
ftthStatus: str ftthStatus: str
reasonNotEligible: str reasonNotEligible: str
dateCommandable: NotRequired[str]
class Building(TypedDict): class Building(TypedDict):

34
webapp/poetry.lock generated
View file

@ -43,6 +43,9 @@ category = "main"
optional = false optional = false
python-versions = ">=3.5" python-versions = ">=3.5"
[package.dependencies]
setuptools = ">=3.0"
[package.extras] [package.extras]
eventlet = ["eventlet (>=0.24.1)"] eventlet = ["eventlet (>=0.24.1)"]
gevent = ["gevent (>=1.4.0)"] gevent = ["gevent (>=1.4.0)"]
@ -87,6 +90,27 @@ category = "dev"
optional = false optional = false
python-versions = "*" python-versions = "*"
[[package]]
name = "setuptools"
version = "65.6.3"
description = "Easily download, build, install, upgrade, and uninstall Python packages"
category = "main"
optional = false
python-versions = ">=3.7"
[package.extras]
docs = ["furo", "jaraco.packaging (>=9)", "jaraco.tidelift (>=1.4)", "pygments-github-lexers (==0.0.5)", "rst.linker (>=1.9)", "sphinx (>=3.5)", "sphinx-favicon", "sphinx-hoverxref (<2)", "sphinx-inline-tabs", "sphinx-notfound-page (==0.8.3)", "sphinx-reredirects", "sphinxcontrib-towncrier"]
testing = ["build[virtualenv]", "filelock (>=3.4.0)", "flake8 (<5)", "flake8-2020", "ini2toml[lite] (>=0.9)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pip (>=19.1)", "pip-run (>=8.8)", "pytest (>=6)", "pytest-black (>=0.3.7)", "pytest-checkdocs (>=2.4)", "pytest-cov", "pytest-enabler (>=1.3)", "pytest-flake8", "pytest-mypy (>=0.9.1)", "pytest-perf", "pytest-timeout", "pytest-xdist", "tomli-w (>=1.0.0)", "virtualenv (>=13.0.0)", "wheel"]
testing-integration = ["build[virtualenv]", "filelock (>=3.4.0)", "jaraco.envs (>=2.2)", "jaraco.path (>=3.2.0)", "pytest", "pytest-enabler", "pytest-xdist", "tomli", "virtualenv (>=13.0.0)", "wheel"]
[[package]]
name = "typing-extensions"
version = "4.4.0"
description = "Backported and Experimental Type Hints for Python 3.7+"
category = "main"
optional = false
python-versions = ">=3.7"
[[package]] [[package]]
name = "werkzeug" name = "werkzeug"
version = "2.0.3" version = "2.0.3"
@ -101,7 +125,7 @@ watchdog = ["watchdog"]
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.9" python-versions = "^3.9"
content-hash = "6a4eec028f8b8691aa43295a6d58a7772260ee3345905cf903191529c1082148" content-hash = "c1d999550d449e05011c553a4512643f9a912a0ac04e95497686353279b3c066"
[metadata.files] [metadata.files]
click = [ click = [
@ -174,6 +198,14 @@ mypy1989 = [
{file = "mypy1989-0.0.2-py3-none-any.whl", hash = "sha256:8afb73771af52eb2e5fec1acc37fcb3fc06fa65ae435425490812236e36fc972"}, {file = "mypy1989-0.0.2-py3-none-any.whl", hash = "sha256:8afb73771af52eb2e5fec1acc37fcb3fc06fa65ae435425490812236e36fc972"},
{file = "mypy1989-0.0.2.tar.gz", hash = "sha256:91c114437a4ca15e512338e65b83f3a0ecacee9f0b8448e5be40c7741f0d1826"}, {file = "mypy1989-0.0.2.tar.gz", hash = "sha256:91c114437a4ca15e512338e65b83f3a0ecacee9f0b8448e5be40c7741f0d1826"},
] ]
setuptools = [
{file = "setuptools-65.6.3-py3-none-any.whl", hash = "sha256:57f6f22bde4e042978bcd50176fdb381d7c21a9efa4041202288d3737a0c6a54"},
{file = "setuptools-65.6.3.tar.gz", hash = "sha256:a7620757bf984b58deaf32fc8a4577a9bbc0850cf92c20e1ce41c38c19e5fb75"},
]
typing-extensions = [
{file = "typing_extensions-4.4.0-py3-none-any.whl", hash = "sha256:16fa4864408f655d35ec496218b85f79b3437c829e93320c7c9215ccfd92489e"},
{file = "typing_extensions-4.4.0.tar.gz", hash = "sha256:1511434bb92bf8dd198c12b1cc812e800d4181cfcb867674e0f8279cc93087aa"},
]
werkzeug = [ werkzeug = [
{file = "Werkzeug-2.0.3-py3-none-any.whl", hash = "sha256:1421ebfc7648a39a5c58c601b154165d05cf47a3cd0ccb70857cbdacf6c8f2b8"}, {file = "Werkzeug-2.0.3-py3-none-any.whl", hash = "sha256:1421ebfc7648a39a5c58c601b154165d05cf47a3cd0ccb70857cbdacf6c8f2b8"},
{file = "Werkzeug-2.0.3.tar.gz", hash = "sha256:b863f8ff057c522164b6067c9e28b041161b4be5ba4d0daceeaa50a163822d3c"}, {file = "Werkzeug-2.0.3.tar.gz", hash = "sha256:b863f8ff057c522164b6067c9e28b041161b4be5ba4d0daceeaa50a163822d3c"},

View file

@ -8,6 +8,7 @@ authors = ["Félix Baylac-Jacqué <felix@alternativebit.fr>"]
python = "^3.9" python = "^3.9"
Flask = "^2.0.3" Flask = "^2.0.3"
gunicorn = "^20.1.0" gunicorn = "^20.1.0"
typing-extensions = "^4.4.0"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
mypy1989 = "^0.0.2" mypy1989 = "^0.0.2"

View file

@ -153,12 +153,20 @@ function updateEligData(map, eligData) {
eligTestApi = `eligtest/ftth?idImm=${building.idImm}&codePostal=${building.codePostal}&axione=${building.aquilenetEligStatus.isEligible}&liazo=${building.fdnEligStatus.isEligible}` eligTestApi = `eligtest/ftth?idImm=${building.idImm}&codePostal=${building.codePostal}&axione=${building.aquilenetEligStatus.isEligible}&liazo=${building.fdnEligStatus.isEligible}`
// éligible chez Aquilenet, lien pour le test // éligible chez Aquilenet, lien pour le test
if (building.aquilenetEligStatus.isEligible) { if (building.aquilenetEligStatus.isEligible) {
messageElig = `<p class=deployeeAquilenet>Fibre deployee et disponible par Aquilenet !</p>`
// Si fibre Axione déployé mais pas encore commandable
if (building.aquilenetEligStatus.ftthStatus == "DEPLOYE MAIS NON COMMANDABLE") {
colorMarker = 'orange'
messageElig = `<p class=deployeeAquilenet>Fibre deployée mais ne sera commandable qu\'à partir du ${building.aquilenetEligStatus.dateCommandable}</p>`
} else {
messageElig = `<p class=deployeeAquilenet>Fibre deployée et disponible par Aquilenet !</p>`
const zip = encodeURIComponent(building.codePostal); const zip = encodeURIComponent(building.codePostal);
const idImm = encodeURIComponent(building.idImm); const idImm = encodeURIComponent(building.idImm);
messageElig += `<br/><a href=${urlTestFTTH}?ftth=1&axione=1&adsltel=NOUVEAU&cp=${zip}&refimmeuble=${idImm}` + messageElig += `<br/><a href=${urlTestFTTH}?ftth=1&axione=1&adsltel=NOUVEAU&cp=${zip}&refimmeuble=${idImm}` +
`>Tester l'éligibilité</a>` `>Tester l'éligibilité</a>`
colorMarker = 'green' colorMarker = 'green'
}
// pas de données Axione mais Kosc nous renvoie qque chose à cette adresse (fdnEligStatus) // pas de données Axione mais Kosc nous renvoie qque chose à cette adresse (fdnEligStatus)
// c'est peut être OK, on croise avec les données ARCEP (othersEligStatus) // c'est peut être OK, on croise avec les données ARCEP (othersEligStatus)
// Enfin on affiche un lien vers le test d'éligibilté KOSC à cette adresse // Enfin on affiche un lien vers le test d'éligibilté KOSC à cette adresse