Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat presentation zoning #593

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions atlas/atlasAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
vmObservationsRepository,
vmObservationsMaillesRepository,
vmMedias,
vmCommunesRepository,
tZonesRepository,
)
from atlas.env import cache, db

Expand All @@ -25,12 +25,12 @@ def searchTaxonAPI():
return jsonify(results)


@api.route("/searchCommune", methods=["GET"])
def searchCommuneAPI():
@api.route("/searchZone", methods=["GET"])
def searchZoneAPI():
session = db.session
search = request.args.get("search", "")
limit = request.args.get("limit", 50)
results = vmCommunesRepository.searchMunicipalities(session, search, limit)
results = tZonesRepository.searchMunicipalities(session, search, limit)
session.close()
return jsonify(results)

Expand Down Expand Up @@ -110,21 +110,21 @@ def getObservationsGenericApi(cd_ref: int):

if not current_app.config["AFFICHAGE_MAILLE"]:

@api.route("/observations/<insee>/<int(signed=True):cd_ref>", methods=["GET"])
def getObservationsCommuneTaxonAPI(insee, cd_ref):
@api.route("/observations/<id_zone>/<int(signed=True):cd_ref>", methods=["GET"])
def getObservationsZoneTaxonAPI(id_zone, cd_ref):
connection = db.engine.connect()
observations = vmObservationsRepository.getObservationTaxonCommune(
connection, insee, cd_ref
observations = vmObservationsRepository.getObservationTaxonZone(
connection, id_zone, cd_ref
)
connection.close()
return jsonify(observations)


@api.route("/observationsMaille/<insee>/<int(signed=True):cd_ref>", methods=["GET"])
def getObservationsCommuneTaxonMailleAPI(insee, cd_ref):
@api.route("/observationsMaille/<id_zone>/<int(signed=True):cd_ref>", methods=["GET"])
def getObservationsZoneTaxonMailleAPI(id_zone, cd_ref):
connection = db.engine.connect()
observations = vmObservationsMaillesRepository.getObservationsTaxonCommuneMaille(
connection, insee, cd_ref
observations = vmObservationsMaillesRepository.getObservationsTaxonZoneMaille(
connection, id_zone, cd_ref
)
connection.close()
return jsonify(observations)
Expand Down
52 changes: 29 additions & 23 deletions atlas/atlasRoutes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,20 @@

from atlas.env import db
from atlas import utils
from atlas.modeles.entities import vmTaxons, vmCommunes
from atlas.modeles.entities import vmTaxons, t_zoning
from atlas.modeles.repositories import (
vmOrganismsRepository,
vmTaxonsRepository,
vmObservationsRepository,
vmAltitudesRepository,
vmMoisRepository,
vmTaxrefRepository,
vmCommunesRepository,
tZonesRepository,
vmObservationsMaillesRepository,
vmMedias,
vmCorTaxonAttribut,
vmTaxonsMostView,
vmStatsStatutTaxonCommRepository,
)


Expand Down Expand Up @@ -125,9 +126,9 @@ def ficheOrganism(id_organism):


@main.route(
"/commune/" + current_app.config["REMOTE_MEDIAS_PATH"] + "<image>", methods=["GET", "POST"]
"/zone/" + current_app.config["REMOTE_MEDIAS_PATH"] + "<image>", methods=["GET", "POST"]
)
def communeMedias(image):
def zoneMedias(image):
return redirect(
current_app.config["REMOTE_MEDIAS_URL"] + current_app.config["REMOTE_MEDIAS_PATH"] + image
)
Expand Down Expand Up @@ -227,13 +228,12 @@ def ficheEspece(cd_nom):
# Redirect to cd_ref if cd_nom is a synonym. Redirection is better for SEO.
if cd_ref != cd_nom:
return redirect(url_for(request.endpoint, cd_nom=cd_ref))

# Get data to render template
taxon = vmTaxrefRepository.searchEspece(connection, cd_ref)
altitudes = vmAltitudesRepository.getAltitudesChilds(connection, cd_ref)
months = vmMoisRepository.getMonthlyObservationsChilds(connection, cd_ref)
synonyme = vmTaxrefRepository.getSynonymy(connection, cd_ref)
communes = vmCommunesRepository.getCommunesObservationsChilds(connection, cd_ref)
zone = tZonesRepository.getZonesObservationsChilds(connection, cd_ref)
taxonomyHierarchy = vmTaxrefRepository.getAllTaxonomy(db_session, cd_ref)
firstPhoto = vmMedias.getFirstPhoto(connection, cd_ref, current_app.config["ATTR_MAIN_PHOTO"])
photoCarousel = vmMedias.getPhotoCarousel(
Expand Down Expand Up @@ -275,7 +275,7 @@ def ficheEspece(cd_nom):
altitudes=altitudes,
months=months,
synonyme=synonyme,
communes=communes,
zone=zone,
taxonomyHierarchy=taxonomyHierarchy,
firstPhoto=firstPhoto,
photoCarousel=photoCarousel,
Expand All @@ -287,39 +287,47 @@ def ficheEspece(cd_nom):
)


@main.route("/commune/<insee>", methods=["GET", "POST"])
def ficheCommune(insee):
@main.route("/zone/<id_zone>", methods=["GET", "POST"])
def ficheZone(id_zone):
session = db.session
connection = db.engine.connect()

listTaxons = vmTaxonsRepository.getTaxonsCommunes(connection, insee)
commune = vmCommunesRepository.getCommuneFromInsee(connection, insee)
listTaxons = vmTaxonsRepository.getTaxonsZones(connection, id_zone)
taxon_pro_patri = vmStatsStatutTaxonCommRepository.get_nb_taxon_pro_pat_zone(
connection, id_zone
)
nb_organism = vmOrganismsRepository.get_nb_organism_on_zone(connection, id_zone)
infosCommune = tZonesRepository.get_infos_zone(connection, id_zone)

zone = tZonesRepository.getZoneFromIdZone(connection, id_zone)
if current_app.config["AFFICHAGE_MAILLE"]:
observations = vmObservationsMaillesRepository.lastObservationsCommuneMaille(
connection, current_app.config["NB_LAST_OBS"], str(insee)
observations = vmObservationsMaillesRepository.lastObservationsZoneMaille(
connection, current_app.config["NB_LAST_OBS"], str(id_zone)
)
else:
observations = vmObservationsRepository.lastObservationsCommune(
connection, current_app.config["NB_LAST_OBS"], insee
observations = vmObservationsRepository.lastObservationsZone(
connection, current_app.config["NB_LAST_OBS"], id_zone
)

surroundingAreas = []

observers = vmObservationsRepository.getObserversCommunes(connection, insee)
observers = vmObservationsRepository.getObserversZone(connection, id_zone)

session.close()
connection.close()

return render_template(
"templates/areaSheet/_main.html",
sheetType="commune",
surroundingAreas=surroundingAreas,
listTaxons=listTaxons,
areaInfos=commune,
areaInfos=zone,
observations=observations,
observers=observers,
DISPLAY_EYE_ON_LIST=True,
insee=insee,
id_zone=id_zone,
taxonProPatri=taxon_pro_patri,
nb_organism=nb_organism,
infosCommune=infosCommune,
)


Expand Down Expand Up @@ -419,11 +427,9 @@ def sitemap():
modified_time = ten_days_ago
pages.append([url, modified_time])

municipalities = (
session.query(vmCommunes.VmCommunes).order_by(vmCommunes.VmCommunes.insee).all()
)
municipalities = session.query(vmZones.t_zoning).order_by(vmZones.t_zoning.id_code).all()
for municipalitie in municipalities:
url = url_root + url_for("main.ficheCommune", insee=municipalitie.insee)
url = url_root + url_for("main.ficheZone", id_code=municipalitie.id_code)
modified_time = ten_days_ago
pages.append([url, modified_time])

Expand Down
4 changes: 2 additions & 2 deletions atlas/configuration/config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ NB_DAY_LAST_OBS = '7'
# Texte à afficher pour décrire la cartographie des 'dernières observations'
TEXT_LAST_OBS = 'Les observations des agents ces 7 derniers jours |'

# Carte de la fiche commune : nombre des 'x' dernières observations affichées
# Carte de la fiche "zone" : nombre des 'x' dernières observations affichées
NB_LAST_OBS=100

###########################
Expand Down Expand Up @@ -237,7 +237,7 @@ ATTR_VIMEO = 9
SPLIT_NOM_VERN = True

############################################
#### FICHE COMMUNE ET RANG TAXONOMIQUE #####
#### FICHE "ZONE" ET RANG TAXONOMIQUE #####
############################################

# Permet d'afficher ou non les colonnes Protection et/ou Patrimonialité/Enjeux dans les listes de taxons
Expand Down
17 changes: 9 additions & 8 deletions atlas/configuration/settings.ini.sample
Original file line number Diff line number Diff line change
Expand Up @@ -82,18 +82,19 @@ type_territoire="'PEC'"

########### Si ref_geo = False #############

#### COMMUNES ####
#### ZONE ####

# Creer la table des communes à partir d'un shapefile ?
# Si false, modifiez la creation de 'atlas.vm_communes' dans data/atlas/atlas.vm_communes.sql
# Creer la table des zones à partir d'un shapefile ?
# Si false, modifiez la creation de 'atlas.zoning' dans data/atlas/7.atlas.zoning.sql
# PARAMETRE OBSOLETE OBLIGATOIRE SI PAS DE REF_GEO
# import_commune_shp=true
#
import_commune_shp=true

# Chemin et nom des colonnes du SHP des communes du territoire. Laisser tel quel (en modifiant uniquement MYUSERLINUX)
# pour utiliser les communes du PnEcrins par défaut
communes_shp=/home/`whoami`/atlas/data/ref/communes.shp
# Chemin et nom des colonnes du SHP des zones du territoire. Laisser tel quel (en modifiant uniquement MYUSERLINUX)
# pour utiliser les zones du PnEcrins par défaut
zones_shp=/home/`whoami`/atlas/data/ref/zones.shp
colonne_insee=insee
colonne_nom_commune=nom_com
colonne_nom_zone=nom_com

#### TERRITOIRE ####

Expand Down
Loading
Loading