Skip to content

Commit

Permalink
admin: Replace hardcoded "-" by Django's .get_empty_value_display()
Browse files Browse the repository at this point in the history
  • Loading branch information
rsebille committed Aug 5, 2024
1 parent 4615001 commit 85b7871
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions itou/approvals/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def employee_record_status(self, obj):
if obj.hiring_start_at and obj.hiring_start_at < get_availability_date_for_kind(obj.to_company.kind).date():
return "Date de début du contrat avant l'interopérabilité"

return "-"
return self.get_empty_value_display()


class SuspensionInline(ItouTabularInline):
Expand Down Expand Up @@ -388,7 +388,7 @@ def assigned_company(self, obj):
get_admin_view_link(company, content=company.display_name),
company.siret,
)
return "-"
return self.get_empty_value_display()


class IsInProgressFilter(admin.SimpleListFilter):
Expand Down Expand Up @@ -562,7 +562,7 @@ def denied_reason_explanation(self, obj):
@admin.display(description="actions envisagées")
def denied_proposed_actions(self, obj):
if obj.deny_information.proposed_actions is None:
return "-"
return self.get_empty_value_display()
return "\n".join(obj.deny_information.get_proposed_actions_display())

@admin.display(description="explications des actions envisagées")
Expand Down
6 changes: 3 additions & 3 deletions itou/companies/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def has_change_permission(self, request, obj=None):
@admin.display(description="Liste des PASS IAE pour cette entreprise")
def approvals_list(self, obj):
if obj.pk is None:
return "-"
return self.get_empty_value_display()
url = add_url_params(reverse("admin:approvals_approval_changelist"), {"assigned_company": obj.id, "o": -6})
count = Approval.objects.is_assigned_to(obj.id).count()
valid_count = Approval.objects.is_assigned_to(obj.id).valid().count()
Expand Down Expand Up @@ -366,10 +366,10 @@ def save_model(self, request, obj, form, change):
@admin.display(description="fin de délai de grâce")
def grace_period_end_at(self, obj):
if not obj.deactivated_at:
return "-"
return self.get_empty_value_display()
return display_for_value(
obj.deactivated_at + timezone.timedelta(days=models.SiaeConvention.DEACTIVATION_GRACE_PERIOD_IN_DAYS),
empty_value_display="-",
empty_value_display=self.get_empty_value_display(),
)


Expand Down
10 changes: 5 additions & 5 deletions itou/employee_record/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def last_exchange(self, obj):
@admin.display(description="données SIAE envoyées")
def company_data_sent(self, obj):
if not obj.archived_json:
return "-"
return self.get_empty_value_display()

# Handle older data serialized from the JSON as string
if not isinstance(obj.archived_json, dict):
Expand All @@ -76,7 +76,7 @@ def company_data_sent(self, obj):
@admin.display(description="données candidat envoyées")
def user_data_sent(self, obj):
if not obj.archived_json:
return "-"
return self.get_empty_value_display()

# Handle older data serialized from the JSON as string
if not isinstance(obj.archived_json, dict):
Expand All @@ -90,7 +90,7 @@ def user_data_sent(self, obj):
@admin.display(description="données PASS IAE envoyées")
def approval_data_sent(self, obj):
if not obj.archived_json:
return "-"
return self.get_empty_value_display()

# Handle older data serialized from the JSON as string
if not isinstance(obj.archived_json, dict):
Expand Down Expand Up @@ -234,7 +234,7 @@ def job_seeker_link(self, obj):
if job_seeker := obj.job_application.job_seeker:
return get_admin_view_link(job_seeker, content=job_seeker)

return "-"
return self.get_empty_value_display()

@admin.display(description="profil du salarié")
def job_seeker_profile_link(self, obj):
Expand All @@ -247,7 +247,7 @@ def asp_processing_type(self, obj):
return "Intégrée par les emplois suite à une erreur 3436 (doublon PASS IAE/SIRET)"
if obj.asp_processing_code == obj.ASP_PROCESSING_SUCCESS_CODE:
return "Intégrée par l'ASP"
return "-"
return self.get_empty_value_display()

def has_add_permission(self, request):
return False
Expand Down
8 changes: 4 additions & 4 deletions itou/siae_evaluations/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ def id_link(self, obj):
def approval(self, obj):
if obj.job_application.approval:
return obj.job_application.approval.number
return "-"
return self.get_empty_value_display()

def job_seeker(self, obj):
if obj.job_application.job_seeker:
return obj.job_application.job_seeker
return "-"
return self.get_empty_value_display()


class EvaluatedAdministrativeCriteriaInline(ItouTabularInline):
Expand Down Expand Up @@ -268,12 +268,12 @@ def state(self, obj):
def approval(self, obj):
if obj.job_application.approval:
return obj.job_application.approval.number
return "-"
return self.get_empty_value_display()

def job_seeker(self, obj):
if obj.job_application.job_seeker:
return obj.job_application.job_seeker
return "-"
return self.get_empty_value_display()


@admin.register(models.EvaluatedAdministrativeCriteria)
Expand Down

0 comments on commit 85b7871

Please sign in to comment.