Clean imports in code

This patch set modifies lines which are importing objects
instead of modules. As per openstack import guide lines, user should
import modules in a file not objects.

http://docs.openstack.org/developer/hacking/#imports

Change-Id: Ibfaf35be7506db820bea8e41a7fc8fcaf20fe08a
This commit is contained in:
Cao Xuan Hoang 2017-02-06 11:21:15 +07:00
parent 308b8c4d67
commit 02a4288827
2 changed files with 8 additions and 8 deletions

View File

@ -15,11 +15,11 @@
import functools
import json
from django.http import HttpResponse
from django import http
from django.views import generic
from openstack_dashboard.api.rest import utils as rest_utils
from openstack_dashboard.api.rest.utils import JSONResponse
from openstack_dashboard.api.rest import utils
import disaster_recovery.api.api as freezer_api
@ -30,7 +30,7 @@ def prevent_json_hijacking(function):
@functools.wraps(function)
def wrapper(*args, **kwargs):
response = function(*args, **kwargs)
if isinstance(response, JSONResponse) and response.content:
if isinstance(response, utils.JSONResponse) and response.content:
response.content = ")]}',\n" + response.content
return response
@ -49,7 +49,7 @@ class Clients(generic.View):
# we need to resort to getting a very high number.
clients = freezer_api.Client(request).list(json=True)
clients = json.dumps(clients)
return HttpResponse(clients, content_type="application/json")
return http.HttpResponse(clients, content_type="application/json")
class ActionList(generic.View):
@ -60,7 +60,7 @@ class ActionList(generic.View):
actions = freezer_api.Action(request).list(json=True)
actions = json.dumps(actions)
return HttpResponse(actions, content_type="application/json")
return http.HttpResponse(actions, content_type="application/json")
class Actions(generic.View):
@ -90,4 +90,4 @@ class Actions(generic.View):
'selected': selected_actions}
actions = json.dumps(actions)
return HttpResponse(actions, content_type="application/json")
return http.HttpResponse(actions, content_type="application/json")

View File

@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
from django.core.exceptions import ValidationError
from django.core import exceptions as d_exceptions
from django.utils.translation import ugettext_lazy as _
from horizon import exceptions
@ -32,7 +32,7 @@ class DestinationAction(workflows.MembershipAction):
if 'client' in self.request.POST:
self.cleaned_data['client'] = self.request.POST['client']
else:
raise ValidationError(_('Client is required'))
raise d_exceptions.ValidationError(_('Client is required'))
return self.cleaned_data