Skip to content

Commit 561c97b

Browse files
committed
Add choices() static functions to gather common choices
for select boxes. Make BallotInfo's primary key an AutoField. - Legacy-Id: 123
1 parent 2739083 commit 561c97b

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

ietf/idtracker/models.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ class IDState(models.Model):
3535
description = models.TextField(blank=True, db_column='document_desc')
3636
def __str__(self):
3737
return self.state
38+
def choices():
39+
return [(state.document_state_id, state.state) for state in IDState.objects.all()]
40+
choices = staticmethod(choices)
3841
class Meta:
3942
db_table = 'ref_doc_states_new'
4043
class Admin:
@@ -436,7 +439,7 @@ class Meta:
436439
db_table = 'document_comments'
437440

438441
class BallotInfo(models.Model): # Added by Michael Lee
439-
ballot = models.IntegerField(primary_key=True, db_column='ballot_id')
442+
ballot = models.AutoField(primary_key=True, db_column='ballot_id')
440443
active = models.BooleanField()
441444
an_sent = models.BooleanField()
442445
an_sent_date = models.DateField(null=True, blank=True)
@@ -571,6 +574,9 @@ def __str__(self):
571574
return self.group_acronym.acronym
572575
def active_drafts(self):
573576
return self.group_acronym.internetdraft_set.all().filter(status__status="Active")
577+
def choices():
578+
return [(wg.group_acronym_id, wg.group_acronym.acronym) for wg in GroupIETF.objects.all().select_related().order_by('acronym.acronym')]
579+
choices = staticmethod(choices)
574580
class Meta:
575581
db_table = 'groups_ietf'
576582
ordering = ['?'] # workaround django wanting to sort by acronym but not joining with it

0 commit comments

Comments
 (0)