-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ajoute la possibilité de filtrer par type
Ajoute la possibilité de filtrer par type de document sur une fiche détection. - Ajoute django-filters pour faciliter la gestion des filtres sur le long terme - Ajoute une deuxième type de document pour pouvoir tester le filtre - Ouverture du bon onglet si on est en train de manipuler les documents (approche assez naïve)
- Loading branch information
Showing
11 changed files
with
113 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import django_filters | ||
from django.forms import forms | ||
|
||
from .models import Document | ||
from .forms import DSFRForm | ||
|
||
|
||
class FilterForm(DSFRForm, forms.Form): | ||
pass | ||
|
||
|
||
class DocumentFilter(django_filters.FilterSet): | ||
class Meta: | ||
model = Document | ||
fields = [ | ||
"document_type", | ||
] | ||
form = FilterForm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Generated by Django 5.0.3 on 2024-07-10 14:47 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("core", "0006_document"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="document", | ||
name="document_type", | ||
field=models.CharField( | ||
choices=[("cartographie", "Cartographie"), ("autre", "Autre document")], | ||
max_length=100, | ||
verbose_name="Type de document", | ||
), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,33 @@ | ||
<div class="fr-btns-group--right fr-mb-2w"> | ||
<button class="fr-btn fr-btn--secondary fr-btn--icon-left fr-icon-add-circle-line" data-testid="documents-add" data-fr-opened="false" aria-controls="fr-modal-add-doc"> | ||
Ajouter un document | ||
</button> | ||
</div> | ||
<div class="fr-container--fluid fr-mb-4w" id="documents"> | ||
<div class="fr-grid-row"> | ||
<div class="fr-col-4"> | ||
<form method="get" action="#documents" class="documents__filters"> | ||
{{ document_filter.form.as_dsfr_div }} | ||
<p class="fr-my-2w fr-ml-2w"> <button type="submit" class="fr-btn" data-testid="documents-filter">Filtrer</button></p> | ||
</form> | ||
|
||
{% include "core/_modale_ajout_document.html" %} | ||
<div class="fr-container--fluid"> | ||
<div class="fr-grid-row fr-grid-row--gutters"> | ||
{% for document in document_list %} | ||
<div class="fr-col-3 fr-col-xl-2"> | ||
{% include "core/_carte_resume_document.html" %} | ||
</div> | ||
<div class="fr-col-5"></div> | ||
<div class="fr-col-3"> | ||
<div class="fr-btns-group--right fr-mt-3w"> | ||
<button class="fr-btn fr-btn--secondary fr-btn--icon-left fr-icon-add-circle-line" data-testid="documents-add" data-fr-opened="false" aria-controls="fr-modal-add-doc"> | ||
Ajouter un document | ||
</button> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
</div> | ||
</div> | ||
{% include "core/_modale_ajout_document.html" %} | ||
<div class="fr-container--fluid"> | ||
{% if document_filter.qs %} | ||
<div class="fr-grid-row fr-grid-row--gutters"> | ||
{% for document in document_filter.qs %} | ||
<div class="fr-col-3 fr-col-xl-2"> | ||
{% include "core/_carte_resume_document.html" %} | ||
</div> | ||
{% endfor %} | ||
</div> | ||
{% else %} | ||
<p>Aucun document</p> | ||
{% endif %} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,4 +13,5 @@ pytest-playwright | |
djhtml | ||
model-bakery | ||
sentry-sdk[django] | ||
django-storages[s3] | ||
django-storages[s3] | ||
django-filter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,3 +25,7 @@ | |
.document__actions a { | ||
background-image: none; | ||
} | ||
.documents__filters { | ||
display:flex; | ||
align-items: end; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters