diff --git a/core/models/profiles.py b/core/models/profiles.py index e28f852a..83ce157a 100644 --- a/core/models/profiles.py +++ b/core/models/profiles.py @@ -514,8 +514,15 @@ def fetch_cvs(self): @cached_property def has_children(self): """check if the object has 1 to many related objects (skill_set, education_set...)""" + return self.has_children_exclude() + + def has_children_exclude(self, exclude: str | list = []): + links = [rel.get_accessor_name() for rel in self._meta.related_objects] + if isinstance(exclude, str): + exclude = [exclude] + for e in exclude: + links.remove(e) - links = (rel.get_accessor_name() for rel in self._meta.related_objects) return any(getattr(self, link).exists() for link in links) def save(self, *args, **kwargs): diff --git a/core/tasks.py b/core/tasks.py index 538c730f..13a684b7 100644 --- a/core/tasks.py +++ b/core/tasks.py @@ -29,7 +29,7 @@ def notify_to_complete_profile(): # Collect emails depending on the profile completion profiles_to_email = [] for p in profiles: - if not p.has_children: + if not p.has_children_exclude("cv_set"): profiles_to_email.append(p) # Send emails diff --git a/core/views/languages.py b/core/views/languages.py index aa67ee0e..3196ba64 100644 --- a/core/views/languages.py +++ b/core/views/languages.py @@ -15,10 +15,7 @@ def switch_language(request): try: page = Page.objects.get(id=request.POST.get("wagtail_page_id")) except (Page.DoesNotExist, ValueError): - messages.error( - request, - _("We did not find the requested page."), - ) + messages.error(request, _("We did not find the requested page.")) post["next"] = "/" request.POST = post return set_language(request) @@ -28,8 +25,7 @@ def switch_language(request): post["next"] = page.get_translation(locale).url except (Page.DoesNotExist, Locale.DoesNotExist): messages.warning( - request, - _("Page not available in the requested language."), + request, _("Page not available in the requested language.") ) return set_language(request)