2727 DocRelationshipName , DocReminderTypeName , BallotPositionName , ReviewRequestStateName , ReviewAssignmentStateName , FormalLanguageName ,
2828 DocUrlTagName )
2929from ietf .person .models import Email , Person
30- from ietf .person .utils import get_active_ads
30+ from ietf .person .utils import get_active_balloteers
3131from ietf .utils import log
3232from ietf .utils .admin import admin_link
3333from ietf .utils .decorators import memoize
@@ -656,7 +656,7 @@ def filename_with_rev(self):
656656
657657 def latest_event (self , * args , ** filter_args ):
658658 """Get latest event of optional Python type and with filter
659- arguments, e.g. d.latest_event(type="xyz") returns an DocEvent
659+ arguments, e.g. d.latest_event(type="xyz") returns a DocEvent
660660 while d.latest_event(WriteupDocEvent, type="xyz") returns a
661661 WriteupDocEvent event."""
662662 model = args [0 ] if args else DocEvent
@@ -1082,36 +1082,36 @@ class Meta:
10821082class BallotDocEvent (DocEvent ):
10831083 ballot_type = ForeignKey (BallotType )
10841084
1085- def active_ad_positions (self ):
1086- """Return dict mapping each active AD to a current ballot position (or None if they haven't voted)."""
1085+ def active_balloteer_positions (self ):
1086+ """Return dict mapping each active AD or IRSG member to a current ballot position (or None if they haven't voted)."""
10871087 res = {}
10881088
1089- active_ads = get_active_ads ( )
1090- positions = BallotPositionDocEvent .objects .filter (type = "changed_ballot_position" ,ad__in = active_ads , ballot = self ).select_related ('ad ' , 'pos' ).order_by ("-time" , "-id" )
1089+ active_balloteers = get_active_balloteers ( self . ballot_type )
1090+ positions = BallotPositionDocEvent .objects .filter (type = "changed_ballot_position" ,pos_by__in = active_balloteers , ballot = self ).select_related ('pos_by ' , 'pos' ).order_by ("-time" , "-id" )
10911091
10921092 for pos in positions :
1093- if pos .ad not in res :
1094- res [pos .ad ] = pos
1093+ if pos .pos_by not in res :
1094+ res [pos .pos_by ] = pos
10951095
1096- for ad in active_ads :
1097- if ad not in res :
1098- res [ad ] = None
1096+ for balloteer in active_balloteers :
1097+ if balloteer not in res :
1098+ res [balloteer ] = None
10991099 return res
11001100
11011101 def all_positions (self ):
11021102 """Return array holding the current and past positions per AD"""
11031103
11041104 positions = []
11051105 seen = {}
1106- active_ads = get_active_ads ( )
1107- for e in BallotPositionDocEvent .objects .filter (type = "changed_ballot_position" , ballot = self ).select_related ('ad ' , 'pos' ).order_by ("-time" , '-id' ):
1108- if e .ad not in seen :
1109- e .old_ad = e .ad not in active_ads
1106+ active_balloteers = get_active_balloteers ( self . ballot_type )
1107+ for e in BallotPositionDocEvent .objects .filter (type = "changed_ballot_position" , ballot = self ).select_related ('pos_by ' , 'pos' ).order_by ("-time" , '-id' ):
1108+ if e .pos_by not in seen :
1109+ e .old_pos_by = e .pos_by not in active_balloteers
11101110 e .old_positions = []
11111111 positions .append (e )
1112- seen [e .ad ] = e
1112+ seen [e .pos_by ] = e
11131113 else :
1114- latest = seen [e .ad ]
1114+ latest = seen [e .pos_by ]
11151115 if latest .old_positions :
11161116 prev = latest .old_positions [- 1 ]
11171117 else :
@@ -1126,25 +1126,27 @@ def all_positions(self):
11261126 while p .old_positions and p .old_positions [- 1 ].slug == "norecord" :
11271127 p .old_positions .pop ()
11281128
1129- # add any missing ADs through fake No Record events
1129+ # add any missing ADs/IRSGers through fake No Record events
11301130 if self .doc .active_ballot () == self :
11311131 norecord = BallotPositionName .objects .get (slug = "norecord" )
1132- for ad in active_ads :
1133- if ad not in seen :
1134- e = BallotPositionDocEvent (type = "changed_ballot_position" , doc = self .doc , rev = self .doc .rev , ad = ad )
1135- e .by = ad
1132+ for balloteer in active_balloteers :
1133+ if balloteer not in seen :
1134+ e = BallotPositionDocEvent (type = "changed_ballot_position" , doc = self .doc , rev = self .doc .rev , pos_by = balloteer )
1135+ e .by = balloteer
11361136 e .pos = norecord
1137- e .old_ad = False
1137+ e .old_pos_by = False
11381138 e .old_positions = []
11391139 positions .append (e )
11401140
1141- positions .sort (key = lambda p : (p .old_ad , p .ad .last_name ()))
1141+ positions .sort (key = lambda p : (p .old_pos_by , p .pos_by .last_name ()))
11421142 return positions
11431143
1144+ class IRSGBallotDocEvent (BallotDocEvent ):
1145+ duedate = models .DateTimeField (blank = True , null = True )
11441146
11451147class BallotPositionDocEvent (DocEvent ):
11461148 ballot = ForeignKey (BallotDocEvent , null = True , default = None ) # default=None is a temporary migration period fix, should be removed when charter branch is live
1147- ad = ForeignKey (Person )
1149+ pos_by = ForeignKey (Person )
11481150 pos = ForeignKey (BallotPositionName , verbose_name = "position" , default = "norecord" )
11491151 discuss = models .TextField (help_text = "Discuss text if position is discuss" , blank = True )
11501152 discuss_time = models .DateTimeField (help_text = "Time discuss text was written" , blank = True , null = True )
0 commit comments