Skip to content

Commit 02bb72d

Browse files
committed
Merged in [18425] from olau@iola.dk:
Make the IPR search form initialize the state field upon form initialization instead of evaluating the queryset upon importing the module. This is probably never a problem in practice in this case in the live environment, but it's a confusing practice, and when running the tests sometimes a bug seems to throw Django off and the error is then shadowed by Django crashing when trying to access the (non-existing) database. - Legacy-Id: 18454 Note: SVN reference [18425] has been migrated to Git commit 0aa0f7d
1 parent d227f1d commit 02bb72d

1 file changed

Lines changed: 5 additions & 7 deletions

File tree

ietf/ipr/forms.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,6 @@
2424
from ietf.utils.fields import DatepickerDateField
2525
from ietf.utils.text import dict_to_text
2626

27-
# ----------------------------------------------------------------
28-
# Globals
29-
# ----------------------------------------------------------------
30-
STATE_CHOICES = [ (x.slug, x.name) for x in IprDisclosureStateName.objects.all() ]
31-
STATE_CHOICES.insert(0,('all','All States'))
32-
3327
# ----------------------------------------------------------------
3428
# Base Classes
3529
# ----------------------------------------------------------------
@@ -418,7 +412,7 @@ def save(self, *args, **kwargs):
418412
return obj
419413

420414
class SearchForm(forms.Form):
421-
state = forms.MultipleChoiceField(choices=STATE_CHOICES,widget=forms.CheckboxSelectMultiple,required=False)
415+
state = forms.MultipleChoiceField(choices=[], widget=forms.CheckboxSelectMultiple,required=False)
422416
draft = forms.CharField(label="Draft name", max_length=128, required=False)
423417
rfc = forms.IntegerField(label="RFC number", required=False)
424418
holder = forms.CharField(label="Name of patent owner/applicant", max_length=128,required=False)
@@ -427,6 +421,10 @@ class SearchForm(forms.Form):
427421
doctitle = forms.CharField(label="Words in document title", max_length=128,required=False)
428422
iprtitle = forms.CharField(label="Words in IPR disclosure title", max_length=128,required=False)
429423

424+
def __init__(self, *args, **kwargs):
425+
super().__init__(*args, **kwargs)
426+
self.fields['state'].choices = [('all','All States')] + [(n.pk, n.name) for n in IprDisclosureStateName.objects.all()]
427+
430428
class StateForm(forms.Form):
431429
state = forms.ModelChoiceField(queryset=IprDisclosureStateName.objects,label="New State",empty_label=None)
432430
comment = forms.CharField(required=False, widget=forms.Textarea, help_text="You may add a comment to be included in the disclosure history.", strip=False)

0 commit comments

Comments
 (0)