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 0aa0f7d4e2
This commit is contained in:
Henrik Levkowetz 2020-09-01 10:30:55 +00:00
parent d227f1dba6
commit 02bb72d585

View file

@ -24,12 +24,6 @@ from ietf.message.models import Message
from ietf.utils.fields import DatepickerDateField
from ietf.utils.text import dict_to_text
# ----------------------------------------------------------------
# Globals
# ----------------------------------------------------------------
STATE_CHOICES = [ (x.slug, x.name) for x in IprDisclosureStateName.objects.all() ]
STATE_CHOICES.insert(0,('all','All States'))
# ----------------------------------------------------------------
# Base Classes
# ----------------------------------------------------------------
@ -418,7 +412,7 @@ class ThirdPartyIprDisclosureForm(IprDisclosureFormBase):
return obj
class SearchForm(forms.Form):
state = forms.MultipleChoiceField(choices=STATE_CHOICES,widget=forms.CheckboxSelectMultiple,required=False)
state = forms.MultipleChoiceField(choices=[], widget=forms.CheckboxSelectMultiple,required=False)
draft = forms.CharField(label="Draft name", max_length=128, required=False)
rfc = forms.IntegerField(label="RFC number", required=False)
holder = forms.CharField(label="Name of patent owner/applicant", max_length=128,required=False)
@ -427,6 +421,10 @@ class SearchForm(forms.Form):
doctitle = forms.CharField(label="Words in document title", max_length=128,required=False)
iprtitle = forms.CharField(label="Words in IPR disclosure title", max_length=128,required=False)
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.fields['state'].choices = [('all','All States')] + [(n.pk, n.name) for n in IprDisclosureStateName.objects.all()]
class StateForm(forms.Form):
state = forms.ModelChoiceField(queryset=IprDisclosureStateName.objects,label="New State",empty_label=None)
comment = forms.CharField(required=False, widget=forms.Textarea, help_text="You may add a comment to be included in the disclosure history.", strip=False)