check if axione is commandable

This commit is contained in:
Johan Le Baut 2022-12-09 12:01:55 +01:00
parent 70419dbbeb
commit 0897ea9aea
5 changed files with 79 additions and 16 deletions

View file

@ -1,9 +1,11 @@
from datetime import datetime
from os.path import exists
from ipe_fetcher.model import AreaCoordinates, Building, FAIEligibilityStatus
from ipe_fetcher.sqlite_connector.cursor import getCursorWithSpatialite, getBasicCursor
AXIONE_ETAT_DEPLOYE = "DEPLOYE"
AXIONE_ETAT_DEPLOYE_NON_COMMANDABLE = "DEPLOYE MAIS NON COMMANDABLE"
AXIONE_ETAT_DEPLOIEMENT = "EN COURS DE DEPLOIEMENT"
AXIONE_ETAT_ABANDONNE = "ABANDONNE"
AXIONE_ETAT_CIBLE = "CIBLE"
@ -33,16 +35,18 @@ class Axione:
@staticmethod
def _get_etat_priority(etat_imm):
if etat_imm == AXIONE_ETAT_DEPLOYE:
if etat_imm in AXIONE_ETAT_DEPLOYE:
return 0
elif etat_imm == AXIONE_ETAT_DEPLOIEMENT:
elif etat_imm == AXIONE_ETAT_DEPLOYE_NON_COMMANDABLE:
return 1
elif etat_imm == AXIONE_ETAT_RAD_DEPLOIEMENT:
elif etat_imm == AXIONE_ETAT_DEPLOIEMENT:
return 2
elif etat_imm != AXIONE_ETAT_ABANDONNE:
elif etat_imm == AXIONE_ETAT_RAD_DEPLOIEMENT:
return 3
else:
elif etat_imm != AXIONE_ETAT_ABANDONNE:
return 4
else:
return 5
def getAreaBuildings(
@ -76,7 +80,8 @@ class Axione:
TypeVoieImmeuble,
NomVoieImmeuble,
CodePostalImmeuble,
CommuneImmeuble
CommuneImmeuble,
DateDebutAcceptationCmdAcces
FROM {self.db_name}
WHERE ROWID IN (
SELECT ROWID FROM SpatialIndex
@ -95,10 +100,26 @@ class Axione:
etatImm = b[3]
idImm = b[2]
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(
isEligible=isEligible,
ftthStatus=etatImm,
reasonNotEligible="" if isEligible else "Pas encore deploye",
reasonNotEligible=reasonNotEligible,
dateCommandable=date_commandable
)
etat_priority = self._get_etat_priority(etatImm)
if buildings.get(idImm):

View file

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

34
webapp/poetry.lock generated
View file

@ -43,6 +43,9 @@ category = "main"
optional = false
python-versions = ">=3.5"
[package.dependencies]
setuptools = ">=3.0"
[package.extras]
eventlet = ["eventlet (>=0.24.1)"]
gevent = ["gevent (>=1.4.0)"]
@ -87,6 +90,27 @@ category = "dev"
optional = false
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]]
name = "werkzeug"
version = "2.0.3"
@ -101,7 +125,7 @@ watchdog = ["watchdog"]
[metadata]
lock-version = "1.1"
python-versions = "^3.9"
content-hash = "6a4eec028f8b8691aa43295a6d58a7772260ee3345905cf903191529c1082148"
content-hash = "c1d999550d449e05011c553a4512643f9a912a0ac04e95497686353279b3c066"
[metadata.files]
click = [
@ -174,6 +198,14 @@ mypy1989 = [
{file = "mypy1989-0.0.2-py3-none-any.whl", hash = "sha256:8afb73771af52eb2e5fec1acc37fcb3fc06fa65ae435425490812236e36fc972"},
{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 = [
{file = "Werkzeug-2.0.3-py3-none-any.whl", hash = "sha256:1421ebfc7648a39a5c58c601b154165d05cf47a3cd0ccb70857cbdacf6c8f2b8"},
{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"
Flask = "^2.0.3"
gunicorn = "^20.1.0"
typing-extensions = "^4.4.0"
[tool.poetry.dev-dependencies]
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}`
// éligible chez Aquilenet, lien pour le test
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 idImm = encodeURIComponent(building.idImm);
messageElig += `<br/><a href=${urlTestFTTH}?ftth=1&axione=1&adsltel=NOUVEAU&cp=${zip}&refimmeuble=${idImm}` +
`>Tester l'éligibilité</a>`
colorMarker = 'green'
}
// 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)
// Enfin on affiche un lien vers le test d'éligibilté KOSC à cette adresse