From 5e91eff5c3685d0e49d90c2f7db0ed7bf63c568f Mon Sep 17 00:00:00 2001 From: Julien Corny Date: Mon, 8 Jul 2024 00:00:55 +0200 Subject: [PATCH] linter --- backend/gn_module_zh/forms.py | 8 ++++++- .../9ff769188d93_add_cb_cover_percentage.py | 14 +++++++---- backend/gn_module_zh/model/cards.py | 6 ++--- backend/gn_module_zh/model/zh.py | 9 ++++---- .../tabs/tab3/zh-form-tab3.component.ts | 23 +++++++++---------- 5 files changed, 36 insertions(+), 24 deletions(-) diff --git a/backend/gn_module_zh/forms.py b/backend/gn_module_zh/forms.py index ff8944f3..f6d6d872 100644 --- a/backend/gn_module_zh/forms.py +++ b/backend/gn_module_zh/forms.py @@ -488,7 +488,13 @@ def update_corine_biotopes(id_zh, corine_biotopes): def post_corine_biotopes(id_zh, corine_biotopes): for corine_biotope in corine_biotopes: - DB.session.add(CorZhCb(id_zh=id_zh, lb_code=corine_biotope["corinBio"]["CB_code"], cb_cover=corine_biotope["cbCover"])) + DB.session.add( + CorZhCb( + id_zh=id_zh, + lb_code=corine_biotope["corinBio"]["CB_code"], + cb_cover=corine_biotope["cbCover"], + ) + ) DB.session.flush() diff --git a/backend/gn_module_zh/migrations/9ff769188d93_add_cb_cover_percentage.py b/backend/gn_module_zh/migrations/9ff769188d93_add_cb_cover_percentage.py index e0b57e7c..f4132868 100644 --- a/backend/gn_module_zh/migrations/9ff769188d93_add_cb_cover_percentage.py +++ b/backend/gn_module_zh/migrations/9ff769188d93_add_cb_cover_percentage.py @@ -5,19 +5,25 @@ Create Date: 2024-07-04 15:42:25.691119 """ + from alembic import op import sqlalchemy as sa # revision identifiers, used by Alembic. -revision = '9ff769188d93' -down_revision = '76e89c793961' +revision = "9ff769188d93" +down_revision = "76e89c793961" branch_labels = None depends_on = None def upgrade(): - op.add_column(table_name="cor_zh_cb", column=sa.Column("cb_cover", sa.Integer, nullable=True), schema='pr_zh') + op.add_column( + table_name="cor_zh_cb", + column=sa.Column("cb_cover", sa.Integer, nullable=True), + schema="pr_zh", + ) + def downgrade(): - op.drop_column(table_name="cor_zh_cb", column_name="cb_cover", schema='pr_zh') + op.drop_column(table_name="cor_zh_cb", column_name="cb_cover", schema="pr_zh") diff --git a/backend/gn_module_zh/model/cards.py b/backend/gn_module_zh/model/cards.py index cbb93902..b6e3305a 100644 --- a/backend/gn_module_zh/model/cards.py +++ b/backend/gn_module_zh/model/cards.py @@ -536,9 +536,9 @@ def __str__(self): "code": cb["lb_code"], "label": CorineBiotope(cb["lb_code"]).__str__()["label"], "Humidité": CorineBiotope(cb["lb_code"]).__str__()["Humidité"], - "recouvrement": cb["cb_cover"] - } - for cb in self.cb_codes_corine_biotope + "recouvrement": cb["cb_cover"], + } + for cb in self.cb_codes_corine_biotope ], "remarques": Utils.get_string(self.remark_pres), "ef_area": self.ef_area, diff --git a/backend/gn_module_zh/model/zh.py b/backend/gn_module_zh/model/zh.py index 263745c3..f9370f94 100644 --- a/backend/gn_module_zh/model/zh.py +++ b/backend/gn_module_zh/model/zh.py @@ -53,10 +53,11 @@ def get_id_references(self): def get_cb_codes(self): corine_biotopes = ZH.get_data_by_id(CorZhCb, self.zh.id_zh) - return {"cb_codes_corine_biotope": [ - {"lb_code": cb.lb_code, - "cb_cover":cb.cb_cover} - for cb in corine_biotopes]} + return { + "cb_codes_corine_biotope": [ + {"lb_code": cb.lb_code, "cb_cover": cb.cb_cover} for cb in corine_biotopes + ] + } def get_corine_landcovers(self): landcovers = ZH.get_data_by_id(CorZhCorineCover, self.zh.id_zh) diff --git a/frontend/app/zh-forms/tabs/tab3/zh-form-tab3.component.ts b/frontend/app/zh-forms/tabs/tab3/zh-form-tab3.component.ts index a95a497d..1a1318f8 100755 --- a/frontend/app/zh-forms/tabs/tab3/zh-form-tab3.component.ts +++ b/frontend/app/zh-forms/tabs/tab3/zh-form-tab3.component.ts @@ -26,9 +26,9 @@ export class ZhFormTab3Component implements OnInit { public currentZh: any; corinBioMetaData: any; corinTableCol = [ - { name: 'corinBio', label: 'Code Corine biotopes', subcell: { name: 'CB_code' }}, - { name: 'corinBio', label: 'Libellé Corine biotopes', subcell: { name: 'CB_label' }}, - { name: 'corinBio', label: 'Humidité', size: '5%', subcell: { name: 'CB_humidity' }}, + { name: 'corinBio', label: 'Code Corine biotopes', subcell: { name: 'CB_code' } }, + { name: 'corinBio', label: 'Libellé Corine biotopes', subcell: { name: 'CB_label' } }, + { name: 'corinBio', label: 'Humidité', size: '5%', subcell: { name: 'CB_humidity' } }, { name: 'cbCover', label: 'Recouvrement sur la ZH (%)', size: '5%' }, ]; // subcell : if the data contain a list inside the data list @@ -146,10 +146,10 @@ export class ZhFormTab3Component implements OnInit { this.currentZh.properties.cb_codes_corine_biotope.forEach((cb) => { this.corinBioMetaData.find((item) => { if (item.CB_code == cb.lb_code) { - this.listCorinBio.push({ "corinBio": item, "cbCover": cb.cb_cover }) + this.listCorinBio.push({ corinBio: item, cbCover: cb.cb_cover }); } - }) - }) + }); + }); } this.currentZh.properties.activities.forEach((activity) => { let impacts = []; @@ -268,7 +268,7 @@ export class ZhFormTab3Component implements OnInit { this.canChangeTab.emit(false); this.patchCorinBio = false; this.addModalBtnLabel = 'Ajouter'; - + this.modalTitle = "Ajout d'un habitat Corine Biotopes"; event.stopPropagation(); this.ngbModal.open(modal, { @@ -449,11 +449,10 @@ export class ZhFormTab3Component implements OnInit { this.patchCorinBio = false; this.formCorinSubmitted = true; if (this.corinBioForm.valid) { - this.listCorinBio.push( - { - "corinBio": this.corinBioForm.value.corinBio, - "cbCover": this.corinBioForm.value.cbCover - }); + this.listCorinBio.push({ + corinBio: this.corinBioForm.value.corinBio, + cbCover: this.corinBioForm.value.cbCover, + }); this.ngbModal.dismissAll(); this.corinBioForm.reset(); this.canChangeTab.emit(false);