Fix the problem that horizon launch fails due to python3-django upgrade

fb4c55d9ec
This commit disables FileInput for uploading multiple files
directly and introduces a new method as a replacement.
the upgrade of python3-django from 2:2.2.28-1~deb11u1 to
2:2.2.28-1~deb11u2 includes this commit.
Refer to the method introduced in the commit to replace
the previous usage.

Test Plan
PASS: build-pkgs -c -p starlingx-dashboard && build-image
PASS: jenkins installation successfuly
PASS: horizon.service can been successfully loaded and restarted
      with python3-django 2:2.2.28-1~deb11u2

Closes-Bug: 2030473

Depends-On: https://review.opendev.org/c/starlingx/tools/+/894257

Change-Id: I5e07f3ec7e02090f1a04038c768a7e657131934e
Signed-off-by: Wentao Zhang <wentao.zhang@windriver.com>
This commit is contained in:
Wentao Zhang 2023-09-08 13:49:12 +08:00
parent 54a0486661
commit b724f037f8
1 changed files with 6 additions and 1 deletions

View File

@ -6,6 +6,7 @@
import logging
from django.forms import FileInput
from django.urls import reverse # noqa
from django.utils.translation import ugettext_lazy as _
@ -17,10 +18,14 @@ from starlingx_dashboard import api as stx_api
LOG = logging.getLogger(__name__)
class MultipleFileInput(FileInput):
allow_multiple_selected = True
class UploadPatchForm(forms.SelfHandlingForm):
failure_url = 'horizon:admin:software_management:index'
patch_files = forms.FileField(label=_("Patch File(s)"),
widget=forms.FileInput(attrs={
widget=MultipleFileInput(attrs={
'data-source-file': _('Patch File(s)'),
'multiple': "multiple"}),
required=True)