Skip to content
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
11 changes: 11 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
34 changes: 32 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,37 @@ jobs:
backend:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v5
with:
fetch-depth: 0
line-length: 99

- name: Backend code formatting check (Black)
uses: psf/black@stable
with:
use_pyproject: true

frontend:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v5

- name: Use setup-node
uses: actions/setup-node@v5
with:
node-version-file: './atlas/static/.nvmrc'
# cache: 'npm'
# cache-dependency-path: './atlas/static/package-lock.json'

- name: Install dependencies
run: node --version
# working-directory: atlas

- name: Install dependencies
run: npm ci
working-directory: ./atlas/static

- name: Run check with ESLint
run: npm run lint
working-directory: ./atlas/static
2 changes: 1 addition & 1 deletion atlas/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def inject_context():
translations=get_tranlated_labels(),
now=now,
timedelta=timedelta,
page_name=request.endpoint.split(".")[1]
page_name=request.endpoint.split(".")[1],
)

@app.template_filter("pretty")
Expand Down
3 changes: 2 additions & 1 deletion atlas/atlasAPI.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,13 @@ def getObservationsPointAPI():
)
return jsonify(observations)


@api.route("/taxonList", methods=["GET"])
@api.route("/taxonList/area/<id_area>", methods=["GET"])
@api.route("/taxonList/liste/<cd_ref>", methods=["GET"])
@api.route("/taxonList/group/<group_name>", methods=["GET"])
def get_taxon_list(id_area=None, cd_ref=None, group_name=None):
"""
"""
return a list of taxon in html with various filters

Returns
Expand Down
40 changes: 10 additions & 30 deletions atlas/atlasRoutes.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,7 @@ def index():
listTaxons = []
if current_app.config["AFFICHAGE_TERRITOIRE_OBS"]:
nb_taxons = vmTaxonsRepository.get_nb_taxons()
listTaxons = vmTaxonsRepository.getListTaxon(
params={
"page": 0
}
)

listTaxons = vmTaxonsRepository.getListTaxon(params={"page": 0})

# si AFFICHAGE_TERRITOIRE_OBS on charge les données en AJAX
# si AFFICHAGE_DERNIERES_OBS = False, on ne charge pas les obs
Expand All @@ -131,19 +126,19 @@ def index():
observations = []
observations_mailles = None
if current_app.config["AFFICHAGE_DERNIERES_OBS"]:
# on charge les observations point meme si on est en mode maille pour afficher
# on charge les observations point meme si on est en mode maille pour afficher
# la liste des dernières obs
observations = vmObservationsRepository.getObservationsChilds(
params={
"last_obs": str(current_app.config["NB_DAY_LAST_OBS"]) + " day",
"fields": "taxons,medias"
"fields": "taxons,medias",
},
)
if current_app.config["AFFICHAGE_MAILLE"]:
observations_mailles = vmObservationsMaillesRepository.getObservationsMaillesChilds(
params={
"last_obs": str(current_app.config["NB_DAY_LAST_OBS"]) + " day",
"fields": "taxons,ids_obs"
"fields": "taxons,ids_obs",
}
)

Expand Down Expand Up @@ -179,7 +174,7 @@ def index():
personal_data=personal_data,
group2_inpn=group2_inpn,
listTaxons=listTaxons,
nb_taxons=nb_taxons
nb_taxons=nb_taxons,
)


Expand Down Expand Up @@ -316,20 +311,15 @@ def is_statut_in_groupe(statut, groupe):
def area(id_area):
area = vmAreasRepository.getAreaFromIdArea(id_area)
stats_area = vmAreasRepository.getStatsByArea(id_area)
listTaxons = vmTaxonsRepository.getListTaxon(
id_area=id_area,
params=MultiDict({
"page": 0
})
)
listTaxons = vmTaxonsRepository.getListTaxon(id_area=id_area, params=MultiDict({"page": 0}))
group2_inpn = vmTaxonsRepository.get_group_inpn("group2_inpn", id_area)
return render_template(
"templates/areaSheet/_main.html",
stats_area=stats_area,
areaInfos=area,
id_area=id_area,
listTaxons=listTaxons,
group2_inpn=group2_inpn
group2_inpn=group2_inpn,
)


Expand All @@ -340,12 +330,7 @@ def ficheRangTaxonomie(cd_ref=None):
referenciel = vmTaxrefRepository.getInfoFromCd_ref(cd_ref)
taxonomyHierarchy = vmTaxrefRepository.getAllTaxonomy(cd_ref)
observers = vmObservationsRepository.getObservers(cd_ref)
listTaxons = vmTaxonsRepository.getListTaxon(
cd_ref=cd_ref,
params=MultiDict({
"page": 0
})
)
listTaxons = vmTaxonsRepository.getListTaxon(cd_ref=cd_ref, params=MultiDict({"page": 0}))

return render_template(
"templates/taxoRankSheet/_main.html",
Expand All @@ -354,7 +339,7 @@ def ficheRangTaxonomie(cd_ref=None):
referenciel=referenciel,
taxonomyHierarchy=taxonomyHierarchy,
observers=observers,
cd_ref=cd_ref
cd_ref=cd_ref,
)


Expand All @@ -364,12 +349,7 @@ def ficheGroupe(groupe):
groups = vmTaxonsRepository.getAllINPNgroup()
nb_taxons = vmTaxonsRepository.get_nb_taxons(group_name=groupe)
observers = vmObservationsRepository.getGroupeObservers(groupe)
listTaxons = vmTaxonsRepository.getListTaxon(
group_name=groupe,
params=MultiDict({
"page": 0
})
)
listTaxons = vmTaxonsRepository.getListTaxon(group_name=groupe, params=MultiDict({"page": 0}))

return render_template(
"templates/groupSheet/_main.html",
Expand Down
7 changes: 5 additions & 2 deletions atlas/configuration/config_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ class MapConfig(Schema):
load_default={"fill": False, "fillColor": "#020202", "fillOpacity": 0.7}
)


class CouchesSigConfig(Schema):
name = fields.Str(required=True)
type = fields.Str(required=True, validate=validate.OneOf(["wms", "geojson"]))
Expand All @@ -139,7 +140,9 @@ class CouchesSigConfig(Schema):

@validates_schema
def layer_required_for_wms_type(self, data, **kwargs):
if data["type"] == "wms" and (not data.get("options").get("layers") or not data.get("options").get("wms_version")):
if data["type"] == "wms" and (
not data.get("options").get("layers") or not data.get("options").get("wms_version")
):
raise ValidationError("'layers' and 'wms_version' are required for type 'wms'")


Expand Down Expand Up @@ -302,7 +305,7 @@ class Meta:
)
MAP = fields.Nested(MapConfig, load_default=dict())
DEFAULT_LEGEND_DISPLAY = fields.Boolean(load_default=True)
COUCHES_SIG = fields.List(fields.Nested(CouchesSigConfig), load_default=list())
COUCHES_SIG = fields.List(fields.Nested(CouchesSigConfig), load_default=list())
# coupe le nom_vernaculaire à la 1ere virgule sur les fiches espèces
SPLIT_NOM_VERN = fields.Boolean(load_default=True)
INTERACTIVE_MAP_LIST = fields.Boolean(load_default=True)
Expand Down
1 change: 0 additions & 1 deletion atlas/modeles/entities/vmMedias.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ class VmMedias(db.Model):
id_type: Mapped[int] = mapped_column()
licence: Mapped[str] = mapped_column(String(100))
source: Mapped[str] = mapped_column(String(25))

15 changes: 7 additions & 8 deletions atlas/modeles/entities/vmTaxons.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ class VmTaxons(db.Model):
main_media: Mapped[VmMedias] = relationship(
VmMedias,
primaryjoin=and_(
VmMedias.cd_ref == cd_ref,
VmMedias.id_type == current_app.config["ATTR_MAIN_PHOTO"]
VmMedias.cd_ref == cd_ref, VmMedias.id_type == current_app.config["ATTR_MAIN_PHOTO"]
),
)

def as_dict(self, with_main_media=False):
d = {
"cd_ref": self.cd_ref,
Expand All @@ -63,13 +63,13 @@ def as_dict(self, with_main_media=False):
"yearmax": self.yearmax,
"nb_obs": self.nb_obs,
"group2_inpn": utils.deleteAccent(self.group2_inpn),
"group3_inpn": utils.deleteAccent(self.group3_inpn)
"group3_inpn": utils.deleteAccent(self.group3_inpn),
}
if with_main_media:
d["media"] = self.get_main_media()
return d

def get_main_media(self, size=(80,80)):
def get_main_media(self, size=(80, 80)):
"""Get main image of default logo

Parameters
Expand All @@ -83,14 +83,14 @@ def get_main_media(self, size=(80,80)):
The path or url of the main image if exist, the logo of the group INPN if not
"""
default_media = url_for(
'static',
filename=f"images/picto_{utils.deleteAccent(self.group2_inpn).replace(' ', '_') }.png"
"static",
filename=f"images/picto_{utils.deleteAccent(self.group2_inpn).replace(' ', '_') }.png",
)
if self.main_media:
if current_app.config["REDIMENSIONNEMENT_IMAGE"]:
height, width = size
return urljoin(
current_app.config['TAXHUB_URL'],
current_app.config["TAXHUB_URL"],
f"api/tmedias/thumbnail/{self.main_media.id_media}?h={height}&width={width}",
)
else:
Expand All @@ -103,7 +103,6 @@ def get_main_media(self, size=(80,80)):
else:
return default_media


def shorten_name(self):
shorten_nom_vern = self.nom_vern.split(",")[0] if self.nom_vern else ""
return shorten_nom_vern + " | <i>" + self.lb_nom + " </i>"
Expand Down
11 changes: 5 additions & 6 deletions atlas/modeles/repositories/vmAreasRepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,23 +65,22 @@ def getAreaFromIdArea(id_area):
area_dict = {
"areaName": area.area_name,
"areaID": str(area.id_area),
"areaCode" : str(area.area_code),
"areaCode": str(area.area_code),
"areaGeoJson": ast.literal_eval(area.area_geojson),
"typeName": area.type_name,
"description": area.description,
"areasParent": [],
}

subquery = (
db.session.query(VmCorAreas.id_area_parent).filter(VmCorAreas.id_area == id_area).subquery()
db.session.query(VmCorAreas.id_area_parent)
.filter(VmCorAreas.id_area == id_area)
.subquery()
)

areas_parent = (
db.session.query(
VmAreas.area_name,
VmAreas.id_area,
VmAreas.area_code,
VmBibAreasTypes.type_name
VmAreas.area_name, VmAreas.id_area, VmAreas.area_code, VmBibAreasTypes.type_name
)
.join(subquery, subquery.c.id_area_parent == VmAreas.id_area)
.join(VmBibAreasTypes, VmBibAreasTypes.id_type == VmAreas.id_type)
Expand Down
11 changes: 4 additions & 7 deletions atlas/modeles/repositories/vmObservationsMaillesRepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def getObservationsMaillesChilds(params={}):
- last_obs_year : l'année à laquel la dernière observation a été faite dans la maille
- obs_nbr : le nombre d'observation dans la maille
- taxons (optionnel: si fields=taxons) : une liste des taxons dans la maille
- ids_obs (optionnel si fields=ids_obs): la liste des id_observations de la maille
- ids_obs (optionnel si fields=ids_obs): la liste des id_observations de la maille
Parameters
----------
filters : dict, optional
Expand Down Expand Up @@ -70,7 +70,7 @@ def getObservationsMaillesChilds(params={}):
VmAreas.area_geojson,
VMCorMailleObservation.type_code,
func.max(func.date_part("year", VmObservations.dateobs)).label("last_obs_year"),
func.count(VmObservations.id_observation).label("obs_nbr")
func.count(VmObservations.id_observation).label("obs_nbr"),
]
if "taxons" in fields:
query_select.append(
Expand All @@ -90,9 +90,7 @@ def getObservationsMaillesChilds(params={}):
).label("taxons"),
)
if "ids_obs" in fields:
query_select.append(
func.array_agg(VmObservations.id_observation).label("ids_obs")
)
query_select.append(func.array_agg(VmObservations.id_observation).label("ids_obs"))
query = (
select(*query_select)
.select_from(VmObservations)
Expand Down Expand Up @@ -144,10 +142,9 @@ def getObservationsMaillesChilds(params={}):
"nb_observations": int(o.obs_nbr),
"last_observation": o.last_obs_year,
"taxons": o.taxons if "taxons" in fields else None,
"ids_obs": o.ids_obs if "ids_obs" in fields else None
"ids_obs": o.ids_obs if "ids_obs" in fields else None,
},
)
for o in db.session.execute(query).all()
]
)

1 change: 0 additions & 1 deletion atlas/modeles/repositories/vmObservationsRepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@ def getObservationsChilds(params: {}):
return FeatureCollection(features)



def observersParser(req):
setObs = set()
tabObs = list()
Expand Down
1 change: 0 additions & 1 deletion atlas/modeles/repositories/vmTaxonsRepository.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,6 @@ def getAllINPNgroup():
return groupList



def get_group_inpn(group, id_area=None):
column = getattr(VmTaxons, group)
req = select(distinct(column)).select_from(VmTaxons)
Expand Down
2 changes: 1 addition & 1 deletion atlas/static/.nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
14.17.6
22
Loading