Adds a manage.py script to assign reviewers to talks.
Requires that a 'reviewers' group exist, and that there are people assigned to it (otherwise it won't find any reviewers to add!). It will assign up to 3 reviewers, where those reviewers are NOT one of the speakers, and that reviewer has not opted out of reviewing that talk. It will choose random reviewers from those with the fewest existing not-opted-out assignments.
This commit is contained in:
parent
6c1cfd1a53
commit
e180c7f00b
2 changed files with 27 additions and 3 deletions
17
symposion/reviews/management/commands/assign_reviewers.py
Normal file
17
symposion/reviews/management/commands/assign_reviewers.py
Normal file
|
@ -0,0 +1,17 @@
|
|||
import csv
|
||||
import os
|
||||
import random
|
||||
|
||||
from django.contrib.auth import models
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
from symposion.reviews.models import ReviewAssignment
|
||||
from symposion.proposals.models import ProposalBase
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
|
||||
def handle(self, *args, **options):
|
||||
for proposal in ProposalBase.objects.filter(cancelled=0):
|
||||
print "Creating assignments for %s" % (proposal.title,)
|
||||
ReviewAssignment.create_assignments(proposal)
|
|
@ -43,6 +43,8 @@ class ReviewAssignment(models.Model):
|
|||
AUTO_ASSIGNED_INITIAL = 0
|
||||
OPT_IN = 1
|
||||
AUTO_ASSIGNED_LATER = 2
|
||||
|
||||
NUM_REVIEWERS = 3
|
||||
|
||||
ORIGIN_CHOICES = [
|
||||
(AUTO_ASSIGNED_INITIAL, "auto-assigned, initial"),
|
||||
|
@ -66,7 +68,10 @@ class ReviewAssignment(models.Model):
|
|||
speaker.user_id
|
||||
for speaker in speakers
|
||||
if speaker.user_id is not None
|
||||
]
|
||||
] + [
|
||||
assignment.user_id
|
||||
for assignment in ReviewAssignment.objects.filter(
|
||||
proposal_id=proposal.id)]
|
||||
).filter(
|
||||
groups__name="reviewers",
|
||||
).filter(
|
||||
|
@ -74,9 +79,11 @@ class ReviewAssignment(models.Model):
|
|||
).annotate(
|
||||
num_assignments=models.Count("reviewassignment")
|
||||
).order_by(
|
||||
"num_assignments",
|
||||
"num_assignments", "?",
|
||||
)
|
||||
for reviewer in reviewers[:3]:
|
||||
num_assigned_reviewers = ReviewAssignment.objects.filter(
|
||||
proposal_id=proposal.id, opted_out=0).count()
|
||||
for reviewer in reviewers[:max(0, cls.NUM_REVIEWERS - num_assigned_reviewers)]:
|
||||
cls._default_manager.create(
|
||||
proposal=proposal,
|
||||
user=reviewer,
|
||||
|
|
Loading…
Reference in a new issue