Merge pull request #38 from taavi/review-assignments-script
Adds a manage.py script to assign reviewers to talks.
This commit is contained in:
commit
349422fae8
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)
|
|
@ -44,6 +44,8 @@ class ReviewAssignment(models.Model):
|
|||
OPT_IN = 1
|
||||
AUTO_ASSIGNED_LATER = 2
|
||||
|
||||
NUM_REVIEWERS = 3
|
||||
|
||||
ORIGIN_CHOICES = [
|
||||
(AUTO_ASSIGNED_INITIAL, "auto-assigned, initial"),
|
||||
(OPT_IN, "opted-in"),
|
||||
|
@ -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