Skip to content

Commit

Permalink
Tri des avenants par date de signature (#1480)
Browse files Browse the repository at this point in the history
  • Loading branch information
syldb authored Jul 10, 2024
1 parent 206f49a commit fdbc6a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
6 changes: 2 additions & 4 deletions conventions/services/avenants.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def upload_avenants_for_avenant(
.get(uuid=convention_uuid)
)
avenant_search_service = AvenantListSearchService(
parent_convention, order_by_numero=True
parent_convention, order_by="numero"
)

if request.method == "POST":
Expand Down Expand Up @@ -134,9 +134,7 @@ def complete_avenants_for_avenant(
) -> dict[str, Any]:
avenant = Convention.objects.get(uuid=convention_uuid)
convention_parent = avenant.parent
avenant_search_service = AvenantListSearchService(
avenant.parent, order_by_numero=True
)
avenant_search_service = AvenantListSearchService(avenant.parent, order_by="numero")

avenant_numero = avenant.get_default_convention_number()

Expand Down
4 changes: 3 additions & 1 deletion conventions/services/conventions.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,9 @@ def convention_post_action(request, convention_uuid):
resiliation_date_form = ConventionDateResiliationForm

upform = UploadForm()
avenant_search_service = AvenantListSearchService(convention, order_by_numero=True)
avenant_search_service = AvenantListSearchService(
convention, order_by="televersement_convention_signee_le"
)
total_avenants = convention.avenants.without_denonciation_and_resiliation().count()
denonciation = convention.avenants.filter(avenant_types__nom__in=["denonciation"])
resiliation = convention.avenants.filter(avenant_types__nom__in=["resiliation"])
Expand Down
6 changes: 3 additions & 3 deletions conventions/services/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,13 @@ def paginate(self, size: int | None = None) -> Paginator:
class AvenantListSearchService(ConventionSearchServiceBase):
prefetch = ["programme", "lot"]

def __init__(self, convention: Convention, order_by_numero: bool = False):
def __init__(self, convention: Convention, order_by: str | None = None):
self.convention: Convention = (
convention.parent if convention.is_avenant() else convention
)

if order_by_numero:
self.order_by = "numero"
if order_by:
self.order_by = order_by

def _get_base_queryset(self) -> QuerySet:
return self.convention.avenants.without_denonciation_and_resiliation()
Expand Down

0 comments on commit fdbc6a4

Please sign in to comment.