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/update lint #65

Merged
merged 2 commits into from
May 3, 2024
Merged
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
4 changes: 1 addition & 3 deletions backend/gn_module_zh/blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -595,9 +595,7 @@ def get_tab_data(id_tab):
)

# select active geo refs in config
active_geo_refs = [
ref for ref in blueprint.config["ref_geo_referentiels"] if ref["active"]
]
active_geo_refs = [ref for ref in blueprint.config["ref_geo_referentiels"] if ref["active"]]
intersection = None
# Check on geometry that should always exist (PATCH or POST)
if len(form_data["geom"]["geometry"]["coordinates"]) == 0:
Expand Down
10 changes: 4 additions & 6 deletions backend/gn_module_zh/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,7 @@ def update_zh_tab0(form_data, polygon, area, info_role, zh_date, geo_refs):

# update pr_zh.cor_lim_list
id_lim_list, ef_area = (
DB.session.query(TZH.id_lim_list, TZH.ef_area)
.filter(TZH.id_zh == form_data["id_zh"])
.one()
DB.session.query(TZH.id_lim_list, TZH.ef_area).filter(TZH.id_zh == form_data["id_zh"]).one()
)

DB.session.query(CorLimList).filter(CorLimList.id_lim_list == id_lim_list).delete()
Expand Down Expand Up @@ -844,9 +842,9 @@ def update_zh_tab6(data):
TZH.update_author: data["update_author"],
TZH.update_date: data["update_date"],
TZH.is_other_inventory: is_other_inventory,
TZH.remark_is_other_inventory: data["remark_is_other_inventory"]
if is_other_inventory
else None,
TZH.remark_is_other_inventory: (
data["remark_is_other_inventory"] if is_other_inventory else None
),
}
)
DB.session.flush()
Expand Down
6 changes: 3 additions & 3 deletions backend/gn_module_zh/geometry.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ def set_geom(geometry, id_zh=None):
if not id_zh:
id_zh = 0
# SetSRID for POSTGIS < 3.0 compat
polygon = DB.session.query(
func.ST_SetSRID(func.ST_GeomFromGeoJSON(str(geometry)), 4326)
).one()[0]
polygon = DB.session.query(func.ST_SetSRID(func.ST_GeomFromGeoJSON(str(geometry)), 4326)).one()[
0
]
q_zh = (
DB.session.query(TZH)
.filter(
Expand Down
20 changes: 11 additions & 9 deletions backend/gn_module_zh/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,9 +934,11 @@ def __str__(self):
"qualification": self.__get_qualif_mnemo(),
"knowledge": self.__get_knowledge_mnemo(),
"name": self.__get_rule_name(),
"note": Hierarchy.get_str_note(self.note, self.denominator)
if self.active
else "Non paramétrée",
"note": (
Hierarchy.get_str_note(self.note, self.denominator)
if self.active
else "Non paramétrée"
),
}


Expand Down Expand Up @@ -973,9 +975,11 @@ def get_note(value):
filter(
None,
[
(float(item["note"].split("/")[0]))
if item["note"] is not None
else None
(
(float(item["note"].split("/")[0]))
if item["note"] is not None
else None
)
for item in value
if item["active"]
],
Expand Down Expand Up @@ -1213,9 +1217,7 @@ def __check_if_rules(self):
def get_denom(rb_id, col_name):
rb_name = DB.session.query(TRiverBasin).filter(TRiverBasin.id_rb == rb_id).one().name
return getattr(
DB.session.query(RbNotesSummary)
.filter(RbNotesSummary.bassin_versant == rb_name)
.one(),
DB.session.query(RbNotesSummary).filter(RbNotesSummary.bassin_versant == rb_name).one(),
col_name,
)

Expand Down
1 change: 1 addition & 0 deletions backend/gn_module_zh/migrations/01cb1aaa2062_init_zh.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-03-27 11:54:34.602380

"""

import importlib

from alembic import op
Expand Down
1 change: 1 addition & 0 deletions backend/gn_module_zh/migrations/22b14fc3abe0_set_srid.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-04-19 14:58:14.295664

"""

from alembic import op
import sqlalchemy as sa

Expand Down
5 changes: 2 additions & 3 deletions backend/gn_module_zh/migrations/26d6515219fe_add_indexes.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-06-05 12:07:39.416188

"""

from alembic import op
import sqlalchemy as sa

Expand All @@ -20,9 +21,7 @@

def upgrade():
op.create_index("index_t_zh_id_sdage", table_name="t_zh", columns=["id_sdage"], schema=SCHEMA)
op.create_index(
"index_t_zh_id_thread", table_name="t_zh", columns=["id_thread"], schema=SCHEMA
)
op.create_index("index_t_zh_id_thread", table_name="t_zh", columns=["id_thread"], schema=SCHEMA)
op.create_index(
"index_t_zh_id_diag_bio", table_name="t_zh", columns=["id_diag_bio"], schema=SCHEMA
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-05-25 15:33:36.262722

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-06-05 12:20:36.897280

"""

from alembic import op
import sqlalchemy as sa

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Create Date: 2023-03-27 13:32:22.741263

"""

import importlib

from alembic import op
Expand Down
29 changes: 8 additions & 21 deletions backend/gn_module_zh/model/cards.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,7 @@ def __get_author(self, type="authors"):
if getattr(self.zh, type).prenom_role is not None
else ""
)
nom = (
getattr(self.zh, type).nom_role if getattr(self.zh, type).nom_role is not None else ""
)
nom = getattr(self.zh, type).nom_role if getattr(self.zh, type).nom_role is not None else ""
return prenom + " " + nom.upper()

def __get_organism(self, type="authors"):
Expand Down Expand Up @@ -485,8 +483,7 @@ def __str__(self):
return {
"presentation": self.presentation.__str__(),
"espace": [
f"{cd} - {label}"
for cd, label in Utils.get_cd_and_mnemo(self.id_corine_landcovers)
f"{cd} - {label}" for cd, label in Utils.get_cd_and_mnemo(self.id_corine_landcovers)
],
"usage": self.use.__str__(),
"basin": self.basin.__str__(),
Expand Down Expand Up @@ -868,9 +865,7 @@ def hydro(self):
@hydro.setter
def hydro(self, val):
self.__hydro = [
Function(
v["id_function"], v["id_qualification"], v["id_knowledge"], v["justification"]
)
Function(v["id_function"], v["id_qualification"], v["id_knowledge"], v["justification"])
for v in val
]

Expand All @@ -881,9 +876,7 @@ def bio(self):
@bio.setter
def bio(self, value):
self.__bio = [
Function(
v["id_function"], v["id_qualification"], v["id_knowledge"], v["justification"]
)
Function(v["id_function"], v["id_qualification"], v["id_knowledge"], v["justification"])
for v in value
]

Expand Down Expand Up @@ -911,9 +904,7 @@ def interet_patrim(self):
@interet_patrim.setter
def interet_patrim(self, val):
self.__interet_patrim = [
Function(
i["id_function"], i["id_qualification"], i["id_knowledge"], i["justification"]
)
Function(i["id_function"], i["id_qualification"], i["id_knowledge"], i["justification"])
for i in val
]

Expand All @@ -924,18 +915,14 @@ def val_soc_eco(self):
@val_soc_eco.setter
def val_soc_eco(self, val):
self.__val_soc_eco = [
Function(
i["id_function"], i["id_qualification"], i["id_knowledge"], i["justification"]
)
Function(i["id_function"], i["id_qualification"], i["id_knowledge"], i["justification"])
for i in val
]

@interet_patrim.setter
def interet_patrim(self, val):
self.__interet_patrim = [
Function(
i["id_function"], i["id_qualification"], i["id_knowledge"], i["justification"]
)
Function(i["id_function"], i["id_qualification"], i["id_knowledge"], i["justification"])
for i in val
]

Expand Down Expand Up @@ -1092,7 +1079,7 @@ def __set_localisation(self):
self.info.localisation = Localisation(
self.id_zh,
self.properties["geo_info"]["regions"],
self.properties["geo_info"]["departments"]
self.properties["geo_info"]["departments"],
# self.ref_geo_config
)

Expand Down
8 changes: 5 additions & 3 deletions backend/gn_module_zh/model/zh.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,11 @@ def get_instruments(self):
"instruments": [
{
"id_instrument": instrument.id_instrument,
"instrument_date": instrument.instrument_date.date().strftime("%d/%m/%Y")
if instrument.instrument_date
else None,
"instrument_date": (
instrument.instrument_date.date().strftime("%d/%m/%Y")
if instrument.instrument_date
else None
),
}
for instrument in ZH.get_data_by_id(TInstruments, self.zh.id_zh)
]
Expand Down
4 changes: 1 addition & 3 deletions backend/gn_module_zh/model/zh_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -680,9 +680,7 @@ class TActivity(DB.Model):
class TOutflow(DB.Model):
__tablename__ = "t_outflow"
__table_args__ = {"schema": "pr_zh"}
id_outflow = DB.Column(
DB.Integer, ForeignKey(TNomenclatures.id_nomenclature), primary_key=True
)
id_outflow = DB.Column(DB.Integer, ForeignKey(TNomenclatures.id_nomenclature), primary_key=True)
id_zh = DB.Column(DB.Integer, ForeignKey(TZH.id_zh), primary_key=True)
id_permanance = DB.Column(
DB.Integer,
Expand Down
1 change: 1 addition & 0 deletions frontend/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lts/gallium
Empty file added frontend/.prettierignore
Empty file.
6 changes: 5 additions & 1 deletion frontend/.prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,9 @@
"useTabs": false,
"tabWidth": 2,
"semi": true,
"bracketSpacing": true
"bracketSpacing": true,
"trailingComma": "es5",
"singleAttributePerLine": true,
"bracketSameLine": false,
"htmlWhitespaceSensitivity": "ignore"
}
14 changes: 7 additions & 7 deletions frontend/app/services/zh-data.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class ZhDataService {

constructor(
private _api: HttpClient,
public config: ConfigService,
public config: ConfigService
) {}

setCurrentZh(zh: any) {
Expand Down Expand Up @@ -47,7 +47,7 @@ export class ZhDataService {

autocompletBib(search_title: string) {
return this._api.get<any>(
`${this.config.API_ENDPOINT}/zones_humides/references/autocomplete?search_title=${search_title}`,
`${this.config.API_ENDPOINT}/zones_humides/references/autocomplete?search_title=${search_title}`
);
}

Expand All @@ -57,7 +57,7 @@ export class ZhDataService {

getHabitatByCorine(corineId: string) {
return this._api.get<any>(
`${this.config.API_ENDPOINT}/zones_humides/forms/cahierhab/${corineId}`,
`${this.config.API_ENDPOINT}/zones_humides/forms/cahierhab/${corineId}`
);
}

Expand All @@ -72,7 +72,7 @@ export class ZhDataService {
map((municipalities: any) => {
municipalities.map((item) => (item.disabled = false));
return municipalities;
}),
})
);
}

Expand All @@ -82,7 +82,7 @@ export class ZhDataService {

getZhDetails(zhId: number) {
return this._api.get<DetailsModel>(
`${this.config.API_ENDPOINT}/zones_humides/${zhId}/complete_card`,
`${this.config.API_ENDPOINT}/zones_humides/${zhId}/complete_card`
);
}

Expand All @@ -107,7 +107,7 @@ export class ZhDataService {
postMainPicture(zhId: number, mediaId: number) {
return this._api.patch(
`${this.config.API_ENDPOINT}/zones_humides/${zhId}/main_pict/${mediaId}`,
{},
{}
);
}

Expand All @@ -117,7 +117,7 @@ export class ZhDataService {

getHierZh(zhId: string) {
return this._api.get<HierarchyModel>(
`${this.config.API_ENDPOINT}/zones_humides/${zhId}/hierarchy`,
`${this.config.API_ENDPOINT}/zones_humides/${zhId}/hierarchy`
);
}

Expand Down
12 changes: 6 additions & 6 deletions frontend/app/zh-forms/tabs/tab1/zh-form-tab1.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class ZhFormTab1Component implements OnInit {
private _tabService: TabsService,
private _error: ErrorTranslatorService,
public ngbModal: NgbModal,
private _config: ConfigService,
private _config: ConfigService
) {}

ngOnInit() {
Expand Down Expand Up @@ -168,7 +168,7 @@ export class ZhFormTab1Component implements OnInit {
this._toastr.error(frontMsg, '', {
positionClass: 'toast-top-right',
});
},
}
);
}
}
Expand All @@ -182,13 +182,13 @@ export class ZhFormTab1Component implements OnInit {
map((res: any) =>
res.filter((r) => {
return !this.listBib.map((bib) => bib.id_reference).includes(r.id_reference);
}),
})
),
catchError(() => {
return of([]);
}),
),
),
})
)
)
);

formatter = (result: any) => `${result.title}`;
Expand Down
8 changes: 4 additions & 4 deletions frontend/app/zh-forms/tabs/tab3/zh-form-tab3.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -469,8 +469,8 @@ export class ZhFormTab3Component implements OnInit {
a.human_activity.mnemonique.slice(0, 2) > b.human_activity.mnemonique.slice(0, 2)
? 1
: b.human_activity.mnemonique.slice(0, 2) > a.human_activity.mnemonique.slice(0, 2)
? -1
: 0
? -1
: 0
);
}

Expand All @@ -480,8 +480,8 @@ export class ZhFormTab3Component implements OnInit {
a.mnemonique.slice(0, 2) > b.mnemonique.slice(0, 2)
? 1
: b.mnemonique.slice(0, 2) > a.mnemonique.slice(0, 2)
? -1
: 0
? -1
: 0
);
}
return impacts;
Expand Down
Loading
Loading