Merge pull request #38 from taavi/review-assignments-script

Adds a manage.py script to assign reviewers to talks.
This commit is contained in:
James Tauber 2013-07-03 16:51:47 -07:00
commit 349422fae8
2 changed files with 27 additions and 3 deletions

View 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)

View file

@ -43,6 +43,8 @@ class ReviewAssignment(models.Model):
AUTO_ASSIGNED_INITIAL = 0 AUTO_ASSIGNED_INITIAL = 0
OPT_IN = 1 OPT_IN = 1
AUTO_ASSIGNED_LATER = 2 AUTO_ASSIGNED_LATER = 2
NUM_REVIEWERS = 3
ORIGIN_CHOICES = [ ORIGIN_CHOICES = [
(AUTO_ASSIGNED_INITIAL, "auto-assigned, initial"), (AUTO_ASSIGNED_INITIAL, "auto-assigned, initial"),
@ -66,7 +68,10 @@ class ReviewAssignment(models.Model):
speaker.user_id speaker.user_id
for speaker in speakers for speaker in speakers
if speaker.user_id is not None if speaker.user_id is not None
] ] + [
assignment.user_id
for assignment in ReviewAssignment.objects.filter(
proposal_id=proposal.id)]
).filter( ).filter(
groups__name="reviewers", groups__name="reviewers",
).filter( ).filter(
@ -74,9 +79,11 @@ class ReviewAssignment(models.Model):
).annotate( ).annotate(
num_assignments=models.Count("reviewassignment") num_assignments=models.Count("reviewassignment")
).order_by( ).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( cls._default_manager.create(
proposal=proposal, proposal=proposal,
user=reviewer, user=reviewer,