Skip to content

Commit

Permalink
Merge pull request #254 from MTES-MCT/fix_n2000_check
Browse files Browse the repository at this point in the history
Corrige le teste auto urba n2000
  • Loading branch information
thibault authored Nov 24, 2023
2 parents 6a449ff + 7965441 commit dd151fc
Showing 1 changed file with 20 additions and 8 deletions.
28 changes: 20 additions & 8 deletions envergo/moulinette/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,15 +277,27 @@ def autorisation_urba_needed(self):
Such an authorization is required if the projet is a "lotissement" or if the
answer to the "autorisation d'urbanisme" question is anything other than "no".
"""
lotissement = self.get_criterion("lotissement")
autorisation_urba = self.get_criterion("autorisation_urba")
try:
lotissement_form = self.get_criterion("lotissement").get_form()
if (
lotissement_form.is_valid()
and lotissement_form.cleaned_data["is_lotissement"] == "oui"
):
return True
except AttributeError:
pass

return any(
(
lotissement and lotissement.result == "soumis",
autorisation_urba and autorisation_urba.result != "non_soumis",
)
)
try:
autor_urba_form = self.get_criterion("autorisation_urba").get_form()
if (
autor_urba_form.is_valid()
and autor_urba_form.cleaned_data["autorisation_urba"] != "none"
):
return True
except AttributeError:
pass

return False

@cached_property
def perimeter(self):
Expand Down

0 comments on commit dd151fc

Please sign in to comment.