Skip to content

Commit

Permalink
Merge pull request #539 from chris-allan/remove-length-restrictions
Browse files Browse the repository at this point in the history
Fix incorrect maximum length of webadmin and webclient form fields
  • Loading branch information
knabar authored Mar 12, 2024
2 parents 4d8d25e + 3acab1e commit 61f19bb
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 80 deletions.
42 changes: 18 additions & 24 deletions omeroweb/webadmin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,10 @@ def __init__(self, *args, **kwargs):
self.field_order = ["server", "username", "password"]

username = forms.CharField(
max_length=50,
max_length=255,
widget=forms.TextInput(attrs={"size": 22, "autofocus": "autofocus"}),
)
password = forms.CharField(
max_length=50,
widget=forms.PasswordInput(attrs={"size": 22, "autocomplete": "off"}),
)

Expand All @@ -67,7 +66,7 @@ def __init__(self, *args, **kwargs):
super(ForgottonPasswordForm, self).__init__(*args, **kwargs)
self.fields["server"] = ServerModelChoiceField(Server, empty_label=None)
f = forms.CharField(
max_length=50,
max_length=255,
widget=forms.TextInput(attrs={"size": 28, "autocomplete": "off"}),
)
self.fields["username"] = f
Expand Down Expand Up @@ -147,11 +146,9 @@ def __init__(

if "with_password" in kwargs["initial"] and kwargs["initial"]["with_password"]:
self.fields["password"] = forms.CharField(
max_length=50,
widget=forms.PasswordInput(attrs={"size": 30, "autocomplete": "off"}),
)
self.fields["confirmation"] = forms.CharField(
max_length=50,
widget=forms.PasswordInput(attrs={"size": 30, "autocomplete": "off"}),
)

Expand Down Expand Up @@ -239,29 +236,29 @@ def __init__(
field.widget.attrs["disabled"] = True

omename = OmeNameField(
max_length=250,
max_length=255,
widget=forms.TextInput(attrs={"size": 30, "autocomplete": "off"}),
label="Username",
)
first_name = forms.CharField(
max_length=250,
max_length=255,
widget=forms.TextInput(attrs={"size": 30, "autocomplete": "off"}),
)
middle_name = forms.CharField(
max_length=250,
max_length=255,
widget=forms.TextInput(attrs={"size": 30, "autocomplete": "off"}),
required=False,
)
last_name = forms.CharField(
max_length=250,
max_length=255,
widget=forms.TextInput(attrs={"size": 30, "autocomplete": "off"}),
)
email = forms.EmailField(
widget=forms.TextInput(attrs={"size": 30, "autocomplete": "off"}),
required=False,
)
institution = forms.CharField(
max_length=250,
max_length=255,
widget=forms.TextInput(attrs={"size": 30, "autocomplete": "off"}),
required=False,
)
Expand Down Expand Up @@ -334,11 +331,10 @@ def __init__(
self.name_check = name_check
if can_modify_group:
self.fields["name"] = forms.CharField(
max_length=100,
max_length=255,
widget=forms.TextInput(attrs={"size": 25, "autocomplete": "off"}),
)
self.fields["description"] = forms.CharField(
max_length=250,
required=False,
widget=forms.TextInput(attrs={"size": 25, "autocomplete": "off"}),
)
Expand Down Expand Up @@ -470,31 +466,32 @@ def __init__(self, email_check=False, *args, **kwargs):
]

omename = forms.CharField(
max_length=50,
max_length=255,
widget=forms.TextInput(
attrs={"onfocus": "this.blur()", "size": 30, "autocomplete": "off"}
),
label="Username",
)
first_name = forms.CharField(
max_length=250,
max_length=255,
widget=forms.TextInput(attrs={"size": 30, "autocomplete": "off"}),
)
middle_name = forms.CharField(
max_length=250,
max_length=255,
widget=forms.TextInput(attrs={"size": 30, "autocomplete": "off"}),
required=False,
)
last_name = forms.CharField(
max_length=250,
max_length=255,
widget=forms.TextInput(attrs={"size": 30, "autocomplete": "off"}),
)
email = forms.EmailField(
max_length=255,
widget=forms.TextInput(attrs={"size": 30, "autocomplete": "off"}),
required=False,
)
institution = forms.CharField(
max_length=250,
max_length=255,
widget=forms.TextInput(attrs={"size": 30, "autocomplete": "off"}),
required=False,
)
Expand Down Expand Up @@ -547,17 +544,14 @@ def clean_photo(self):

class ChangePassword(forms.Form):
old_password = forms.CharField(
max_length=50,
widget=forms.PasswordInput(attrs={"size": 30, "autocomplete": "off"}),
label="Current password",
)
password = forms.CharField(
max_length=50,
widget=forms.PasswordInput(attrs={"size": 30, "autocomplete": "off"}),
label="New password",
)
confirmation = forms.CharField(
max_length=50,
widget=forms.PasswordInput(attrs={"size": 30, "autocomplete": "off"}),
label="Confirm password",
)
Expand All @@ -578,7 +572,7 @@ def clean_confirmation(self):

class EnumerationEntry(forms.Form):
new_entry = forms.CharField(
max_length=250, widget=forms.TextInput(attrs={"size": 30})
max_length=255, widget=forms.TextInput(attrs={"size": 30})
)


Expand All @@ -589,20 +583,20 @@ def __init__(self, entries, *args, **kwargs):
try:
if kwargs["initial"]["entries"]:
self.fields[str(e.id)] = forms.CharField(
max_length=250,
max_length=255,
initial=e.value,
widget=forms.TextInput(attrs={"size": 30}),
label=i + 1,
)
else:
self.fields[str(e.id)] = forms.CharField(
max_length=250,
max_length=255,
widget=forms.TextInput(attrs={"size": 30}),
label=i + 1,
)
except Exception:
self.fields[str(e.id)] = forms.CharField(
max_length=250,
max_length=255,
widget=forms.TextInput(attrs={"size": 30}),
label=i + 1,
)
Expand Down
Loading

0 comments on commit 61f19bb

Please sign in to comment.