diff --git a/scipost_django/profiles/models.py b/scipost_django/profiles/models.py index 37b45132a7823819d6bd540de49ee60705a17b8a..fb4bc5faeaf2274d0436d4c33d2313b6ce6d565f 100644 --- a/scipost_django/profiles/models.py +++ b/scipost_django/profiles/models.py @@ -126,10 +126,17 @@ class Profile(models.Model): @property def full_name(self): + """The full name: first name + last name.""" return f"{self.first_name} {self.last_name}" + @property + def formal_name(self): + """The formal name: title + last name.""" + return f"{self.get_title_display()} {self.last_name}" + @property def full_name_original(self): + """The full name in original script: first name + last name.""" return f"{self.first_name_original} {self.last_name_original}" @property @@ -154,14 +161,10 @@ class Profile(models.Model): @property def has_active_contributor(self): - has_active_contributor = False try: - has_active_contributor = ( - self.contributor is not None and self.contributor.is_active - ) + return self.contributor is not None and self.contributor.is_active except Contributor.DoesNotExist: - pass - return has_active_contributor + return False def get_absolute_url(self): return reverse("profiles:profile_detail", kwargs={"pk": self.id}) diff --git a/scipost_django/scipost/models.py b/scipost_django/scipost/models.py index 5587a2aa0cc8950c1a11f25e5961c6a3028ab8db..e42cb62411c651725689e0fb06bd5a5ed3088db5 100644 --- a/scipost_django/scipost/models.py +++ b/scipost_django/scipost/models.py @@ -157,7 +157,9 @@ class Contributor(models.Model): Checks if the Contributor is registered, vetted, and has not been deactivated for any reason. """ - return self.user.is_active and self.status == NORMAL_CONTRIBUTOR + # [TypeHint] Coerce to bool since `is_active` is a property of the `AbstractBaseUser` class. + user_active: bool = self.user.is_active + return user_active and self.status == NORMAL_CONTRIBUTOR @property def is_duplicate(self): diff --git a/scipost_django/submissions/models/submission.py b/scipost_django/submissions/models/submission.py index 3a58ab3f6444cf467341cdd4722ae8aad522eb53..dc7c6dbae019b6b5628898d9a9db286a69fef24a 100644 --- a/scipost_django/submissions/models/submission.py +++ b/scipost_django/submissions/models/submission.py @@ -47,13 +47,12 @@ from ..refereeing_cycles import ShortCycle, DirectCycle, RegularCycle if TYPE_CHECKING: from django.db.models.manager import RelatedManager - from submissions.models import EditorialDecision + from submissions.models import EditorialDecision, RefereeInvitation, Report from scipost.models import Contributor from journals.models import Journal, Publication from proceedings.models import Proceedings from iThenticate_report import iThenticateReport from ontology.models import AcademicField, Specialty, Topic - from ..models.referee_invitation import RefereeInvitation from series.models import Collection @@ -258,6 +257,7 @@ class Submission(models.Model): author_profiles: "RelatedManager[SubmissionAuthorProfile]" collections: "RelatedManager[Collection]" editorial_assignments: "RelatedManager[EditorialAssignment]" + reports: "RelatedManager[Report]" # Fields preprint = models.OneToOneField(