File tree Expand file tree Collapse file tree 4 files changed +22
-6
lines changed
Expand file tree Collapse file tree 4 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ export function buildHeader(isAuthenticated: boolean) {
9191 label : "Mon compte" ,
9292 shouldDisplay : isAuthenticated ,
9393 subMenu : [
94- { label : "Mes territoires" , url : "/diagnostic/mes-territoires" } ,
94+ { label : "Mes territoires favoris " , url : "/diagnostic/mes-territoires" } ,
9595 { label : "Profil" , url : "/users/profile/" } ,
9696 { label : "Déconnexion" , url : "/users/signout/" } ,
9797 ] ,
Original file line number Diff line number Diff line change 88
99{% block content %}
1010< div class ="fr-container ">
11- < h1 class ="fr-mb-2w "> Mes territoires</ h1 >
11+ < h1 class ="fr-mb-2w "> Mes territoires favoris < span class =" bi bi-star-fill fr-ml-1w " style =" color: #FFD700; " aria-hidden =" true " > </ span > </ h1 >
1212
1313 {% if main_pref %}
1414 < div class ="fr-mb-4w ">
@@ -72,7 +72,6 @@ <h3 class="fr-mb-0">{{ main_pref.land.name }}</h3>
7272 </ div >
7373 {% endif %}
7474
75- < h2 class ="fr-h4 fr-mb-1w "> < span class ="bi bi-star-fill " style ="color: #FFD700; " aria-hidden ="true "> </ span > Territoires favoris</ h2 >
7675 < div class ="fr-grid-row fr-grid-row--gutters ">
7776 {% for pref in preferences %}
7877 {% if pref.land and not pref.is_favorite %}
Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ def get_queryset(self):
4646
4747 def get_context_data (self , ** kwargs ):
4848 context = super ().get_context_data (** kwargs )
49+ from types import SimpleNamespace
50+
4951 from public_data .models import LandModel
5052
5153 for pref in context ["preferences" ]:
@@ -54,8 +56,23 @@ def get_context_data(self, **kwargs):
5456 except LandModel .DoesNotExist :
5557 pref .land = None
5658
57- # Find the favorite pref (main_land) among the already-enriched preferences
58- context ["main_pref" ] = next ((p for p in context ["preferences" ] if p .is_favorite and p .land ), None )
59+ user = self .request .user
60+ main_pref = next ((p for p in context ["preferences" ] if p .is_favorite and p .land ), None )
61+
62+ if not main_pref and user .main_land_type and user .main_land_id :
63+ land = LandModel .objects .filter (land_type = user .main_land_type , land_id = user .main_land_id ).first ()
64+ if land :
65+ main_pref = SimpleNamespace (
66+ land = land ,
67+ target_2031 = None ,
68+ report_count = ReportDraft .objects .filter (
69+ land_type = user .main_land_type ,
70+ land_id = user .main_land_id ,
71+ user = user ,
72+ ).count (),
73+ )
74+
75+ context ["main_pref" ] = main_pref
5976 context ["has_other_favorites" ] = any (p for p in context ["preferences" ] if not p .is_favorite and p .land )
6077
6178 return context
Original file line number Diff line number Diff line change 5050 < div class ="fr-collapse fr-menu " id ="menu-mon-compte ">
5151 < ul class ="fr-menu__list ">
5252 < li >
53- < a class ="fr-nav__link " href ="{% url 'project:list' %} "> Mes territoires</ a >
53+ < a class ="fr-nav__link " href ="{% url 'project:list' %} "> Mes territoires favoris </ a >
5454 </ li >
5555 < li >
5656 < a class ="fr-nav__link " href ="{% url 'users:profile' %} " target ="_self "> Profil</ a >
You can’t perform that action at this time.
0 commit comments