Skip to content

Commit

Permalink
add unread tender link and header badge
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienReuiller committed Aug 24, 2023
1 parent 3491225 commit 8929a58
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 48 deletions.
103 changes: 55 additions & 48 deletions lemarche/templates/layouts/_header.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,57 +19,64 @@
<nav role="navigation" id="nav-primary" aria-label="Navigation principale">
<ul>
{% if user.is_authenticated %}
<li>
<a href="{% url 'tenders:create' %}" id="header-demande" class="btn btn-primary btn-ico">
<i class="ri-mail-send-line ri-lg"></i>
<span>Publier un besoin d'achat</span>
</a>
</li>
<li>
<div class="dropdown">
<button class="btn btn-outline-primary dropdown-toggle" id="userDropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Mon espace
</button>
<div class="dropdown-menu" aria-labelledby="userDropdownMenuButton">
<a href="{% url 'dashboard:home' %}" class="dropdown-item">
<i class="ri-dashboard-line"></i>
Tableau de bord
</a>
<a href="{% url 'dashboard_favorites:list' %}" id="header-favorites" class="dropdown-item">
<i class="ri-star-line"></i>
Favoris <span class="badge badge-pill badge-primary fs-xs">{{ user.favorite_list_count }}</span>
</a>
<a href="{% url 'dashboard:profile_edit' %}" class="dropdown-item">
<i class="ri-user-line"></i>
Mon profil
</a>
<div class="dropdown-divider"></div>
<a href="{% url 'auth:logout' %}" class="dropdown-item">
<i class="ri-logout-box-line"></i>
Déconnexion
{% if user.kind == user.KIND_SIAE %}
<li>
<a href="{% url 'tenders:list' %}" class="btn btn-link">
Demandes reçues <span class="badge badge-pill badge-danger fs-xs">{{ user.unread_tender_siae_count }}</span>
</a>
</li>
{% endif %}
<li>
<a href="{% url 'tenders:create' %}" id="header-demande" class="btn btn-primary btn-ico">
<i class="ri-mail-send-line ri-lg"></i>
<span>Publier un besoin d'achat</span>
</a>
</li>
<li>
<div class="dropdown">
<button class="btn btn-outline-primary dropdown-toggle" id="userDropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
Mon espace
</button>
<div class="dropdown-menu" aria-labelledby="userDropdownMenuButton">
<a href="{% url 'dashboard:home' %}" class="dropdown-item">
<i class="ri-dashboard-line"></i>
Tableau de bord
</a>
<a href="{% url 'dashboard_favorites:list' %}" id="header-favorites" class="dropdown-item">
<i class="ri-star-line"></i>
Favoris <span class="badge badge-pill badge-primary fs-xs">{{ user.favorite_list_count }}</span>
</a>
<a href="{% url 'dashboard:profile_edit' %}" class="dropdown-item">
<i class="ri-user-line"></i>
Mon profil
</a>
<div class="dropdown-divider"></div>
<a href="{% url 'auth:logout' %}" class="dropdown-item">
<i class="ri-logout-box-line"></i>
Déconnexion
</a>
</div>
</div>
</div>
</li>
</li>
{% else %}
<li>
<a href="{% url 'tenders:create' %}" id="header-demande" class="btn btn-link btn-ico">
<i class="ri-mail-send-line ri-lg"></i>
<span>Publier un besoin d'achat</span>
</a>
</li>
<li>
<a href="{% url 'auth:signup' %}" id="h_signup" class="btn btn-outline-primary btn-ico">
<i class="ri-user-add-line ri-lg"></i>
<span>S'inscrire</span>
</a>
</li>
<li>
<a href="{% url 'auth:login' %}" id="h_login" class="btn btn-primary btn-ico">
<i class="ri-login-box-line ri-lg"></i>
<span>Se connecter</span>
</a>
</li>
<li>
<a href="{% url 'tenders:create' %}" id="header-demande" class="btn btn-link btn-ico">
<i class="ri-mail-send-line ri-lg"></i>
<span>Publier un besoin d'achat</span>
</a>
</li>
<li>
<a href="{% url 'auth:signup' %}" id="h_signup" class="btn btn-outline-primary btn-ico">
<i class="ri-user-add-line ri-lg"></i>
<span>S'inscrire</span>
</a>
</li>
<li>
<a href="{% url 'auth:login' %}" id="h_login" class="btn btn-primary btn-ico">
<i class="ri-login-box-line ri-lg"></i>
<span>Se connecter</span>
</a>
</li>
{% endif %}
</ul>
</nav>
Expand Down
7 changes: 7 additions & 0 deletions lemarche/templates/layouts/_header_nav_primary_items.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
<ul>
{% if user.is_authenticated %}
{% if user.kind == user.KIND_SIAE %}
<li>
<a href="{% url 'tenders:list' %}" class="btn btn-link">
Demandes reçues <span class="badge badge-pill badge-danger fs-xs">{{ user.unread_tender_siae_count }}</span>
</a>
</li>
{% endif %}
<li>
<a href="{% url 'tenders:create' %}" id="header-demande" class="btn btn-primary btn-ico">
<i class="ri-mail-send-line ri-lg"></i>
Expand Down
9 changes: 9 additions & 0 deletions lemarche/users/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,15 @@ def has_tender_siae(self, tender=None):
qs = qs.filter(tender=tender)
return qs.exists()

@property
def unread_tender_siae_count(self, tender=None):
from lemarche.tenders.models import TenderSiae

qs = TenderSiae.objects.filter(siae__in=self.siaes.all(), tender__validated_at__isnull=False).filter(
detail_display_date__isnull=True
)
return qs.count()


@receiver(post_save, sender=User)
def user_post_save(sender, instance, **kwargs):
Expand Down

0 comments on commit 8929a58

Please sign in to comment.