jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/373708 )
Change subject: Break in-process cache of model choice fields ...................................................................... Break in-process cache of model choice fields ChoiceFields which are initial as class variables will (may?) cache results for the lifetime of the python execution environment. To break this cache, use the __init__ method of the form instance to reset the queryset used for validation. Bug: T173963 Change-Id: Ia795114642328e8958f18c79c3d7c0dbfd9348af --- M striker/tools/forms.py 1 file changed, 13 insertions(+), 5 deletions(-) Approvals: BryanDavis: Looks good to me, approved jenkins-bot: Verified diff --git a/striker/tools/forms.py b/striker/tools/forms.py index 3e7d496..97c946f 100644 --- a/striker/tools/forms.py +++ b/striker/tools/forms.py @@ -266,8 +266,7 @@ ), ) license = forms.ModelChoiceField( - queryset=SoftwareLicense.objects.filter( - osi_approved=True).order_by('-recommended', 'slug'), + queryset=SoftwareLicense.objects.none(), empty_label=_('-- Choose your software license --'), label=_('Default software license'), help_text=_( @@ -276,12 +275,19 @@ ).format(choose_a_license='https://choosealicense.com/'), ) tags = forms.ModelMultipleChoiceField( - queryset=ToolInfoTag.objects.all().order_by('name'), + queryset=ToolInfoTag.objects.none(), widget=autocomplete.ModelSelect2Multiple( url='tools:tags_autocomplete', ), required=False, ) + + def __init__(self, *args, **kwargs): + super(ToolCreateForm, self).__init__(*args, **kwargs) + self.fields['license'].queryset = SoftwareLicense.objects.filter( + osi_approved=True).order_by('-recommended', 'slug') + self.fields['tags'].queryset = ToolInfoTag.objects.all().order_by( + 'name') def clean_name(self): """Validate that name is available.""" @@ -305,13 +311,13 @@ @parsleyfy class MaintainersForm(forms.Form): maintainers = MaintainerChoiceField( - queryset=Maintainer.objects.all(), + queryset=Maintainer.objects.none(), widget=autocomplete.ModelSelect2Multiple( url='tools:api:maintainer', ), ) tools = forms.ModelMultipleChoiceField( - queryset=ToolUser.objects.all(), + queryset=ToolUser.objects.none(), widget=autocomplete.ModelSelect2Multiple( url='tools:api:tooluser', ), @@ -332,3 +338,5 @@ initial['tools'] = tool.tool_member_ids() kwargs['initial'] = initial super(MaintainersForm, self).__init__(*args, **kwargs) + self.fields['maintainers'].queryset = Maintainer.objects.all() + self.fields['tools'].queryset = ToolUser.objects.all() -- To view, visit https://gerrit.wikimedia.org/r/373708 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: Ia795114642328e8958f18c79c3d7c0dbfd9348af Gerrit-PatchSet: 1 Gerrit-Project: labs/striker Gerrit-Branch: master Gerrit-Owner: BryanDavis <bda...@wikimedia.org> Gerrit-Reviewer: BryanDavis <bda...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits