SciPost Code Repository

Skip to content
Snippets Groups Projects
Commit 19b837d3 authored by Jean-Sébastien Caux's avatar Jean-Sébastien Caux
Browse files

Work on removing profile.discipline

parent 07ee0a3d
No related branches found
No related tags found
No related merge requests found
......@@ -35,29 +35,13 @@ class FellowQuerySet(models.QuerySet):
today = timezone.now().date()
return self.filter(until_date__lt=today)
def specialties_overlap(self, discipline, expertises=[]):
def specialties_overlap(self, specialties_slug_list):
"""
Returns all Fellows specialized in the given discipline
and any of the (optional) expertises.
Returns all Fellows whose specialties overlap with those specified in the slug list.
This method is also separately implemented for Contributor and Profile objects.
"""
qs = self.filter(contributor__profile__discipline=discipline)
if expertises and len(expertises) > 0:
qs = qs.filter(contributor__profile__expertises__overlap=expertises)
return qs
def specialties_contain(self, discipline, expertises=[]):
"""
Returns all Fellows specialized in the given discipline
and all of the (optional) expertises.
This method is also separately implemented for Contributor and Profile objects.
"""
qs = self.filter(contributor__profile__discipline=discipline)
if expertises and len(expertises) > 0:
qs = qs.filter(contributor__profile__expertises__contains=expertises)
return qs
return self.filter(contributor__profile__specialties__slug__in=specialties_slug_list)
def ordered(self):
"""Return ordered queryset explicitly, since this may have big effect on performance."""
......@@ -87,8 +71,9 @@ class FellowQuerySet(models.QuerySet):
class PotentialFellowshipQuerySet(models.QuerySet):
def vote_needed(self, contributor):
college_id_list = [f.college.id for f in contributor.fellowships.regular().active()]
return self.filter(
profile__discipline=contributor.profile.discipline,
college__pk__in=college_id_list,
status=POTENTIAL_FELLOWSHIP_ELECTION_VOTE_ONGOING
).distinct().order_by('profile__last_name')
......
......@@ -82,16 +82,16 @@ def voting_results_display(potfel):
nr_agree = potfel.in_agreement.count()
nr_abstain = potfel.in_abstain.count()
nr_disagree = potfel.in_disagreement.count()
nr_spec_agree = potfel.in_agreement.all().specialties_overlap(
potfel.profile.discipline, potfel.profile.expertises).count()
nr_spec_abstain = potfel.in_abstain.all().specialties_overlap(
potfel.profile.discipline, potfel.profile.expertises).count()
nr_spec_disagree = potfel.in_disagreement.all().specialties_overlap(
potfel.profile.discipline, potfel.profile.expertises).count()
nr_specialists = Fellowship.objects.active().specialties_overlap(
potfel.profile.discipline, potfel.profile.expertises).count()
nr_Fellows = Fellowship.objects.active().specialties_overlap(
potfel.profile.discipline).count()
specialties_slug_list = [s.slug for s in potfel.profile.specialties.all()]
nr_spec_agree = potfel.in_agreement.all(
).specialties_overlap(specialties_slug_list).count()
nr_spec_abstain = potfel.in_abstain.all(
).specialties_overlap(specialties_slug_list).count()
nr_spec_disagree = potfel.in_disagreement.all(
).specialties_overlap(specialties_slug_list).count()
nr_specialists = Fellowship.objects.regular().active(
).specialties_overlap(specialties_slug_list).count()
nr_Fellows = potfel.college.fellowships.regular().active().count()
# Establish whether election criterion has been met.
# Rule is: spec Agree must be >= 3/4 of (total nr of spec - nr abstain)
election_agree_percentage = int(
......
......@@ -44,27 +44,3 @@ class ProfileQuerySet(models.QuerySet):
models.Q(full_name__in=[item['full_name'] for item in duplicates_by_full_name]) |
models.Q(id__in=ids_of_duplicates_by_email)
).order_by('last_name', 'first_name', '-id')
def specialties_overlap(self, discipline, expertises=[]):
"""
Returns all Profiles specialized in the given discipline
and any of the (optional) expertises.
This method is also separately implemented for Contributor and Fellowship objects.
"""
qs = self.filter(discipline=discipline)
if expertises and len(expertises) > 0:
qs = qs.filter(expertises__overlap=expertises)
return qs
def specialties_contain(self, discipline, expertises=[]):
"""
Returns all Profiles specialized in the given discipline
and all of the (optional) expertises.
This method is also separately implemented for Contributor and Fellowship objects.
"""
qs = self.filter(discipline=discipline)
if expertises and len(expertises) > 0:
qs = qs.filter(expertises__contains=expertises)
return qs
......@@ -57,30 +57,6 @@ class ContributorQuerySet(models.QuerySet):
"""TODO: NEEDS UPDATE TO NEW FELLOWSHIP RELATIONS."""
return self.filter(fellowships__isnull=False).distinct()
def specialties_overlap(self, discipline, expertises=[]):
"""
Returns all Contributors specialized in the given discipline
and any of the (optional) expertises.
This method is also separately implemented for Profile and Fellowship objects.
"""
qs = self.filter(profile__discipline=discipline)
if expertises and len(expertises) > 0:
qs = qs.filter(profile__expertises__overlap=expertises)
return qs
def specialties_contain(self, discipline, expertises=[]):
"""
Returns all Contributors specialized in the given discipline
and all of the (optional) expertises.
This method is also separately implemented for Profile and Fellowship objects.
"""
qs = self.filter(profile__discipline=discipline)
if expertises and len(expertises) > 0:
qs = qs.filter(profile__expertises__contains=expertises)
return qs
def with_duplicate_names(self):
"""
Returns only potential duplicate Contributors (as identified by first and
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment