Skip to content

Commit

Permalink
Black last version
Browse files Browse the repository at this point in the history
  • Loading branch information
amandine-sahl committed Mar 31, 2023
1 parent a6a894c commit eb50083
Show file tree
Hide file tree
Showing 29 changed files with 11 additions and 151 deletions.
1 change: 0 additions & 1 deletion app/cmd/crypt.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,4 @@
@app.cli.command()
@click.argument("password")
def password_hash(password):

password_hash = generate_password_hash(password.encode("utf-8")).decode("utf-8")
6 changes: 0 additions & 6 deletions app/modules/oeasc/chasse/repositories.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ def chasse_process_args():


def get_attribution_result(params):

columns = GenericTable(
"v_custom_result_attribution", "oeasc_chasse", DB.engine
).tableDef.columns
Expand Down Expand Up @@ -154,7 +153,6 @@ def chasse_get_infos():


def build_chasse_bilan_filters(params, query, tableModel):

# filter query
if params["id_zone_indicative"]:
query = query.filter(
Expand Down Expand Up @@ -290,7 +288,6 @@ def get_plain_text_data(params):


def get_chasse_bilan(params):

query = get_chasse_bilan_realisation(params)
res = query.all()
# 0: nom_saison
Expand Down Expand Up @@ -656,7 +653,6 @@ def get_details(nom_saison, nom_espece, filter={}):


def get_data_export_ods(nom_saison, nom_espece):

columns = GenericTable(
"v_pre_bilan_pretty", "oeasc_chasse", DB.engine
).tableDef.columns
Expand All @@ -678,12 +674,10 @@ def get_data_export_ods(nom_saison, nom_espece):
zcs = []

for r in res:

zc = next(
(item for item in zcs if item["nom"] == r["nom_zone_cynegetique"]), None
)
if not zc:

zc = {
"nom": r["nom_zone_cynegetique"],
"mini": r["nb_attribution_min_zc"] or "",
Expand Down
1 change: 0 additions & 1 deletion app/modules/oeasc/commons/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ def api_communes(test):
@bp.route("files/<string:dir_file>", methods=["GET"])
@json_resp_accept_empty_list
def api_images(dir_file):

"""
renvoie la liste des image du repertoire image
"""
Expand Down
1 change: 0 additions & 1 deletion app/modules/oeasc/declaration/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,6 @@ def random_populate(nb):
"""

for i in range(nb):

declaration_dict = declaration_dict_random_sample()

if not declaration_dict:
Expand Down
3 changes: 0 additions & 3 deletions app/modules/oeasc/declaration/mail.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


def display_mail_test(destinataire):

declaration = declaration_dict_random_sample()

declaration = f_create_or_update_declaration(declaration)
Expand All @@ -32,7 +31,6 @@ def display_mail_test(destinataire):


def send_mail_test():

declaration = declaration_dict_random_sample()

declaration = f_create_or_update_declaration(declaration)
Expand All @@ -50,7 +48,6 @@ def send_mail_validation_declaration(declaration, b_create):
email_user = user["email"]

with mail.connect() as conn:

# on envoie le message à l'utilisateur seulement si c'est une creation
if b_create:
msg = Message(
Expand Down
10 changes: 0 additions & 10 deletions app/modules/oeasc/declaration/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class CorAreasDeclaration(DB.Model):
id_area = DB.Column(DB.Integer, primary_key=True)

def __init__(self, id_area=None):

super(CorAreasDeclaration, self).__init__()
self.id_area = id_area

Expand All @@ -48,7 +47,6 @@ class CorAreasForet(DB.Model):
)

def __init__(self, id_area=None):

super(CorAreasForet, self).__init__()
self.id_area = id_area

Expand All @@ -70,7 +68,6 @@ class CorNomenclatureDeclarationEssenceSecondaire(DB.Model):
)

def __init__(self, id_nomenclature=None):

super(CorNomenclatureDeclarationEssenceSecondaire, self).__init__()
self.id_nomenclature = id_nomenclature

Expand All @@ -92,7 +89,6 @@ class CorNomenclatureDeclarationEssenceComplementaire(DB.Model):
)

def __init__(self, id_nomenclature=None):

super(CorNomenclatureDeclarationEssenceComplementaire, self).__init__()
self.id_nomenclature = id_nomenclature

Expand All @@ -114,7 +110,6 @@ class CorNomenclatureDeclarationMaturite(DB.Model):
)

def __init__(self, id_nomenclature=None):

super(CorNomenclatureDeclarationMaturite, self).__init__()
self.id_nomenclature = id_nomenclature

Expand All @@ -136,7 +131,6 @@ class CorNomenclatureDeclarationOrigine(DB.Model):
)

def __init__(self, id_nomenclature=None):

super(CorNomenclatureDeclarationOrigine, self).__init__()
self.id_nomenclature = id_nomenclature

Expand All @@ -158,7 +152,6 @@ class CorNomenclatureDeclarationProtectionType(DB.Model):
)

def __init__(self, id_nomenclature=None):

super(CorNomenclatureDeclarationProtectionType, self).__init__()
self.id_nomenclature = id_nomenclature

Expand All @@ -180,7 +173,6 @@ class CorNomenclatureDeclarationPaturageType(DB.Model):
)

def __init__(self, id_nomenclature=None):

super(CorNomenclatureDeclarationPaturageType, self).__init__()
self.id_nomenclature = id_nomenclature

Expand All @@ -202,7 +194,6 @@ class CorNomenclatureDeclarationPaturageSaison(DB.Model):
)

def __init__(self, id_nomenclature=None):

super(CorNomenclatureDeclarationPaturageSaison, self).__init__()
self.id_nomenclature = id_nomenclature

Expand All @@ -224,7 +215,6 @@ class CorNomenclatureDeclarationEspece(DB.Model):
)

def __init__(self, id_nomenclature=None):

super(CorNomenclatureDeclarationEspece, self).__init__()
self.id_nomenclature = id_nomenclature

Expand Down
19 changes: 0 additions & 19 deletions app/modules/oeasc/declaration/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,9 @@ def get_foret_type(id_foret):
foret, proprietaire = get_foret(id_foret)

if not foret:

return

if not proprietaire.id_nomenclature_proprietaire_type:

return "Indéterminé"

proprietaire_type = get_nomenclature_from_id(
Expand Down Expand Up @@ -59,19 +57,15 @@ def dfpu_as_dict(declaration, foret, proprietaire, declarant, b_resolve=True):
en dictionnaire
"""
if not declaration:

declaration = TDeclaration()

if not foret:

foret = TForet()

if not proprietaire:

proprietaire = TProprietaire()

if not declarant:

declarant = get_user()

declaration_dict = declaration.as_dict(True)
Expand Down Expand Up @@ -117,11 +111,9 @@ def get_foret(id_foret):
foret = DB.session.query(TForet).filter(id_foret == TForet.id_foret).first()

if foret:

id_proprietaire = foret.id_proprietaire

if id_proprietaire:

proprietaire = (
DB.session.query(TProprietaire)
.filter(id_proprietaire == TProprietaire.id_proprietaire)
Expand All @@ -144,16 +136,13 @@ def get_dfpu(id_declaration):
)

if declaration:

id_declarant = declaration.id_declarant

if id_declarant:

declarant = get_user(id_declarant)
id_foret = declaration.id_foret

if id_foret:

foret, proprietaire = get_foret(id_foret)

return (declaration, foret, proprietaire, declarant)
Expand All @@ -166,7 +155,6 @@ def create_or_modify(model, key, val, dict_in):
elem = None

if key:

elem = DB.session.query(model).filter(getattr(model, key) == val).first()

if elem is None:
Expand Down Expand Up @@ -251,7 +239,6 @@ def f_create_or_update_declaration(declaration_dict):
# on n'écrit la foret ou le proprietaire dans la base
# que dans le cas d'une foret non documentée
if not declaration_dict["foret"]["b_document"]:

id_foret = declaration_dict["foret"].get("id_foret", None)
id_proprietaire = declaration_dict["foret"]["proprietaire"].get(
"id_proprietaire", None
Expand All @@ -273,7 +260,6 @@ def f_create_or_update_declaration(declaration_dict):
declaration_dict["id_foret"] = foret.id_foret

else:

proprietaire = TProprietaire().from_dict(
declaration_dict["foret"]["proprietaire"], True
)
Expand All @@ -283,7 +269,6 @@ def f_create_or_update_declaration(declaration_dict):
# - elle sera crée un fois avec la date courante
# - puis modifiée pour lui donner la date choisie aléatoirement
if declaration_dict.get("meta_create_date", None):

declaration = create_or_modify(
TDeclaration, "id_declaration", id_declaration, declaration_dict
)
Expand Down Expand Up @@ -363,7 +348,6 @@ def get_declarations(
# choix des filtrers selon les droits de l'utilisateur
filters = {}
if user:

# administrateur et animateur >=5
if user["id_droit_max"] >= 5:
pass
Expand Down Expand Up @@ -436,7 +420,6 @@ def add_degats(declarations):
degats_declarations = {}

for deg in data_degats:

dd = degats_declarations.get(deg["id_declaration_degat"])
if not dd:
dd = degats_declarations[deg["id_declaration_degat"]] = []
Expand Down Expand Up @@ -488,7 +471,6 @@ def resume_gravite(declaration_dict):
return
for degat in declaration_dict.get("degats"):
for degat_essence in degat["degat_essences"]:

if not degat_essence["id_nomenclature_degat_gravite"]:
continue

Expand Down Expand Up @@ -537,7 +519,6 @@ def get_declaration_table(declaration_dict):
return get_declaration(declaration_dict["id_declaration"])

else:

d = {}
d["declaration_date"] = declaration_dict.get("meta_create_date") or ""
d["b_autorisation"] = declaration_dict.get("b_autorisation")
Expand Down
1 change: 0 additions & 1 deletion app/modules/oeasc/declaration/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ def route_declarations():
id_declarant = None

if session.get("current_user", None):

id_declarant = session["current_user"]["id_role"]

nomenclature = nomenclature_oeasc()
Expand Down
4 changes: 0 additions & 4 deletions app/modules/oeasc/declaration/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@


def get_areas_from_type_code(areas, type_code):

out = []
if not areas:
return out
Expand Down Expand Up @@ -116,7 +115,6 @@ def check_proprietaire(declaration_dict):
]

if id_declarant_proprietaire:

proprietaire = (
DB.session.query(TProprietaire)
.filter(id_declarant_proprietaire == TProprietaire.id_declarant)
Expand Down Expand Up @@ -190,7 +188,6 @@ def get_listes_essences(declaration):
b_feuillus = True

for elem in nomenclature["OEASC_PEUPLEMENT_ESSENCE"]["values"]:

id = elem["id_nomenclature"]

if id not in listes_essences["selected"]:
Expand Down Expand Up @@ -244,7 +241,6 @@ def get_listes_essences(declaration):


def get_foret_from_name(nom_foret):

data = DB.session.query(TForet).filter(TForet.nom_foret == nom_foret).first()
if not data:
return None
Expand Down
2 changes: 0 additions & 2 deletions app/modules/oeasc/degat_foret/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
@bp.route("proprietaire_from_id_declarant/<int:id_declarant>", methods=["GET"])
@check_auth_redirect_login(1)
def api_get_proprietaire_from_id_declarant(id_declarant):

(proprietaire) = get_proprietaire_from_id_declarant(id_declarant)
out = proprietaire.as_dict(True)

Expand All @@ -40,7 +39,6 @@ def api_get_proprietaire_from_id_declarant(id_declarant):
@bp.route("foret_from_code/<string:code_foret>", methods=["GET"])
@check_auth_redirect_login(1)
def api_get_foret_from_code(code_foret):

(foret, proprietaire) = get_foret_from_code(code_foret)
out = foret.as_dict(True)
out.update(proprietaire.as_dict(True))
Expand Down
3 changes: 0 additions & 3 deletions app/modules/oeasc/degat_foret/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ def create_or_modify(model, key, dict_in):
elem = None

if key:

val = dict_in.get(key, None)
if val:
elem = DB.session.query(model).filter(getattr(model, key) == val).first()
Expand Down Expand Up @@ -108,7 +107,6 @@ def create_or_update_declaration(post_data):
]

if not post_data["b_document"]:

id_declarant = post_data["id_declarant"]

nomenclature = post_data[
Expand Down Expand Up @@ -195,7 +193,6 @@ def get_proprietaire_from_id_declarant(id_declarant):


def get_declarations():

declarations = (
DB.session.query(TDeclaration, TForet, VUsers)
.join(TForet, TForet.id_foret == TDeclaration.id_foret)
Expand Down
1 change: 0 additions & 1 deletion app/modules/oeasc/generic/decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def check_object_type(droit_type):
def check_object_type_(fn):
@wraps(fn)
def check_object_type__(*args, **kwargs):

module_name = kwargs.get("module_name")
object_type = kwargs.get("object_type") or kwargs.get("object_types")[:-1]
current_user = session.get("current_user", {})
Expand Down
1 change: 0 additions & 1 deletion app/modules/oeasc/generic/definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def get_object_type(self, module_name, object_type):
return self.get_module(module_name).get(object_type, {})

def get_model(self, module_name, object_type):

Model = self.get_object_type(module_name, object_type).get("model")

id_field_name = inspect(Model).primary_key[0].name if Model else None
Expand Down

0 comments on commit eb50083

Please sign in to comment.