Skip to content

Commit

Permalink
Merge pull request #473 from sbesson/nonasciiform_cleanup
Browse files Browse the repository at this point in the history
Deprecate omeroweb.custom_forms.NonASCIIForm
  • Loading branch information
knabar authored May 31, 2023
2 parents 2c0b255 + 8f6493a commit ac5e4cc
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 18 deletions.
6 changes: 6 additions & 0 deletions omeroweb/custom_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,22 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#

import warnings
from past.builtins import basestring
from django import forms
from django.utils.encoding import smart_str

from django.forms.utils import ErrorDict, ValidationError
from django.forms.fields import FileField, CharField

DEPRECATION_MESSAGE = (
"This form is deprecated as of OMERO.web 5.21.0. Use Django's" "forms.Form instead."
)


class NonASCIIForm(forms.Form):
def __init__(self, *args, **kwargs):
warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)
super(NonASCIIForm, self).__init__(*args, **kwargs)

def full_clean(self):
Expand Down
20 changes: 9 additions & 11 deletions omeroweb/webadmin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

from omeroweb.connector import Server

from omeroweb.custom_forms import NonASCIIForm

from .custom_forms import ServerModelChoiceField, GroupModelChoiceField
from .custom_forms import GroupModelMultipleChoiceField, OmeNameField
from .custom_forms import ExperimenterModelMultipleChoiceField, MultiEmailField
Expand All @@ -45,7 +43,7 @@
# Non-model Form


class LoginForm(NonASCIIForm):
class LoginForm(forms.Form):
def __init__(self, *args, **kwargs):
super(LoginForm, self).__init__(*args, **kwargs)
self.fields["server"] = ServerModelChoiceField(Server, empty_label=None)
Expand All @@ -67,7 +65,7 @@ def clean_username(self):
return self.cleaned_data["username"]


class ForgottonPasswordForm(NonASCIIForm):
class ForgottonPasswordForm(forms.Form):
def __init__(self, *args, **kwargs):
super(ForgottonPasswordForm, self).__init__(*args, **kwargs)
self.fields["server"] = ServerModelChoiceField(Server, empty_label=None)
Expand All @@ -88,7 +86,7 @@ def __init__(self, *args, **kwargs):
)


class ExperimenterForm(NonASCIIForm):
class ExperimenterForm(forms.Form):
def __init__(
self,
name_check=False,
Expand Down Expand Up @@ -324,7 +322,7 @@ def clean_other_groups(self):
)


class GroupForm(NonASCIIForm):
class GroupForm(forms.Form):
def __init__(
self,
name_check=False,
Expand Down Expand Up @@ -448,7 +446,7 @@ def __init__(self, *args, **kwargs):
)


class MyAccountForm(NonASCIIForm):
class MyAccountForm(forms.Form):
def __init__(self, email_check=False, *args, **kwargs):
super(MyAccountForm, self).__init__(*args, **kwargs)
self.email_check = email_check
Expand Down Expand Up @@ -510,7 +508,7 @@ def clean_email(self):
return self.cleaned_data.get("email")


class ContainedExperimentersForm(NonASCIIForm):
class ContainedExperimentersForm(forms.Form):
def __init__(self, *args, **kwargs):
super(ContainedExperimentersForm, self).__init__(*args, **kwargs)

Expand Down Expand Up @@ -550,7 +548,7 @@ def clean_photo(self):
return self.cleaned_data.get("photo")


class ChangePassword(NonASCIIForm):
class ChangePassword(forms.Form):
old_password = forms.CharField(
max_length=50,
widget=forms.PasswordInput(attrs={"size": 30, "autocomplete": "off"}),
Expand Down Expand Up @@ -581,13 +579,13 @@ def clean_confirmation(self):
return self.cleaned_data.get("password")


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


class EnumerationEntries(NonASCIIForm):
class EnumerationEntries(forms.Form):
def __init__(self, entries, *args, **kwargs):
super(EnumerationEntries, self).__init__(*args, **kwargs)
for i, e in enumerate(entries):
Expand Down
13 changes: 6 additions & 7 deletions omeroweb/webclient/forms.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
from django.forms.formsets import formset_factory
from django.urls import reverse

from omeroweb.custom_forms import NonASCIIForm
from .custom_forms import MetadataModelChoiceField
from .custom_forms import MultipleFileField
from .custom_forms import AnnotationModelMultipleChoiceField
Expand Down Expand Up @@ -67,11 +66,11 @@
# Non-model Form


class GlobalSearchForm(NonASCIIForm):
class GlobalSearchForm(forms.Form):
search_query = forms.CharField(widget=forms.TextInput(attrs={"size": 25}))


class ShareForm(NonASCIIForm):
class ShareForm(forms.Form):
def __init__(self, *args, **kwargs):
super(ShareForm, self).__init__(*args, **kwargs)

Expand Down Expand Up @@ -126,25 +125,25 @@ def clean_expiration(self):
return self.cleaned_data["expiration"]


class ContainerForm(NonASCIIForm):
class ContainerForm(forms.Form):
name = forms.CharField(max_length=250, widget=forms.TextInput(attrs={"size": 45}))
description = forms.CharField(
widget=forms.Textarea(attrs={"rows": 2, "cols": 49}), required=False
)
owner = forms.CharField(widget=forms.HiddenInput, required=False)


class ContainerNameForm(NonASCIIForm):
class ContainerNameForm(forms.Form):
name = forms.CharField(max_length=250, widget=forms.TextInput(attrs={"size": 45}))


class ContainerDescriptionForm(NonASCIIForm):
class ContainerDescriptionForm(forms.Form):
description = forms.CharField(
widget=forms.Textarea(attrs={"rows": 3, "cols": 39}), required=False
)


class BaseAnnotationForm(NonASCIIForm):
class BaseAnnotationForm(forms.Form):
"""
This is the superclass of the various forms used for annotating single or
multiple objects.
Expand Down

0 comments on commit ac5e4cc

Please sign in to comment.