Skip to content
This repository has been archived by the owner on Jan 26, 2021. It is now read-only.

Commit

Permalink
Refactor: add constant for magic auteur value
Browse files Browse the repository at this point in the history
  • Loading branch information
ronnix authored and davidbgk committed Apr 21, 2020
1 parent 17532af commit c3562f6
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
6 changes: 5 additions & 1 deletion repondeur/zam_repondeur/models/amendement.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,11 @@ class AmendementLocation(Base):


class Amendement(Base):

AUTEUR_GOUVERNEMENT = "LE GOUVERNEMENT"

VERY_BIG_NUMBER = 999_999_999

__tablename__ = "amendements"
__table_args__ = (
Index("ix_amendements__lecture_pk", "lecture_pk"),
Expand Down Expand Up @@ -465,7 +469,7 @@ def parse_num(text: str) -> Tuple[int, int]:

@reify
def gouvernemental(self) -> bool:
return self.auteur == "LE GOUVERNEMENT"
return self.auteur == Amendement.AUTEUR_GOUVERNEMENT

@reify
def is_withdrawn(self) -> bool:
Expand Down
2 changes: 1 addition & 1 deletion repondeur/zam_repondeur/scripts/enfoncer_colonnes.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ def extract_data_from_csv_file(

# Extraction de l'auteur
if mo.group(2) == "Gouvernement":
auteur = "LE GOUVERNEMENT"
auteur = Amendement.AUTEUR_GOUVERNEMENT
else:
groupe = mo.group(2)

Expand Down
2 changes: 1 addition & 1 deletion repondeur/zam_repondeur/services/fetch/an/amendements.py
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,7 @@ def get_auteur(self) -> str:
if self.raw_auteur is None:
return "Non trouvé"
if self.raw_auteur.get("estGouvernement", "") == "1":
return "LE GOUVERNEMENT"
return Amendement.AUTEUR_GOUVERNEMENT
nom = self.raw_auteur.get("nom", "")
prenom = self.raw_auteur.get("prenom", "")
return f"{nom} {prenom}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def _make_amendement(
is_gouvernemental = extract("signataires", "auteur", "typeAuteur") == "Gouvernement"

if is_gouvernemental:
auteur_name = "LE GOUVERNEMENT"
auteur_name = Amendement.AUTEUR_GOUVERNEMENT
groupe_name = None
matricule = None
else:
Expand Down
2 changes: 1 addition & 1 deletion repondeur/zam_repondeur/visam/views/amendements_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def post(self) -> Response:
.one_or_none()
)

auteur = "LE GOUVERNEMENT" if organisation.is_gouvernement else ""
auteur = Amendement.AUTEUR_GOUVERNEMENT if organisation.is_gouvernement else ""
groupe = organisation.name

max_position = max(
Expand Down

0 comments on commit c3562f6

Please sign in to comment.