Skip to content

Commit

Permalink
improve UI
Browse files Browse the repository at this point in the history
  • Loading branch information
pyDez committed Jan 16, 2025
1 parent 39781f1 commit 9f26b1d
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 37 deletions.
10 changes: 0 additions & 10 deletions envergo/hedges/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,19 +106,9 @@ def hedges_to_remove_pac(self):
if h.is_on_pac and h.hedge_type != "alignement"
]

def hedges_to_plant_pac(self):
return [
h
for h in self.hedges_to_plant()
if h.is_on_pac and h.hedge_type != "alignement"
]

def lineaire_detruit_pac(self):
return round(sum(h.length for h in self.hedges_to_remove_pac()))

def lineaire_plante_pac(self):
return round(sum(h.length for h in self.hedges_to_plant_pac()))

def lineaire_detruit_pac_including_alignement(self):
return round(sum(h.length for h in self.hedges_to_remove() if h.is_on_pac))

Expand Down
51 changes: 31 additions & 20 deletions envergo/petitions/services.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ def compute_instructor_informations(petition_project, moulinette) -> ProjectDeta

lineaire_total = moulinette.catalog.get("lineaire_total", "")
lineaire_detruit_pac = hedge_data.lineaire_detruit_pac()
lineaire_plante_pac = hedge_data.lineaire_plante_pac()
motif = moulinette.catalog.get("motif", "")
bcae8 = InstructorInformation(
slug="bcae8",
Expand Down Expand Up @@ -170,20 +169,22 @@ def compute_instructor_informations(petition_project, moulinette) -> ProjectDeta
items=[
Item(
"Nombre de tracés plantés",
len(hedge_data.hedges_to_plant_pac()),
len(hedge_data.hedges_to_plant()),
None,
None,
),
Item(
"Total linéaire planté",
hedge_data.lineaire_plante_pac(),
hedge_data.length_to_plant(),
"m",
None,
),
Item(
"Ratio en longueur",
(
round(lineaire_plante_pac / lineaire_detruit_pac, 2)
round(
hedge_data.length_to_plant() / lineaire_detruit_pac, 2
)
if lineaire_detruit_pac > 0
else ""
),
Expand Down Expand Up @@ -213,9 +214,6 @@ def compute_instructor_informations(petition_project, moulinette) -> ProjectDeta
h for h in hedge_data.hedges_to_plant() if h.connexion_boisement
]

hedges_to_remove_under_power_line = [
h for h in hedge_data.hedges_to_remove() if h.sous_ligne_electrique
]
hedges_to_plant_under_power_line = [
h for h in hedge_data.hedges_to_plant() if h.sous_ligne_electrique
]
Expand All @@ -232,13 +230,21 @@ def compute_instructor_informations(petition_project, moulinette) -> ProjectDeta
AdditionalInfo(
label="Destruction",
value=f"{round(sum(h.length for h in hedges_to_remove_near_pond))} m "
f"• {', '.join([h.id for h in hedges_to_remove_near_pond])}",
+ (
f" • {', '.join([h.id for h in hedges_to_remove_near_pond])}"
if hedges_to_remove_near_pond
else ""
),
unit=None,
),
AdditionalInfo(
label="Plantation",
value=f"{round(sum(h.length for h in hedges_to_plant_near_pond))} m "
f"• {', '.join([h.id for h in hedges_to_plant_near_pond])}",
+ (
f" • {', '.join([h.id for h in hedges_to_plant_near_pond])}"
if hedges_to_plant_near_pond
else ""
),
unit=None,
),
],
Expand All @@ -255,13 +261,21 @@ def compute_instructor_informations(petition_project, moulinette) -> ProjectDeta
AdditionalInfo(
label="Destruction",
value=f"{round(sum(h.length for h in hedges_to_remove_woodland_connection))} m "
f"• {', '.join([h.id for h in hedges_to_remove_woodland_connection])}",
+ (
f" • {', '.join([h.id for h in hedges_to_remove_woodland_connection])}"
if hedges_to_remove_woodland_connection
else ""
),
unit=None,
),
AdditionalInfo(
label="Plantation",
value=f"{round(sum(h.length for h in hedges_to_plant_woodland_connection))} m "
f"• {', '.join([h.id for h in hedges_to_plant_woodland_connection])}",
+ (
f" • {', '.join([h.id for h in hedges_to_plant_woodland_connection])}"
if hedges_to_plant_woodland_connection
else ""
),
unit=None,
),
],
Expand All @@ -272,19 +286,16 @@ def compute_instructor_informations(petition_project, moulinette) -> ProjectDeta
Item(
"Proximité ligne électrique",
ItemDetails(
result=len(hedges_to_remove_under_power_line) > 0
or len(hedges_to_plant_under_power_line) > 0,
result=len(hedges_to_plant_under_power_line) > 0,
details=[
AdditionalInfo(
label="Destruction",
value=f"{round(sum(h.length for h in hedges_to_remove_under_power_line))} m "
f"• {', '.join([h.id for h in hedges_to_remove_under_power_line])}",
unit=None,
),
AdditionalInfo(
label="Plantation",
value=f"{round(sum(h.length for h in hedges_to_plant_under_power_line))} m "
f"• {', '.join([h.id for h in hedges_to_plant_under_power_line])}",
+ (
f" • {', '.join([h.id for h in hedges_to_plant_under_power_line])}"
if hedges_to_plant_under_power_line
else ""
),
unit=None,
),
],
Expand Down
4 changes: 2 additions & 2 deletions envergo/petitions/urls_haie.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
urlpatterns = [
path("", PetitionProjectCreate.as_view(), name="petition_project_create"),
path(
"<slug:reference>",
"<slug:reference>/",
PetitionProjectDetail.as_view(),
name="petition_project",
),
# a path that redirects to the petition project detail page without logging the event
path(
"<slug:reference>/auto-redirection",
"<slug:reference>/auto-redirection/",
PetitionProjectAutoRedirection.as_view(),
name="petition_project_auto_redirection",
),
Expand Down
6 changes: 3 additions & 3 deletions envergo/templates/haie/petitions/_items.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,18 @@
{% endif %}
{% if comment %}
<br />
<span class="fr-text--xs">{{ comment }}</span>
<span class="fr-hint-text">{{ comment }}</span>
{% endif %}
{% else %}
<span>
{{ item.value }}
{% if item.unit %}{{ item.unit }}{% endif %}
{% if item.unit and item.value is not None and item.value != "" %}{{ item.unit }}{% endif %}
</span>
{% endif %}

{% if item.comment %}
<br />
<span class="fr-text--xs">{{ item.comment }}</span>
<span class="fr-hint-text">{{ item.comment }}</span>
{% endif %}
</div>
{% endfor %}
6 changes: 4 additions & 2 deletions envergo/templates/haie/petitions/instructor_view.html
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ <h1>Caractéristiques du projet</h1>
{% for information in project_details.details %}
<section class="fr-mt-6w"
{% if information.slug %}id="{{ information.slug }}"{% endif %}>
{% if information.label %}<h2>{{ information.label }}</h2>{% endif %}
{% if information.comment %}<p class="fr-text--xs">{{ information.comment }}</p>{% endif %}
{% if information.label %}<h2 class="fr-mb-0">{{ information.label }}</h2>{% endif %}
<p class="fr-hint-text">
{% if information.comment %}{{ information.comment }}{% endif %}
</p>
{% include "haie/petitions/_items.html" with items=information.items %}
{% if information.details %}
{% for information_details in information.details %}
Expand Down

0 comments on commit 9f26b1d

Please sign in to comment.