Skip to content

Commit

Permalink
Display currently editing activity. dynamic title
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Jun 26, 2024
1 parent 33e9da2 commit 83a9e59
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
18 changes: 10 additions & 8 deletions lemarche/templates/dashboard/_siae_activity_card.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
</p>
</div>

<div class="col-12 col-lg-4 text-right">
<a href="{% url 'dashboard_siaes:siae_edit_activities_edit' activity.siae.slug activity.id %}" id="siae-activity-edit-btn" class="btn" title="Modifier l'activité">
<i class="ri-pencil-fill ri-xl"></i>
</a>
<a href="#" id="siae-activity-delete-modal-btn" class="btn" data-toggle="modal" data-target="#siae_activity_delete_modal" data-siae-id="{{ activity.siae.id }}" data-siae-slug="{{ activity.siae.slug }}" data-siae-activity-id="{{ activity.id }}" data-siae-activity-name-display="{{ activity.sector_group }}" title="Supprimer l'activité">
<i class="ri-delete-bin-line ri-xl"></i>
</a>
</div>
{% if not hide_actions %}
<div class="col-12 col-lg-4 text-right">
<a href="{% url 'dashboard_siaes:siae_edit_activities_edit' activity.siae.slug activity.id %}" id="siae-activity-edit-btn" class="btn" title="Modifier l'activité">
<i class="ri-pencil-fill ri-xl"></i>
</a>
<a href="#" id="siae-activity-delete-modal-btn" class="btn" data-toggle="modal" data-target="#siae_activity_delete_modal" data-siae-id="{{ activity.siae.id }}" data-siae-slug="{{ activity.siae.slug }}" data-siae-activity-id="{{ activity.id }}" data-siae-activity-name-display="{{ activity.sector_group }}" title="Supprimer l'activité">
<i class="ri-delete-bin-line ri-xl"></i>
</a>
</div>
{% endif %}
</div>
</div>
14 changes: 11 additions & 3 deletions lemarche/templates/dashboard/siae_edit_activities_create.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{% extends "layouts/base.html" %}
{% load static bootstrap4 %}

{% block title %}Ajouter une activité{{ block.super }}{% endblock %}
{% block title %}{{ page_title }}{{ block.super }}{% endblock %}

{% block breadcrumbs %}
<section>
Expand All @@ -13,7 +13,7 @@
<li class="breadcrumb-item"><a href="{{ HOME_PAGE_PATH }}">Accueil</a></li>
<li class="breadcrumb-item"><a href="{% url 'dashboard:home' %}">Tableau de bord</a></li>
<li class="breadcrumb-item" title="{{ siae.name_display }} : modifier"><a href="{% url 'dashboard_siaes:siae_edit_activities' siae.slug %}">{{ siae.name_display }} : modifier</a></li>
<li class="breadcrumb-item active" aria-current="page">Ajouter une activité</li>
<li class="breadcrumb-item active" aria-current="page">{{ page_title }}</li>
</ol>
</nav>
</div>
Expand All @@ -34,10 +34,18 @@

<div class="row mb-3 mb-lg-5">
<div class="col-12">
<h3>Ajouter une activité</h3>
<h3>{{ page_title }}</h3>
</div>
</div>

{% if activity %}
<div class="row mb-3 mb-lg-5">
<div class="col-12 col-lg-8">
{% include "dashboard/_siae_activity_card.html" with activity=activity hide_actions=True %}
</div>
</div>
{% endif %}

<div class="row mb-3 mb-lg-5">
<div class="col-12 col-lg-8">
<div class="bg-white d-block rounded-lg shadow-lg p-3 p-lg-5">
Expand Down
9 changes: 6 additions & 3 deletions lemarche/www/dashboard_siaes/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def form_valid(self, form):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["page_title"] = "Ajouter une activité"
context["siae"] = self.siae
return context

Expand All @@ -191,14 +192,16 @@ def get(self, request, *args, **kwargs):
self.siae = Siae.objects.get(slug=self.kwargs.get("slug"))
return super().get(request, *args, **kwargs)

def get_object(self):
return get_object_or_404(SiaeActivity, siae__slug=self.kwargs.get("slug"), id=self.kwargs.get("activity_id"))

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["page_title"] = "Modifier une activité"
context["siae"] = self.siae
context["activity"] = self.object
return context

def get_object(self):
return get_object_or_404(SiaeActivity, siae__slug=self.kwargs.get("slug"), id=self.kwargs.get("activity_id"))

def get_success_url(self):
return reverse_lazy("dashboard_siaes:siae_edit_activities", args=[self.kwargs.get("slug")])

Expand Down

0 comments on commit 83a9e59

Please sign in to comment.