diff --git a/employee/models.py b/employee/models.py index 161d783b8..279a6f976 100644 --- a/employee/models.py +++ b/employee/models.py @@ -5,6 +5,8 @@ This module is used to register models for employee app """ from datetime import date, datetime +import os +from django.conf import settings from django.db import models from django.contrib.auth.models import User, Permission from django.utils.translation import gettext_lazy as trans @@ -116,7 +118,12 @@ class Employee(models.Model): f"https://ui-avatars.com/api/?name={self.get_full_name()}&background=random" ) if self.employee_profile: - url = self.employee_profile.url + image_url = self.employee_profile.url.split("/media/")[1] + media_root = settings.MEDIA_ROOT + image_path = os.path.join(media_root, image_url) + + if os.path.exists(image_path): + url = self.employee_profile.url return url def __str__(self) -> str: diff --git a/onboarding/templates/onboarding/candidates.html b/onboarding/templates/onboarding/candidates.html index 4bffb9e3b..d67d96eb1 100644 --- a/onboarding/templates/onboarding/candidates.html +++ b/onboarding/templates/onboarding/candidates.html @@ -38,19 +38,11 @@
- {% if candidate.profile %} {{candidate.name}} - {% else %} - {{candidate.name}} - {% endif %}
{{candidate.name}} - {% comment %} {{candidate.joining_date}} {% endcomment %} diff --git a/onboarding/templates/onboarding/dashboard.html b/onboarding/templates/onboarding/dashboard.html index 5dec0d0f2..430a6807e 100644 --- a/onboarding/templates/onboarding/dashboard.html +++ b/onboarding/templates/onboarding/dashboard.html @@ -98,7 +98,7 @@ {{cand}}
{{cand}} diff --git a/onboarding/templates/onboarding/kanban/kanban.html b/onboarding/templates/onboarding/kanban/kanban.html index 21906eab9..a511dd1fa 100644 --- a/onboarding/templates/onboarding/kanban/kanban.html +++ b/onboarding/templates/onboarding/kanban/kanban.html @@ -186,7 +186,7 @@
- Hella +
{{candidate.candidate_id.name}}
diff --git a/onboarding/templates/onboarding/onboarding_table.html b/onboarding/templates/onboarding/onboarding_table.html index 22dcfb1a2..69445c0a3 100644 --- a/onboarding/templates/onboarding/onboarding_table.html +++ b/onboarding/templates/onboarding/onboarding_table.html @@ -181,13 +181,8 @@ />
- {% if candidate.candidate_id.profile %} - - {% else %} - - {% endif %}
{{candidate.candidate_id}} diff --git a/onboarding/templates/onboarding/profile_view.html b/onboarding/templates/onboarding/profile_view.html index 436d6ca6d..9f5013938 100644 --- a/onboarding/templates/onboarding/profile_view.html +++ b/onboarding/templates/onboarding/profile_view.html @@ -54,11 +54,7 @@
- {% if candidate.profile %} - {{candidate.name}} - {% else %} - {{candidate.name}} - {% endif %} + {{candidate.name}}

Welcome Aboard

@@ -91,13 +87,8 @@
- {% if candidate.profile %} - User Photo - {% else %} - User Photo - {% endif %}
- {% if candidate.profile %} - - {% else %} - - {% endif %}
diff --git a/recruitment/models.py b/recruitment/models.py index 5fdb1ba65..4796b8e3c 100644 --- a/recruitment/models.py +++ b/recruitment/models.py @@ -9,6 +9,7 @@ import os import json from django import forms import django +from django.conf import settings from django.db import models from django.core.exceptions import ValidationError from django.utils.translation import gettext_lazy as _ @@ -284,7 +285,13 @@ class Candidate(models.Model): f"https://ui-avatars.com/api/?name={self.get_full_name()}&background=random" ) if self.profile: - url = self.profile.url + image_url = self.profile.url.split("/media/")[1] + media_root = settings.MEDIA_ROOT + + image_path = os.path.join(media_root, image_url) + if os.path.exists(image_path): + url = self.profile.url + return url def tracking(self):