Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 31299 #1103

Merged
merged 10 commits into from
Apr 14, 2018
6 changes: 5 additions & 1 deletion gui/middleware/form.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def handle_middleware_validation(form, excep):
if list_field_name in form.fields:
list_index = int(field_name.split('.')[-2])
field_name = list_field_name
error_message = repr(form.cleaned_data[field_name][list_index]) + f": {error_message}"
if isinstance(form.cleaned_data[field_name], list):
list_ = form.cleaned_data[field_name]
else:
list_ = form.cleaned_data[field_name].split()
error_message = repr(list_[list_index]) + f": {error_message}"
if field_name not in form.fields:
field_name = '__all__'

Expand Down
8 changes: 4 additions & 4 deletions gui/services/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -424,8 +424,8 @@ class Meta:
model = models.RsyncMod

def middleware_clean(self, update):
update['hostsallow'] = list(filter(None, re.split(r"\s+", update["hostsallow"])))
update['hostsdeny'] = list(filter(None, re.split(r"\s+", update["hostsdeny"])))
update['hostsallow'] = update["hostsallow"].split()
update['hostsdeny'] = update["hostsdeny"].split()
return update


Expand Down Expand Up @@ -478,7 +478,7 @@ def clean(self):
return cdata

def middleware_clean(self, update):
update["domain"] = list(filter(None, re.split(r"\s+", update["domain"])))
update["domain"] = update["domain"].split()
return update


Expand Down Expand Up @@ -1492,7 +1492,7 @@ class Meta:

def middleware_clean(self, update):
update["powermode"] = update["powermode"].upper()
update["email"] = list(filter(None, re.split(r"\s+", update["email"])))
update["email"] = update["email"].split()
return update


Expand Down
2 changes: 1 addition & 1 deletion gui/services/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -2039,7 +2039,7 @@ class SMART(Model):
max_length=255,
blank=True,
help_text=_("Destination email address. Separate email addresses "
"with commas."),
"with spaces."),
)

class Meta:
Expand Down
2 changes: 1 addition & 1 deletion gui/services/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __enter__(self):
with open(self.SMART_FILE, 'rb') as f:
try:
self.data = pickle.loads(f.read())
except:
except Exception:
pass
return self

Expand Down
4 changes: 2 additions & 2 deletions gui/services/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ def enable(request, svc):
def services_cifs(request):
try:
cifs = models.CIFS.objects.all()[0]
except:
except Exception:
cifs = models.CIFS()

try:
Expand Down Expand Up @@ -344,7 +344,7 @@ def fibrechanneltotarget(request):
def services_s3(request):
try:
s3 = models.S3.objects.all()[0]
except:
except Exception:
s3 = models.S3()

if request.method == "POST":
Expand Down
5 changes: 3 additions & 2 deletions gui/tasks/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import logging
import re

from django.utils.translation import ugettext_lazy as _

Expand Down Expand Up @@ -295,7 +294,9 @@ def __init__(self, *args, **kwargs):
)

def middleware_clean(self, update):
update['extra'] = list(filter(None, re.split(r"\s+", update["extra"])))
update['month'] = self.data.getlist("rsync_month")
update['dayweek'] = self.data.getlist("rsync_dayweek")
update['extra'] = update["extra"].split()
update['schedule'] = {
'minute': update.pop('minute'),
'hour': update.pop('hour'),
Expand Down
4 changes: 1 addition & 3 deletions src/middlewared/middlewared/plugins/dyndns.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import re

from middlewared.schema import accepts, Bool, Dict, Int, List, Str
from middlewared.service import SystemServiceService, private

Expand All @@ -14,7 +12,7 @@ class Config:
@private
async def dyndns_extend(self, dyndns):
dyndns["password"] = await self.middleware.call("notifier.pwenc_decrypt", dyndns["password"])
dyndns["domain"] = list(filter(None, re.split(r"\s+", dyndns["domain"])))
dyndns["domain"] = dyndns["domain"].split()
return dyndns

@accepts(Dict(
Expand Down
5 changes: 2 additions & 3 deletions src/middlewared/middlewared/plugins/smart.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import re
from itertools import chain

from middlewared.schema import accepts, Cron, Dict, Int, List, Patch, Str
Expand Down Expand Up @@ -168,7 +167,7 @@ class Config:
@private
async def smart_extend(self, smart):
smart["powermode"] = smart["powermode"].upper()
smart["email"] = list(filter(None, re.split(r"\s+", smart["email"])))
smart["email"] = smart["email"].split(",")
return smart

@accepts(Dict(
Expand All @@ -187,7 +186,7 @@ async def do_update(self, data):
new.update(data)

new["powermode"] = new["powermode"].lower()
new["email"] = " ".join(new["email"])
new["email"] = ",".join([email.strip() for email in new["email"]])

await self._update_service(old, new)

Expand Down