Skip to content

Commit

Permalink
Merge pull request #392 from MTES-MCT/cleanup_lotissement_criterion
Browse files Browse the repository at this point in the history
Refactoring : nettoyage de l'ancien critère « lotissement »
  • Loading branch information
thibault committed Aug 30, 2024
2 parents 87dabf0 + a5d4df4 commit f7e8bca
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 115 deletions.
2 changes: 1 addition & 1 deletion envergo/analytics/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def test_feedback_sent(mock_notify, _mock_api, client, site):

feedback_url = reverse("feedback_submit")
referer_url = "https://envergo/simulateur/resultat/?created_surface=42&existing_surface=42&lng=-1.77498&lat=47.21452&is_lotissement=oui" # noqa
referer_url = "https://envergo/simulateur/resultat/?created_surface=42&existing_surface=42&lng=-1.77498&lat=47.21452" # noqa
data = {
"useful-feedback": "Oui",
"useful-message": "Ceci n'est pas un message",
Expand Down
58 changes: 11 additions & 47 deletions envergo/moulinette/regulations/natura2000.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,53 +192,6 @@ def evaluate(self):
self._result_code, self._result = result, result


class LotissementForm(forms.Form):
# I sacrificed a frog to the god of bad translations for the right to use
# this variable name. Sorry.
is_lotissement = forms.ChoiceField(
label=_("Le projet concerne-t-il un lotissement ?"),
widget=forms.RadioSelect,
choices=(("oui", "Oui"), ("non", "Non")),
required=True,
)


class Lotissement(CriterionEvaluator):
choice_label = "Natura 2000 > Lotissement"
slug = "lotissement"
form_class = LotissementForm

CODES = [
"soumis_dedans",
"soumis_proximite_immediate",
"non_soumis",
"non_disponible",
]

CODE_MATRIX = {
("oui", "dedans"): "soumis_dedans",
("oui", "proximite_immediate"): "soumis_proximite_immediate",
("non", "dedans"): "non_soumis",
("non", "proximite_immediate"): "non_soumis",
}

RESULT_MATRIX = {
"soumis_dedans": RESULTS.soumis,
"soumis_proximite_immediate": RESULTS.soumis,
"non_soumis": RESULTS.non_soumis,
"non_disponible": RESULTS.non_disponible,
}

def get_result_data(self):
is_lotissement = self.catalog["is_lotissement"]
if self.distance <= 0:
distance = "dedans"
else:
distance = "proximite_immediate"

return is_lotissement, distance


AUTORISATION_URBA_CHOICES = (
("pa", "soumis à permis d'aménager (PA)"),
("pc", "soumis à permis de construire (PC)"),
Expand Down Expand Up @@ -327,6 +280,17 @@ def get_result_code(self, result_data):
return result_code


class LotissementForm(forms.Form):
# I sacrificed a frog to the god of bad translations for the right to use
# this variable name. Sorry.
is_lotissement = forms.ChoiceField(
label=_("Le projet concerne-t-il un lotissement ?"),
widget=forms.RadioSelect,
choices=(("oui", "Oui"), ("non", "Non")),
required=True,
)


class AutorisationUrbanismeExcLotissementForm(
LotissementForm, AutorisationUrbanismeForm
):
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

0 comments on commit f7e8bca

Please sign in to comment.