Enable H302 check
This patch replaces some method imports with module imports and makes H302 test enabled. Fixes bug 1188531 Change-Id: Ibfbddeaa19cbbb244da58ffd5c918c41f03a0c65
This commit is contained in:
parent
c4ac732aa9
commit
953d1b9793
@ -26,10 +26,10 @@ methods like :func:`~horizon.register` and :func:`~horizon.unregister`.
|
||||
# should that fail.
|
||||
Horizon = None
|
||||
try:
|
||||
from horizon.base import Dashboard
|
||||
from horizon.base import Horizon
|
||||
from horizon.base import Panel
|
||||
from horizon.base import PanelGroup
|
||||
from horizon.base import Dashboard # noqa
|
||||
from horizon.base import Horizon # noqa
|
||||
from horizon.base import Panel # noqa
|
||||
from horizon.base import PanelGroup # noqa
|
||||
except ImportError:
|
||||
import warnings
|
||||
|
||||
|
@ -28,22 +28,22 @@ import inspect
|
||||
import logging
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls.defaults import include
|
||||
from django.conf.urls.defaults import patterns
|
||||
from django.conf.urls.defaults import url
|
||||
from django.core.exceptions import ImproperlyConfigured
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.functional import SimpleLazyObject
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.module_loading import module_has_submodule
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings # noqa
|
||||
from django.conf.urls.defaults import include # noqa
|
||||
from django.conf.urls.defaults import patterns # noqa
|
||||
from django.conf.urls.defaults import url # noqa
|
||||
from django.core.exceptions import ImproperlyConfigured # noqa
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django.utils.datastructures import SortedDict # noqa
|
||||
from django.utils.functional import SimpleLazyObject # noqa
|
||||
from django.utils.importlib import import_module # noqa
|
||||
from django.utils.module_loading import module_has_submodule # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import conf
|
||||
from horizon.decorators import _current_component
|
||||
from horizon.decorators import require_auth
|
||||
from horizon.decorators import require_perms
|
||||
from horizon.decorators import _current_component # noqa
|
||||
from horizon.decorators import require_auth # noqa
|
||||
from horizon.decorators import require_perms # noqa
|
||||
from horizon import loaders
|
||||
|
||||
|
||||
@ -549,7 +549,7 @@ class Workflow(object):
|
||||
|
||||
|
||||
try:
|
||||
from django.utils.functional import empty
|
||||
from django.utils.functional import empty # noqa
|
||||
except ImportError:
|
||||
#Django 1.3 fallback
|
||||
empty = None
|
||||
|
@ -14,8 +14,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from horizon.browsers.base import ResourceBrowser
|
||||
from horizon.browsers.views import ResourceBrowserView
|
||||
from horizon.browsers.base import ResourceBrowser # noqa
|
||||
from horizon.browsers.views import ResourceBrowserView # noqa
|
||||
|
||||
assert ResourceBrowser
|
||||
assert ResourceBrowserView
|
||||
|
@ -15,10 +15,10 @@
|
||||
# under the License.
|
||||
|
||||
from django import template
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon.browsers.breadcrumb import Breadcrumb
|
||||
from horizon.tables import DataTable
|
||||
from horizon.browsers.breadcrumb import Breadcrumb # noqa
|
||||
from horizon.tables import DataTable # noqa
|
||||
from horizon.utils import html
|
||||
|
||||
|
||||
|
@ -14,9 +14,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon.tables import MultiTableView
|
||||
from horizon.tables import MultiTableView # noqa
|
||||
|
||||
|
||||
class ResourceBrowserView(MultiTableView):
|
||||
|
@ -1,13 +1,13 @@
|
||||
import copy
|
||||
|
||||
from django.utils.functional import empty
|
||||
from django.utils.functional import LazyObject
|
||||
from django.utils.functional import empty # noqa
|
||||
from django.utils.functional import LazyObject # noqa
|
||||
|
||||
|
||||
class LazySettings(LazyObject):
|
||||
def _setup(self, name=None):
|
||||
from django.conf import settings
|
||||
from horizon.conf.default import HORIZON_CONFIG as DEFAULT_CONFIG
|
||||
from django.conf import settings # noqa
|
||||
from horizon.conf.default import HORIZON_CONFIG as DEFAULT_CONFIG # noqa
|
||||
HORIZON_CONFIG = copy.copy(DEFAULT_CONFIG)
|
||||
HORIZON_CONFIG.update(settings.HORIZON_CONFIG)
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
# Default configuration dictionary. Do not mutate.
|
||||
HORIZON_CONFIG = {
|
||||
|
@ -23,8 +23,8 @@ General-purpose decorators for use with Horizon.
|
||||
"""
|
||||
import functools
|
||||
|
||||
from django.utils.decorators import available_attrs
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.decorators import available_attrs # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
|
||||
def _current_component(view_func, dashboard=None, panel=None):
|
||||
@ -46,7 +46,7 @@ def require_auth(view_func):
|
||||
:exc:`~horizon.exceptions.NotAuthenticated` exception if the user is not
|
||||
signed-in.
|
||||
"""
|
||||
from horizon.exceptions import NotAuthenticated
|
||||
from horizon.exceptions import NotAuthenticated # noqa
|
||||
|
||||
@functools.wraps(view_func, assigned=available_attrs(view_func))
|
||||
def dec(request, *args, **kwargs):
|
||||
@ -74,7 +74,7 @@ def require_perms(view_func, required):
|
||||
Raises a :exc:`~horizon.exceptions.NotAuthorized` exception if the
|
||||
requirements are not met.
|
||||
"""
|
||||
from horizon.exceptions import NotAuthorized
|
||||
from horizon.exceptions import NotAuthorized # noqa
|
||||
# We only need to check each permission once for a view, so we'll use a set
|
||||
current_perms = getattr(view_func, '_required_perms', set([]))
|
||||
view_func._required_perms = current_perms | set(required)
|
||||
|
@ -22,14 +22,14 @@ import logging
|
||||
import os
|
||||
import sys
|
||||
|
||||
from django.contrib.auth import logout
|
||||
from django.core.management import color_style
|
||||
from django.http import HttpRequest
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.views.debug import CLEANSED_SUBSTITUTE
|
||||
from django.views.debug import SafeExceptionReporterFilter
|
||||
from django.contrib.auth import logout # noqa
|
||||
from django.core.management import color_style # noqa
|
||||
from django.http import HttpRequest # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
from django.views.debug import CLEANSED_SUBSTITUTE # noqa
|
||||
from django.views.debug import SafeExceptionReporterFilter # noqa
|
||||
|
||||
from horizon.conf import HORIZON_CONFIG
|
||||
from horizon.conf import HORIZON_CONFIG # noqa
|
||||
from horizon import messages
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -19,13 +19,13 @@ from django.forms import * # noqa
|
||||
from django.forms import widgets
|
||||
|
||||
# Convenience imports for public API components.
|
||||
from horizon.forms.base import DateForm
|
||||
from horizon.forms.base import SelfHandlingForm
|
||||
from horizon.forms.base import SelfHandlingMixin
|
||||
from horizon.forms.fields import DynamicChoiceField
|
||||
from horizon.forms.fields import DynamicTypedChoiceField
|
||||
from horizon.forms.views import ModalFormMixin
|
||||
from horizon.forms.views import ModalFormView
|
||||
from horizon.forms.base import DateForm # noqa
|
||||
from horizon.forms.base import SelfHandlingForm # noqa
|
||||
from horizon.forms.base import SelfHandlingMixin # noqa
|
||||
from horizon.forms.fields import DynamicChoiceField # noqa
|
||||
from horizon.forms.fields import DynamicTypedChoiceField # noqa
|
||||
from horizon.forms.views import ModalFormMixin # noqa
|
||||
from horizon.forms.views import ModalFormView # noqa
|
||||
|
||||
assert widgets
|
||||
assert SelfHandlingMixin
|
||||
|
@ -19,7 +19,7 @@
|
||||
# under the License.
|
||||
|
||||
from django import forms
|
||||
from django.forms.forms import NON_FIELD_ERRORS
|
||||
from django.forms.forms import NON_FIELD_ERRORS # noqa
|
||||
|
||||
|
||||
class SelfHandlingMixin(object):
|
||||
|
@ -4,10 +4,10 @@ Wrapper for loading templates from "templates" directories in panel modules.
|
||||
|
||||
import os
|
||||
|
||||
from django.conf import settings
|
||||
from django.template.base import TemplateDoesNotExist
|
||||
from django.template.loader import BaseLoader
|
||||
from django.utils._os import safe_join
|
||||
from django.conf import settings # noqa
|
||||
from django.template.base import TemplateDoesNotExist # noqa
|
||||
from django.template.loader import BaseLoader # noqa
|
||||
from django.utils._os import safe_join # noqa
|
||||
|
||||
# Set up a cache of the panel directories to search.
|
||||
panel_template_dirs = {}
|
||||
|
@ -1,10 +1,10 @@
|
||||
import glob
|
||||
from optparse import make_option
|
||||
from optparse import make_option # noqa
|
||||
import os
|
||||
|
||||
from django.core.management.base import CommandError
|
||||
from django.core.management.templates import TemplateCommand
|
||||
from django.utils.importlib import import_module
|
||||
from django.core.management.base import CommandError # noqa
|
||||
from django.core.management.templates import TemplateCommand # noqa
|
||||
from django.utils.importlib import import_module # noqa
|
||||
|
||||
import horizon
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
import glob
|
||||
from optparse import make_option
|
||||
from optparse import make_option # noqa
|
||||
import os
|
||||
|
||||
from django.core.management.base import CommandError
|
||||
from django.core.management.templates import TemplateCommand
|
||||
from django.utils.importlib import import_module
|
||||
from django.core.management.base import CommandError # noqa
|
||||
from django.core.management.templates import TemplateCommand # noqa
|
||||
from django.utils.importlib import import_module # noqa
|
||||
|
||||
import horizon
|
||||
|
||||
|
@ -21,8 +21,8 @@ messaging needs (e.g. AJAX communication, etc.).
|
||||
|
||||
from django.contrib import messages as _messages
|
||||
from django.contrib.messages import constants
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.utils.safestring import SafeData
|
||||
from django.utils.encoding import force_unicode # noqa
|
||||
from django.utils.safestring import SafeData # noqa
|
||||
|
||||
|
||||
def add_message(request, level, message, extra_tags='', fail_silently=False):
|
||||
|
@ -25,14 +25,14 @@ import datetime
|
||||
import json
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import REDIRECT_FIELD_NAME
|
||||
from django.contrib.auth.views import redirect_to_login
|
||||
from django.conf import settings # noqa
|
||||
from django.contrib.auth import REDIRECT_FIELD_NAME # noqa
|
||||
from django.contrib.auth.views import redirect_to_login # noqa
|
||||
from django.contrib import messages as django_messages
|
||||
from django import http
|
||||
from django.http import HttpResponseRedirect
|
||||
from django.http import HttpResponseRedirect # noqa
|
||||
from django import shortcuts
|
||||
from django.utils.encoding import iri_to_uri
|
||||
from django.utils.encoding import iri_to_uri # noqa
|
||||
from django.utils import timezone
|
||||
|
||||
from horizon import exceptions
|
||||
|
@ -18,11 +18,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf.urls.defaults import include
|
||||
from django.conf.urls.defaults import patterns
|
||||
from django.conf.urls.defaults import url
|
||||
from django.views.generic import TemplateView
|
||||
from django.conf import settings # noqa
|
||||
from django.conf.urls.defaults import include # noqa
|
||||
from django.conf.urls.defaults import patterns # noqa
|
||||
from django.conf.urls.defaults import url # noqa
|
||||
from django.views.generic import TemplateView # noqa
|
||||
|
||||
|
||||
urlpatterns = patterns('horizon.views',
|
||||
|
@ -15,19 +15,19 @@
|
||||
# under the License.
|
||||
|
||||
# Convenience imports for public API components.
|
||||
from horizon.tables.actions import Action
|
||||
from horizon.tables.actions import BatchAction
|
||||
from horizon.tables.actions import DeleteAction
|
||||
from horizon.tables.actions import FilterAction
|
||||
from horizon.tables.actions import FixedFilterAction
|
||||
from horizon.tables.actions import LinkAction
|
||||
from horizon.tables.base import Column
|
||||
from horizon.tables.base import DataTable
|
||||
from horizon.tables.base import Row
|
||||
from horizon.tables.views import DataTableView
|
||||
from horizon.tables.views import MixedDataTableView
|
||||
from horizon.tables.views import MultiTableMixin
|
||||
from horizon.tables.views import MultiTableView
|
||||
from horizon.tables.actions import Action # noqa
|
||||
from horizon.tables.actions import BatchAction # noqa
|
||||
from horizon.tables.actions import DeleteAction # noqa
|
||||
from horizon.tables.actions import FilterAction # noqa
|
||||
from horizon.tables.actions import FixedFilterAction # noqa
|
||||
from horizon.tables.actions import LinkAction # noqa
|
||||
from horizon.tables.base import Column # noqa
|
||||
from horizon.tables.base import DataTable # noqa
|
||||
from horizon.tables.base import Row # noqa
|
||||
from horizon.tables.views import DataTableView # noqa
|
||||
from horizon.tables.views import MixedDataTableView # noqa
|
||||
from horizon.tables.views import MultiTableMixin # noqa
|
||||
from horizon.tables.views import MultiTableView # noqa
|
||||
|
||||
assert Action
|
||||
assert BatchAction
|
||||
|
@ -14,15 +14,15 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from collections import defaultdict
|
||||
from collections import defaultdict # noqa
|
||||
import logging
|
||||
import new
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf import settings # noqa
|
||||
from django.core import urlresolvers
|
||||
from django import shortcuts
|
||||
from django.utils.functional import Promise
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.functional import Promise # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import messages
|
||||
|
@ -17,29 +17,29 @@
|
||||
import collections
|
||||
import copy
|
||||
import logging
|
||||
from operator import attrgetter
|
||||
from operator import attrgetter # noqa
|
||||
import sys
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf import settings # noqa
|
||||
from django.core import urlresolvers
|
||||
from django import forms
|
||||
from django.http import HttpResponse
|
||||
from django.http import HttpResponse # noqa
|
||||
from django import template
|
||||
from django.template.defaultfilters import truncatechars
|
||||
from django.template.loader import render_to_string
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.html import escape
|
||||
from django.template.defaultfilters import truncatechars # noqa
|
||||
from django.template.loader import render_to_string # noqa
|
||||
from django.utils.datastructures import SortedDict # noqa
|
||||
from django.utils.html import escape # noqa
|
||||
from django.utils import http
|
||||
from django.utils.http import urlencode
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.http import urlencode # noqa
|
||||
from django.utils.safestring import mark_safe # noqa
|
||||
from django.utils import termcolors
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import conf
|
||||
from horizon import exceptions
|
||||
from horizon import messages
|
||||
from horizon.tables.actions import FilterAction
|
||||
from horizon.tables.actions import LinkAction
|
||||
from horizon.tables.actions import FilterAction # noqa
|
||||
from horizon.tables.actions import LinkAction # noqa
|
||||
from horizon.utils import html
|
||||
|
||||
|
||||
|
@ -14,11 +14,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from collections import defaultdict
|
||||
from collections import defaultdict # noqa
|
||||
|
||||
from django.views import generic
|
||||
|
||||
from horizon.templatetags.horizon import has_permissions
|
||||
from horizon.templatetags.horizon import has_permissions # noqa
|
||||
|
||||
|
||||
class MultiTableMixin(object):
|
||||
|
@ -14,11 +14,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from horizon.tabs.base import Tab
|
||||
from horizon.tabs.base import TabGroup
|
||||
from horizon.tabs.base import TableTab
|
||||
from horizon.tabs.views import TabbedTableView
|
||||
from horizon.tabs.views import TabView
|
||||
from horizon.tabs.base import Tab # noqa
|
||||
from horizon.tabs.base import TabGroup # noqa
|
||||
from horizon.tabs.base import TableTab # noqa
|
||||
from horizon.tabs.views import TabbedTableView # noqa
|
||||
from horizon.tabs.views import TabView # noqa
|
||||
|
||||
assert TabGroup
|
||||
assert Tab
|
||||
|
@ -16,9 +16,9 @@
|
||||
|
||||
import sys
|
||||
|
||||
from django.template.loader import render_to_string
|
||||
from django.template import TemplateSyntaxError
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.template.loader import render_to_string # noqa
|
||||
from django.template import TemplateSyntaxError # noqa
|
||||
from django.utils.datastructures import SortedDict # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon.utils import html
|
||||
|
@ -3,7 +3,7 @@ from django.views import generic
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tables
|
||||
from horizon.tabs.base import TableTab
|
||||
from horizon.tabs.base import TableTab # noqa
|
||||
|
||||
|
||||
class TabView(generic.TemplateView):
|
||||
|
@ -22,9 +22,9 @@
|
||||
Template tags for customizing Horizon.
|
||||
"""
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf import settings # noqa
|
||||
from django import template
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
|
||||
register = template.Library()
|
||||
|
@ -17,11 +17,11 @@
|
||||
from __future__ import absolute_import
|
||||
|
||||
from django import template
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.datastructures import SortedDict # noqa
|
||||
from django.utils.encoding import force_unicode # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon.base import Horizon
|
||||
from horizon.base import Horizon # noqa
|
||||
from horizon import conf
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
Template tags for parsing date strings.
|
||||
"""
|
||||
|
||||
from datetime import datetime
|
||||
from datetime import datetime # noqa
|
||||
from django import template
|
||||
from django.utils import timezone
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
import horizon
|
||||
|
||||
|
@ -22,22 +22,22 @@ import logging
|
||||
import os
|
||||
import socket
|
||||
|
||||
from django.contrib.auth.middleware import AuthenticationMiddleware
|
||||
from django.contrib.auth.models import Permission
|
||||
from django.contrib.auth.models import User
|
||||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.contrib.messages.storage import default_storage
|
||||
from django.contrib.auth.middleware import AuthenticationMiddleware # noqa
|
||||
from django.contrib.auth.models import Permission # noqa
|
||||
from django.contrib.auth.models import User # noqa
|
||||
from django.contrib.contenttypes.models import ContentType # noqa
|
||||
from django.contrib.messages.storage import default_storage # noqa
|
||||
from django.core.handlers import wsgi
|
||||
from django import http
|
||||
from django import test as django_test
|
||||
from django.test.client import RequestFactory
|
||||
from django.test.client import RequestFactory # noqa
|
||||
from django.utils import unittest
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
try:
|
||||
from selenium.webdriver.firefox.webdriver import WebDriver
|
||||
from selenium.webdriver.firefox.webdriver import WebDriver # noqa
|
||||
from selenium.webdriver.support import ui as selenium_ui
|
||||
except ImportError as e:
|
||||
# NOTE(saschpe): Several distribution can't ship selenium due to it's
|
||||
|
@ -21,7 +21,7 @@
|
||||
import os
|
||||
import socket
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
|
||||
socket.setdefaulttimeout(1)
|
||||
|
@ -1,4 +1,4 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
import horizon
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
import horizon
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from django.conf.urls.defaults import patterns
|
||||
from django.conf.urls.defaults import url
|
||||
from django.conf.urls.defaults import patterns # noqa
|
||||
from django.conf.urls.defaults import url # noqa
|
||||
|
||||
from horizon.test.test_dashboards.cats.kittens.views import IndexView
|
||||
from horizon.test.test_dashboards.cats.kittens.views import IndexView # noqa
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
|
@ -1,4 +1,4 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
import horizon
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from django.conf.urls.defaults import patterns
|
||||
from django.conf.urls.defaults import url
|
||||
from django.conf.urls.defaults import patterns # noqa
|
||||
from django.conf.urls.defaults import url # noqa
|
||||
|
||||
from horizon.test.test_dashboards.cats.tigers.views import IndexView
|
||||
from horizon.test.test_dashboards.cats.tigers.views import IndexView # noqa
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
|
@ -1,4 +1,4 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
import horizon
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
import horizon
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from django.conf.urls.defaults import patterns
|
||||
from django.conf.urls.defaults import url
|
||||
from django.conf.urls.defaults import patterns # noqa
|
||||
from django.conf.urls.defaults import url # noqa
|
||||
|
||||
from horizon.test.test_dashboards.dogs.puppies.views import IndexView
|
||||
from horizon.test.test_dashboards.dogs.puppies.views import IndexView # noqa
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
|
@ -19,21 +19,21 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth.models import User
|
||||
from django.conf import settings # noqa
|
||||
from django.contrib.auth.models import User # noqa
|
||||
from django.core import urlresolvers
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.importlib import import_module # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
import horizon
|
||||
from horizon import base
|
||||
from horizon import conf
|
||||
from horizon.test import helpers as test
|
||||
from horizon.test.test_dashboards.cats.dashboard import Cats
|
||||
from horizon.test.test_dashboards.cats.kittens.panel import Kittens
|
||||
from horizon.test.test_dashboards.cats.tigers.panel import Tigers
|
||||
from horizon.test.test_dashboards.dogs.dashboard import Dogs
|
||||
from horizon.test.test_dashboards.dogs.puppies.panel import Puppies
|
||||
from horizon.test.test_dashboards.cats.dashboard import Cats # noqa
|
||||
from horizon.test.test_dashboards.cats.kittens.panel import Kittens # noqa
|
||||
from horizon.test.test_dashboards.cats.tigers.panel import Tigers # noqa
|
||||
from horizon.test.test_dashboards.dogs.dashboard import Dogs # noqa
|
||||
from horizon.test.test_dashboards.dogs.puppies.panel import Puppies # noqa
|
||||
|
||||
|
||||
class MyDash(horizon.Dashboard):
|
||||
|
@ -17,9 +17,9 @@
|
||||
import json
|
||||
|
||||
from django import http
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.utils.safestring import mark_safe
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.encoding import force_unicode # noqa
|
||||
from django.utils.safestring import mark_safe # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import messages
|
||||
from horizon import middleware
|
||||
|
@ -15,7 +15,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf import settings # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import middleware
|
||||
|
@ -14,12 +14,12 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django import http
|
||||
from django import shortcuts
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from mox import IsA
|
||||
from mox import IsA # noqa
|
||||
|
||||
from horizon import tables
|
||||
from horizon.tables import views as table_views
|
||||
|
@ -17,14 +17,14 @@
|
||||
import copy
|
||||
|
||||
from django import http
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tabs as horizon_tabs
|
||||
from horizon.test import helpers as test
|
||||
|
||||
from horizon.test.tests.tables import MyTable
|
||||
from horizon.test.tests.tables import TEST_DATA
|
||||
from horizon.test.tests.tables import MyTable # noqa
|
||||
from horizon.test.tests.tables import TEST_DATA # noqa
|
||||
|
||||
|
||||
class BaseTestTab(horizon_tabs.Tab):
|
||||
|
@ -20,10 +20,10 @@
|
||||
|
||||
import re
|
||||
|
||||
from django.conf import settings
|
||||
from django.template import Context
|
||||
from django.template import Template
|
||||
from django.utils.text import normalize_newlines
|
||||
from django.conf import settings # noqa
|
||||
from django.template import Context # noqa
|
||||
from django.template import Template # noqa
|
||||
from django.utils.text import normalize_newlines # noqa
|
||||
|
||||
from horizon.test import helpers as test
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
|
||||
import os
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.exceptions import ValidationError # noqa
|
||||
|
||||
from horizon.test import helpers as test
|
||||
from horizon.utils import fields
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
from django import forms
|
||||
from django import http
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon.test import helpers as test
|
||||
|
@ -22,11 +22,11 @@
|
||||
URL patterns for testing Horizon views.
|
||||
"""
|
||||
|
||||
from django.conf.urls.defaults import include
|
||||
from django.conf.urls.defaults import patterns
|
||||
from django.conf.urls.defaults import url
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
|
||||
from django.views.generic import TemplateView
|
||||
from django.conf.urls.defaults import include # noqa
|
||||
from django.conf.urls.defaults import patterns # noqa
|
||||
from django.conf.urls.defaults import url # noqa
|
||||
from django.contrib.staticfiles.urls import staticfiles_urlpatterns # noqa
|
||||
from django.views.generic import TemplateView # noqa
|
||||
|
||||
import horizon
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.exceptions import ValidationError # noqa
|
||||
from django.forms import forms
|
||||
from django.forms import widgets
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.utils.functional import Promise
|
||||
from django.utils.html import conditional_escape
|
||||
from django.utils.html import escape
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.encoding import force_unicode # noqa
|
||||
from django.utils.functional import Promise # noqa
|
||||
from django.utils.html import conditional_escape # noqa
|
||||
from django.utils.html import escape # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
import netaddr
|
||||
import re
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import iso8601
|
||||
|
||||
from django.template.defaultfilters import register
|
||||
from django.template.defaultfilters import register # noqa
|
||||
|
||||
|
||||
@register.filter
|
||||
|
@ -1,7 +1,7 @@
|
||||
import math
|
||||
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.utils.functional import lazy
|
||||
from django.utils.encoding import force_unicode # noqa
|
||||
from django.utils.functional import lazy # noqa
|
||||
|
||||
|
||||
def _lazy_join(separator, strings):
|
||||
|
@ -1,6 +1,6 @@
|
||||
import copy
|
||||
|
||||
from django.forms.util import flatatt
|
||||
from django.forms.util import flatatt # noqa
|
||||
|
||||
|
||||
class HTMLElement(object):
|
||||
|
@ -14,7 +14,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.core.exceptions import ValidationError
|
||||
from django.core.exceptions import ValidationError # noqa
|
||||
|
||||
from horizon import conf
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
from horizon.workflows.base import Action
|
||||
from horizon.workflows.base import MembershipAction
|
||||
from horizon.workflows.base import Step
|
||||
from horizon.workflows.base import UpdateMembersStep
|
||||
from horizon.workflows.base import Workflow
|
||||
from horizon.workflows.views import WorkflowView
|
||||
from horizon.workflows.base import Action # noqa
|
||||
from horizon.workflows.base import MembershipAction # noqa
|
||||
from horizon.workflows.base import Step # noqa
|
||||
from horizon.workflows.base import UpdateMembersStep # noqa
|
||||
from horizon.workflows.base import Workflow # noqa
|
||||
from horizon.workflows.views import WorkflowView # noqa
|
||||
|
||||
assert Action
|
||||
assert MembershipAction
|
||||
|
@ -20,18 +20,18 @@ import logging
|
||||
|
||||
from django.core import urlresolvers
|
||||
from django import forms
|
||||
from django.forms.forms import NON_FIELD_ERRORS
|
||||
from django.forms.forms import NON_FIELD_ERRORS # noqa
|
||||
from django import template
|
||||
from django.template.defaultfilters import linebreaks
|
||||
from django.template.defaultfilters import safe
|
||||
from django.template.defaultfilters import slugify
|
||||
from django.utils.encoding import force_unicode
|
||||
from django.utils.importlib import import_module
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.template.defaultfilters import linebreaks # noqa
|
||||
from django.template.defaultfilters import safe # noqa
|
||||
from django.template.defaultfilters import slugify # noqa
|
||||
from django.utils.encoding import force_unicode # noqa
|
||||
from django.utils.importlib import import_module # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import base
|
||||
from horizon import exceptions
|
||||
from horizon.templatetags.horizon import has_permissions
|
||||
from horizon.templatetags.horizon import has_permissions # noqa
|
||||
from horizon.utils import html
|
||||
|
||||
|
||||
|
@ -22,7 +22,7 @@ from django import shortcuts
|
||||
from django.views import generic
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon.forms.views import ADD_TO_FIELD_HEADER
|
||||
from horizon.forms.views import ADD_TO_FIELD_HEADER # noqa
|
||||
from horizon import messages
|
||||
|
||||
|
||||
|
@ -18,10 +18,10 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from collections import Sequence
|
||||
from collections import Sequence # noqa
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf import settings # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
|
||||
|
@ -24,15 +24,14 @@ from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from cinderclient.v1 import client as cinder_client
|
||||
|
||||
from horizon import exceptions
|
||||
|
||||
from openstack_dashboard.api.base import QuotaSet
|
||||
from openstack_dashboard.api.base import url_for
|
||||
from openstack_dashboard.api import base
|
||||
from openstack_dashboard.api import nova
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -46,7 +45,7 @@ def cinderclient(request):
|
||||
insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
|
||||
cinder_url = ""
|
||||
try:
|
||||
cinder_url = url_for(request, 'volume')
|
||||
cinder_url = base.url_for(request, 'volume')
|
||||
except exceptions.ServiceCatalogException:
|
||||
LOG.debug('no volume service configured.')
|
||||
return None
|
||||
@ -123,8 +122,8 @@ def volume_snapshot_delete(request, snapshot_id):
|
||||
def tenant_quota_get(request, tenant_id):
|
||||
c_client = cinderclient(request)
|
||||
if c_client is None:
|
||||
return QuotaSet()
|
||||
return QuotaSet(c_client.quotas.get(tenant_id))
|
||||
return base.QuotaSet()
|
||||
return base.QuotaSet(c_client.quotas.get(tenant_id))
|
||||
|
||||
|
||||
def tenant_quota_update(request, tenant_id, **kwargs):
|
||||
@ -132,7 +131,7 @@ def tenant_quota_update(request, tenant_id, **kwargs):
|
||||
|
||||
|
||||
def default_quota_get(request, tenant_id):
|
||||
return QuotaSet(cinderclient(request).quotas.defaults(tenant_id))
|
||||
return base.QuotaSet(cinderclient(request).quotas.defaults(tenant_id))
|
||||
|
||||
|
||||
def volume_type_list(request):
|
||||
|
@ -25,18 +25,18 @@ import logging
|
||||
import thread
|
||||
import urlparse
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf import settings # noqa
|
||||
|
||||
import glanceclient as glance_client
|
||||
|
||||
from openstack_dashboard.api.base import url_for
|
||||
from openstack_dashboard.api import base
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def glanceclient(request):
|
||||
o = urlparse.urlparse(url_for(request, 'image'))
|
||||
o = urlparse.urlparse(base.url_for(request, 'image'))
|
||||
url = "://".join((o.scheme, o.netloc))
|
||||
insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
|
||||
LOG.debug('glanceclient connection created using token "%s" and url "%s"'
|
||||
|
@ -14,9 +14,9 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf import settings # noqa
|
||||
from heatclient import client as heat_client
|
||||
from openstack_dashboard.api.base import url_for
|
||||
from openstack_dashboard.api import base
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -32,7 +32,7 @@ def format_parameters(params):
|
||||
def heatclient(request, password=None):
|
||||
api_version = "1"
|
||||
insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
|
||||
endpoint = url_for(request, 'orchestration')
|
||||
endpoint = base.url_for(request, 'orchestration')
|
||||
LOG.debug('heatclient connection created using token "%s" and url "%s"' %
|
||||
(request.user.token.id, endpoint))
|
||||
kwargs = {
|
||||
|
@ -22,13 +22,13 @@
|
||||
import logging
|
||||
import urlparse
|
||||
|
||||
from django.conf import settings
|
||||
from django.contrib.auth import logout
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings # noqa
|
||||
from django.contrib.auth import logout # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from keystoneclient.exceptions import ClientException
|
||||
from keystoneclient.exceptions import ClientException # noqa
|
||||
|
||||
from openstack_auth.backend import KEYSTONE_CLIENT_ATTR
|
||||
from openstack_auth.backend import KEYSTONE_CLIENT_ATTR # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import messages
|
||||
|
@ -16,9 +16,9 @@
|
||||
|
||||
from __future__ import absolute_import
|
||||
|
||||
from openstack_dashboard.api.neutron import NeutronAPIDictWrapper
|
||||
from openstack_dashboard.api.neutron import neutronclient
|
||||
from openstack_dashboard.api.neutron import subnet_get
|
||||
from openstack_dashboard.api.neutron import NeutronAPIDictWrapper # noqa
|
||||
from openstack_dashboard.api.neutron import neutronclient # noqa
|
||||
from openstack_dashboard.api.neutron import subnet_get # noqa
|
||||
|
||||
|
||||
class Vip(NeutronAPIDictWrapper):
|
||||
|
@ -21,7 +21,7 @@ introduced to abstract the differences between them for seamless consumption by
|
||||
different dashboard implementations.
|
||||
"""
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf import settings # noqa
|
||||
|
||||
from openstack_dashboard.api import base
|
||||
from openstack_dashboard.api import neutron
|
||||
|
@ -23,12 +23,11 @@ from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.datastructures import SortedDict
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings # noqa
|
||||
from django.utils.datastructures import SortedDict # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from openstack_dashboard.api.base import APIDictWrapper
|
||||
from openstack_dashboard.api.base import url_for
|
||||
from openstack_dashboard.api import base
|
||||
from openstack_dashboard.api import network_base
|
||||
from openstack_dashboard.api import nova
|
||||
|
||||
@ -39,7 +38,7 @@ LOG = logging.getLogger(__name__)
|
||||
IP_VERSION_DICT = {4: 'IPv4', 6: 'IPv6'}
|
||||
|
||||
|
||||
class NeutronAPIDictWrapper(APIDictWrapper):
|
||||
class NeutronAPIDictWrapper(base.APIDictWrapper):
|
||||
|
||||
def set_id_as_name_if_empty(self, length=8):
|
||||
try:
|
||||
@ -262,7 +261,7 @@ class SecurityGroupManager(network_base.SecurityGroupManager):
|
||||
port_modify(self.request, p.id, **params)
|
||||
|
||||
|
||||
class FloatingIp(APIDictWrapper):
|
||||
class FloatingIp(base.APIDictWrapper):
|
||||
_attrs = ['id', 'ip', 'fixed_ip', 'port_id', 'instance_id', 'pool']
|
||||
|
||||
def __init__(self, fip):
|
||||
@ -272,11 +271,11 @@ class FloatingIp(APIDictWrapper):
|
||||
super(FloatingIp, self).__init__(fip)
|
||||
|
||||
|
||||
class FloatingIpPool(APIDictWrapper):
|
||||
class FloatingIpPool(base.APIDictWrapper):
|
||||
pass
|
||||
|
||||
|
||||
class FloatingIpTarget(APIDictWrapper):
|
||||
class FloatingIpTarget(base.APIDictWrapper):
|
||||
pass
|
||||
|
||||
|
||||
@ -382,11 +381,11 @@ def get_ipver_str(ip_version):
|
||||
def neutronclient(request):
|
||||
insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
|
||||
LOG.debug('neutronclient connection created using token "%s" and url "%s"'
|
||||
% (request.user.token.id, url_for(request, 'network')))
|
||||
% (request.user.token.id, base.url_for(request, 'network')))
|
||||
LOG.debug('user_id=%(user)s, tenant_id=%(tenant)s' %
|
||||
{'user': request.user.id, 'tenant': request.user.tenant_id})
|
||||
c = neutron_client.Client(token=request.user.token.id,
|
||||
endpoint_url=url_for(request, 'network'),
|
||||
endpoint_url=base.url_for(request, 'network'),
|
||||
insecure=insecure)
|
||||
return c
|
||||
|
||||
|
@ -24,23 +24,20 @@ from __future__ import absolute_import
|
||||
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from novaclient.v1_1 import client as nova_client
|
||||
from novaclient.v1_1.contrib.list_extensions import ListExtManager
|
||||
from novaclient.v1_1.contrib.list_extensions import ListExtManager # noqa
|
||||
from novaclient.v1_1 import security_group_rules as nova_rules
|
||||
from novaclient.v1_1.security_groups import SecurityGroup as NovaSecurityGroup
|
||||
from novaclient.v1_1.servers import REBOOT_HARD
|
||||
from novaclient.v1_1.servers import REBOOT_SOFT
|
||||
from novaclient.v1_1.security_groups import SecurityGroup as NovaSecurityGroup # noqa
|
||||
from novaclient.v1_1.servers import REBOOT_HARD # noqa
|
||||
from novaclient.v1_1.servers import REBOOT_SOFT # noqa
|
||||
|
||||
from horizon.conf import HORIZON_CONFIG
|
||||
from horizon.utils.memoized import memoized
|
||||
from horizon.conf import HORIZON_CONFIG # noqa
|
||||
from horizon.utils.memoized import memoized # noqa
|
||||
|
||||
from openstack_dashboard.api.base import APIDictWrapper
|
||||
from openstack_dashboard.api.base import APIResourceWrapper
|
||||
from openstack_dashboard.api.base import QuotaSet
|
||||
from openstack_dashboard.api.base import url_for
|
||||
from openstack_dashboard.api import base
|
||||
from openstack_dashboard.api import network_base
|
||||
|
||||
|
||||
@ -52,21 +49,21 @@ INSTANCE_ACTIVE_STATE = 'ACTIVE'
|
||||
VOLUME_STATE_AVAILABLE = "available"
|
||||
|
||||
|
||||
class VNCConsole(APIDictWrapper):
|
||||
class VNCConsole(base.APIDictWrapper):
|
||||
"""Wrapper for the "console" dictionary returned by the
|
||||
novaclient.servers.get_vnc_console method.
|
||||
"""
|
||||
_attrs = ['url', 'type']
|
||||
|
||||
|
||||
class SPICEConsole(APIDictWrapper):
|
||||
class SPICEConsole(base.APIDictWrapper):
|
||||
"""Wrapper for the "console" dictionary returned by the
|
||||
novaclient.servers.get_spice_console method.
|
||||
"""
|
||||
_attrs = ['url', 'type']
|
||||
|
||||
|
||||
class Server(APIResourceWrapper):
|
||||
class Server(base.APIResourceWrapper):
|
||||
"""Simple wrapper around novaclient.server.Server
|
||||
|
||||
Preserves the request info so image name can later be retrieved
|
||||
@ -100,7 +97,7 @@ class Server(APIResourceWrapper):
|
||||
return getattr(self, 'OS-EXT-SRV-ATTR:instance_name', "")
|
||||
|
||||
|
||||
class NovaUsage(APIResourceWrapper):
|
||||
class NovaUsage(base.APIResourceWrapper):
|
||||
"""Simple wrapper around contrib/simple_usage.py."""
|
||||
_attrs = ['start', 'server_usages', 'stop', 'tenant_id',
|
||||
'total_local_gb_usage', 'total_memory_mb_usage',
|
||||
@ -142,7 +139,7 @@ class NovaUsage(APIResourceWrapper):
|
||||
return getattr(self, "total_local_gb_usage", 0)
|
||||
|
||||
|
||||
class SecurityGroup(APIResourceWrapper):
|
||||
class SecurityGroup(base.APIResourceWrapper):
|
||||
"""Wrapper around novaclient.security_groups.SecurityGroup which wraps its
|
||||
rules in SecurityGroupRule objects and allows access to them.
|
||||
"""
|
||||
@ -159,7 +156,7 @@ class SecurityGroup(APIResourceWrapper):
|
||||
return self.__dict__['_rules']
|
||||
|
||||
|
||||
class SecurityGroupRule(APIResourceWrapper):
|
||||
class SecurityGroupRule(base.APIResourceWrapper):
|
||||
""" Wrapper for individual rules in a SecurityGroup. """
|
||||
_attrs = ['id', 'ip_protocol', 'from_port', 'to_port', 'ip_range', 'group']
|
||||
|
||||
@ -275,7 +272,7 @@ class FlavorExtraSpec(object):
|
||||
self.value = val
|
||||
|
||||
|
||||
class FloatingIp(APIResourceWrapper):
|
||||
class FloatingIp(base.APIResourceWrapper):
|
||||
_attrs = ['id', 'ip', 'fixed_ip', 'port_id', 'instance_id', 'pool']
|
||||
|
||||
def __init__(self, fip):
|
||||
@ -283,14 +280,14 @@ class FloatingIp(APIResourceWrapper):
|
||||
super(FloatingIp, self).__init__(fip)
|
||||
|
||||
|
||||
class FloatingIpPool(APIDictWrapper):
|
||||
class FloatingIpPool(base.APIDictWrapper):
|
||||
def __init__(self, pool):
|
||||
pool_dict = {'id': pool.name,
|
||||
'name': pool.name}
|
||||
super(FloatingIpPool, self).__init__(pool_dict)
|
||||
|
||||
|
||||
class FloatingIpTarget(APIDictWrapper):
|
||||
class FloatingIpTarget(base.APIDictWrapper):
|
||||
def __init__(self, server):
|
||||
server_dict = {'name': '%s (%s)' % (server.name, server.id),
|
||||
'id': server.id}
|
||||
@ -343,15 +340,15 @@ class FloatingIpManager(network_base.FloatingIpManager):
|
||||
def novaclient(request):
|
||||
insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False)
|
||||
LOG.debug('novaclient connection created using token "%s" and url "%s"' %
|
||||
(request.user.token.id, url_for(request, 'compute')))
|
||||
(request.user.token.id, base.url_for(request, 'compute')))
|
||||
c = nova_client.Client(request.user.username,
|
||||
request.user.token.id,
|
||||
project_id=request.user.tenant_id,
|
||||
auth_url=url_for(request, 'compute'),
|
||||
auth_url=base.url_for(request, 'compute'),
|
||||
insecure=insecure,
|
||||
http_log_debug=settings.DEBUG)
|
||||
c.client.auth_token = request.user.token.id
|
||||
c.client.management_url = url_for(request, 'compute')
|
||||
c.client.management_url = base.url_for(request, 'compute')
|
||||
return c
|
||||
|
||||
|
||||
@ -545,7 +542,7 @@ def server_stop(request, instance_id):
|
||||
|
||||
|
||||
def tenant_quota_get(request, tenant_id):
|
||||
return QuotaSet(novaclient(request).quotas.get(tenant_id))
|
||||
return base.QuotaSet(novaclient(request).quotas.get(tenant_id))
|
||||
|
||||
|
||||
def tenant_quota_update(request, tenant_id, **kwargs):
|
||||
@ -553,7 +550,7 @@ def tenant_quota_update(request, tenant_id, **kwargs):
|
||||
|
||||
|
||||
def default_quota_get(request, tenant_id):
|
||||
return QuotaSet(novaclient(request).quotas.defaults(tenant_id))
|
||||
return base.QuotaSet(novaclient(request).quotas.defaults(tenant_id))
|
||||
|
||||
|
||||
def usage_get(request, tenant_id, start, end):
|
||||
@ -589,7 +586,7 @@ def instance_volume_detach(request, instance_id, att_id):
|
||||
|
||||
|
||||
def instance_volumes_list(request, instance_id):
|
||||
from openstack_dashboard.api.cinder import cinderclient
|
||||
from openstack_dashboard.api.cinder import cinderclient # noqa
|
||||
|
||||
volumes = novaclient(request).volumes.get_server_volumes(instance_id)
|
||||
|
||||
|
@ -22,14 +22,13 @@ import logging
|
||||
|
||||
import swiftclient
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import messages
|
||||
|
||||
from openstack_dashboard.api.base import APIDictWrapper
|
||||
from openstack_dashboard.api.base import url_for
|
||||
from openstack_dashboard.api import base
|
||||
from openstack_dashboard.openstack.common import timeutils
|
||||
|
||||
|
||||
@ -37,11 +36,11 @@ LOG = logging.getLogger(__name__)
|
||||
FOLDER_DELIMITER = "/"
|
||||
|
||||
|
||||
class Container(APIDictWrapper):
|
||||
class Container(base.APIDictWrapper):
|
||||
pass
|
||||
|
||||
|
||||
class StorageObject(APIDictWrapper):
|
||||
class StorageObject(base.APIDictWrapper):
|
||||
def __init__(self, apidict, container_name, orig_name=None, data=None):
|
||||
super(StorageObject, self).__init__(apidict)
|
||||
self.container_name = container_name
|
||||
@ -53,7 +52,7 @@ class StorageObject(APIDictWrapper):
|
||||
return self.name
|
||||
|
||||
|
||||
class PseudoFolder(APIDictWrapper):
|
||||
class PseudoFolder(base.APIDictWrapper):
|
||||
def __init__(self, apidict, container_name):
|
||||
super(PseudoFolder, self).__init__(apidict)
|
||||
self.container_name = container_name
|
||||
@ -92,7 +91,7 @@ def _objectify(items, container_name):
|
||||
|
||||
|
||||
def swift_api(request):
|
||||
endpoint = url_for(request, 'object-store')
|
||||
endpoint = base.url_for(request, 'object-store')
|
||||
LOG.debug('Swift connection created using token "%s" and url "%s"'
|
||||
% (request.user.token.id, endpoint))
|
||||
return swiftclient.client.Connection(None,
|
||||
|
@ -23,7 +23,7 @@ Context processors used by Horizon.
|
||||
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.conf import settings # noqa
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
@ -14,7 +14,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
import horizon
|
||||
|
||||
|
@ -14,11 +14,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
import horizon
|
||||
|
||||
from openstack_dashboard.api.keystone import VERSIONS as IDENTITY_VERSIONS
|
||||
from openstack_dashboard.api.keystone import VERSIONS as IDENTITY_VERSIONS # noqa
|
||||
from openstack_dashboard.dashboards.admin import dashboard
|
||||
|
||||
|
||||
|
@ -16,22 +16,17 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.conf import settings
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.conf import settings # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from keystoneclient.exceptions import ClientException
|
||||
from keystoneclient.exceptions import ClientException # noqa
|
||||
|
||||
from horizon import messages
|
||||
from horizon import tables
|
||||
|
||||
from openstack_dashboard import api
|
||||
|
||||
from openstack_dashboard.dashboards.admin.domains.constants \
|
||||
import DOMAINS_CREATE_URL
|
||||
from openstack_dashboard.dashboards.admin.domains.constants \
|
||||
import DOMAINS_INDEX_URL
|
||||
from openstack_dashboard.dashboards.admin.domains.constants \
|
||||
import DOMAINS_UPDATE_URL
|
||||
from openstack_dashboard.dashboards.admin.domains import constants
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -40,7 +35,7 @@ LOG = logging.getLogger(__name__)
|
||||
class CreateDomainLink(tables.LinkAction):
|
||||
name = "create"
|
||||
verbose_name = _("Create Domain")
|
||||
url = DOMAINS_CREATE_URL
|
||||
url = constants.DOMAINS_CREATE_URL
|
||||
classes = ("ajax-modal", "btn-create")
|
||||
|
||||
def allowed(self, request, domain):
|
||||
@ -50,7 +45,7 @@ class CreateDomainLink(tables.LinkAction):
|
||||
class EditDomainLink(tables.LinkAction):
|
||||
name = "edit"
|
||||
verbose_name = _("Edit")
|
||||
url = DOMAINS_UPDATE_URL
|
||||
url = constants.DOMAINS_UPDATE_URL
|
||||
classes = ("ajax-modal", "btn-edit")
|
||||
|
||||
def allowed(self, request, domain):
|
||||
@ -99,7 +94,7 @@ class DomainFilterAction(tables.FilterAction):
|
||||
class SetDomainContext(tables.Action):
|
||||
name = "set_domain_context"
|
||||
verbose_name = _("Set Domain Context")
|
||||
url = DOMAINS_INDEX_URL
|
||||
url = constants.DOMAINS_INDEX_URL
|
||||
preempt = True
|
||||
|
||||
def allowed(self, request, datum):
|
||||
@ -132,7 +127,7 @@ class SetDomainContext(tables.Action):
|
||||
class UnsetDomainContext(tables.Action):
|
||||
name = "clear_domain_context"
|
||||
verbose_name = _("Clear Domain Context")
|
||||
url = DOMAINS_INDEX_URL
|
||||
url = constants.DOMAINS_INDEX_URL
|
||||
preempt = True
|
||||
requires_input = False
|
||||
|
||||
|
@ -15,32 +15,24 @@
|
||||
# under the License.
|
||||
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django import http
|
||||
|
||||
from mox import IgnoreArg
|
||||
from mox import IsA
|
||||
from mox import IgnoreArg # noqa
|
||||
from mox import IsA # noqa
|
||||
|
||||
from horizon.workflows.views import WorkflowView
|
||||
from horizon.workflows import views
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.test import helpers as test
|
||||
|
||||
from openstack_dashboard.dashboards.admin.domains.constants \
|
||||
import DOMAINS_CREATE_URL as create_url
|
||||
from openstack_dashboard.dashboards.admin.domains.constants \
|
||||
import DOMAINS_INDEX_URL as index_url
|
||||
from openstack_dashboard.dashboards.admin.domains.constants \
|
||||
import DOMAINS_INDEX_VIEW_TEMPLATE
|
||||
from openstack_dashboard.dashboards.admin.domains.constants \
|
||||
import DOMAINS_UPDATE_URL as update_url
|
||||
from openstack_dashboard.dashboards.admin.domains.workflows import CreateDomain
|
||||
from openstack_dashboard.dashboards.admin.domains.workflows import UpdateDomain
|
||||
from openstack_dashboard.dashboards.admin.domains import constants
|
||||
from openstack_dashboard.dashboards.admin.domains import workflows
|
||||
|
||||
|
||||
DOMAINS_INDEX_URL = reverse(index_url)
|
||||
DOMAIN_CREATE_URL = reverse(create_url)
|
||||
DOMAIN_UPDATE_URL = reverse(update_url, args=[1])
|
||||
DOMAINS_INDEX_URL = reverse(constants.DOMAINS_INDEX_URL)
|
||||
DOMAIN_CREATE_URL = reverse(constants.DOMAINS_CREATE_URL)
|
||||
DOMAIN_UPDATE_URL = reverse(constants.DOMAINS_UPDATE_URL, args=[1])
|
||||
|
||||
|
||||
class DomainsViewTests(test.BaseAdminViewTests):
|
||||
@ -52,7 +44,7 @@ class DomainsViewTests(test.BaseAdminViewTests):
|
||||
|
||||
res = self.client.get(DOMAINS_INDEX_URL)
|
||||
|
||||
self.assertTemplateUsed(res, DOMAINS_INDEX_VIEW_TEMPLATE)
|
||||
self.assertTemplateUsed(res, constants.DOMAINS_INDEX_VIEW_TEMPLATE)
|
||||
self.assertItemsEqual(res.context['table'].data, self.domains.list())
|
||||
self.assertContains(res, 'Create Domain')
|
||||
self.assertContains(res, 'Edit')
|
||||
@ -69,7 +61,7 @@ class DomainsViewTests(test.BaseAdminViewTests):
|
||||
|
||||
res = self.client.get(DOMAINS_INDEX_URL)
|
||||
|
||||
self.assertTemplateUsed(res, DOMAINS_INDEX_VIEW_TEMPLATE)
|
||||
self.assertTemplateUsed(res, constants.DOMAINS_INDEX_VIEW_TEMPLATE)
|
||||
self.assertItemsEqual(res.context['table'].data, self.domains.list())
|
||||
self.assertNotContains(res, 'Create Domain')
|
||||
self.assertNotContains(res, 'Edit')
|
||||
@ -119,14 +111,14 @@ class DomainsViewTests(test.BaseAdminViewTests):
|
||||
formData = {'action': 'domains__set_domain_context__%s' % domain.id}
|
||||
res = self.client.post(DOMAINS_INDEX_URL, formData)
|
||||
|
||||
self.assertTemplateUsed(res, DOMAINS_INDEX_VIEW_TEMPLATE)
|
||||
self.assertTemplateUsed(res, constants.DOMAINS_INDEX_VIEW_TEMPLATE)
|
||||
self.assertItemsEqual(res.context['table'].data, [domain, ])
|
||||
self.assertContains(res, "<em>test_domain:</em>")
|
||||
|
||||
formData = {'action': 'domains__clear_domain_context__%s' % domain.id}
|
||||
res = self.client.post(DOMAINS_INDEX_URL, formData)
|
||||
|
||||
self.assertTemplateUsed(res, DOMAINS_INDEX_VIEW_TEMPLATE)
|
||||
self.assertTemplateUsed(res, constants.DOMAINS_INDEX_VIEW_TEMPLATE)
|
||||
self.assertItemsEqual(res.context['table'].data, self.domains.list())
|
||||
self.assertNotContains(res, "<em>test_domain:</em>")
|
||||
|
||||
@ -146,10 +138,11 @@ class CreateDomainWorkflowTests(test.BaseAdminViewTests):
|
||||
url = reverse('horizon:admin:domains:create')
|
||||
res = self.client.get(url)
|
||||
|
||||
self.assertTemplateUsed(res, WorkflowView.template_name)
|
||||
self.assertTemplateUsed(res, views.WorkflowView.template_name)
|
||||
|
||||
workflow = res.context['workflow']
|
||||
self.assertEqual(res.context['workflow'].name, CreateDomain.name)
|
||||
self.assertEqual(res.context['workflow'].name,
|
||||
workflows.CreateDomain.name)
|
||||
|
||||
self.assertQuerysetEqual(workflow.steps,
|
||||
['<CreateDomainInfo: create_domain>', ])
|
||||
@ -195,10 +188,11 @@ class UpdateDomainWorkflowTests(test.BaseAdminViewTests):
|
||||
|
||||
res = self.client.get(DOMAIN_UPDATE_URL)
|
||||
|
||||
self.assertTemplateUsed(res, WorkflowView.template_name)
|
||||
self.assertTemplateUsed(res, views.WorkflowView.template_name)
|
||||
|
||||
workflow = res.context['workflow']
|
||||
self.assertEqual(res.context['workflow'].name, UpdateDomain.name)
|
||||
self.assertEqual(res.context['workflow'].name,
|
||||
workflows.UpdateDomain.name)
|
||||
|
||||
self.assertQuerysetEqual(workflow.steps,
|
||||
['<UpdateDomainInfo: update_domain>', ])
|
||||
|
@ -14,17 +14,15 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.conf.urls.defaults import patterns
|
||||
from django.conf.urls.defaults import url
|
||||
from django.conf.urls.defaults import patterns # noqa
|
||||
from django.conf.urls.defaults import url # noqa
|
||||
|
||||
from openstack_dashboard.dashboards.admin.domains.views import CreateDomainView
|
||||
from openstack_dashboard.dashboards.admin.domains.views import IndexView
|
||||
from openstack_dashboard.dashboards.admin.domains.views import UpdateDomainView
|
||||
from openstack_dashboard.dashboards.admin.domains import views
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
url(r'^create$', CreateDomainView.as_view(), name='create'),
|
||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
||||
url(r'^create$', views.CreateDomainView.as_view(), name='create'),
|
||||
url(r'^(?P<domain_id>[^/]+)/update/$',
|
||||
UpdateDomainView.as_view(), name='update')
|
||||
views.UpdateDomainView.as_view(), name='update')
|
||||
)
|
||||
|
@ -14,8 +14,8 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tables
|
||||
@ -23,22 +23,16 @@ from horizon import workflows
|
||||
|
||||
from openstack_dashboard import api
|
||||
|
||||
from openstack_dashboard.dashboards.admin.domains.constants \
|
||||
import DOMAIN_INFO_FIELDS
|
||||
from openstack_dashboard.dashboards.admin.domains.constants \
|
||||
import DOMAINS_INDEX_URL
|
||||
from openstack_dashboard.dashboards.admin.domains.constants \
|
||||
import DOMAINS_INDEX_VIEW_TEMPLATE
|
||||
from openstack_dashboard.dashboards.admin.domains.tables import DomainsTable
|
||||
from openstack_dashboard.dashboards.admin.domains.workflows \
|
||||
import CreateDomain
|
||||
from openstack_dashboard.dashboards.admin.domains.workflows \
|
||||
import UpdateDomain
|
||||
from openstack_dashboard.dashboards.admin.domains import constants
|
||||
from openstack_dashboard.dashboards.admin.domains \
|
||||
import tables as project_tables
|
||||
from openstack_dashboard.dashboards.admin.domains \
|
||||
import workflows as project_workflows
|
||||
|
||||
|
||||
class IndexView(tables.DataTableView):
|
||||
table_class = DomainsTable
|
||||
template_name = DOMAINS_INDEX_VIEW_TEMPLATE
|
||||
table_class = project_tables.DomainsTable
|
||||
template_name = constants.DOMAINS_INDEX_VIEW_TEMPLATE
|
||||
|
||||
def get_data(self):
|
||||
domains = []
|
||||
@ -57,11 +51,11 @@ class IndexView(tables.DataTableView):
|
||||
|
||||
|
||||
class CreateDomainView(workflows.WorkflowView):
|
||||
workflow_class = CreateDomain
|
||||
workflow_class = project_workflows.CreateDomain
|
||||
|
||||
|
||||
class UpdateDomainView(workflows.WorkflowView):
|
||||
workflow_class = UpdateDomain
|
||||
workflow_class = project_workflows.UpdateDomain
|
||||
|
||||
def get_initial(self):
|
||||
initial = super(UpdateDomainView, self).get_initial()
|
||||
@ -73,10 +67,10 @@ class UpdateDomainView(workflows.WorkflowView):
|
||||
# get initial domain info
|
||||
domain_info = api.keystone.domain_get(self.request,
|
||||
domain_id)
|
||||
for field in DOMAIN_INFO_FIELDS:
|
||||
for field in constants.DOMAIN_INFO_FIELDS:
|
||||
initial[field] = getattr(domain_info, field, None)
|
||||
except Exception:
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to retrieve domain details.'),
|
||||
redirect=reverse(DOMAINS_INDEX_URL))
|
||||
redirect=reverse(constants.DOMAINS_INDEX_URL))
|
||||
return initial
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
@ -24,8 +24,7 @@ from horizon import workflows
|
||||
|
||||
from openstack_dashboard import api
|
||||
|
||||
from openstack_dashboard.dashboards.admin.domains.constants \
|
||||
import DOMAINS_INDEX_URL
|
||||
from openstack_dashboard.dashboards.admin.domains import constants
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
@ -61,7 +60,7 @@ class CreateDomain(workflows.Workflow):
|
||||
finalize_button_name = _("Create Domain")
|
||||
success_message = _('Created new domain "%s".')
|
||||
failure_message = _('Unable to create domain "%s".')
|
||||
success_url = DOMAINS_INDEX_URL
|
||||
success_url = constants.DOMAINS_INDEX_URL
|
||||
default_steps = (CreateDomainInfo, )
|
||||
|
||||
def format_status_message(self, message):
|
||||
@ -105,7 +104,7 @@ class UpdateDomain(workflows.Workflow):
|
||||
finalize_button_name = _("Save")
|
||||
success_message = _('Modified domain "%s".')
|
||||
failure_message = _('Unable to modify domain "%s".')
|
||||
success_url = DOMAINS_INDEX_URL
|
||||
success_url = constants.DOMAINS_INDEX_URL
|
||||
default_steps = (UpdateDomainInfo, )
|
||||
|
||||
def format_status_message(self, message):
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from openstack_dashboard import api
|
||||
|
||||
|
@ -16,8 +16,8 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import tables
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django import http
|
||||
|
||||
from mox import IsA
|
||||
from mox import IsA # noqa
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.test import helpers as test
|
||||
|
@ -18,16 +18,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.conf.urls.defaults import patterns
|
||||
from django.conf.urls.defaults import url
|
||||
from django.conf.urls.defaults import patterns # noqa
|
||||
from django.conf.urls.defaults import url # noqa
|
||||
|
||||
from openstack_dashboard.dashboards.admin.flavors.extras.views \
|
||||
import CreateView
|
||||
from openstack_dashboard.dashboards.admin.flavors.extras.views import EditView
|
||||
from openstack_dashboard.dashboards.admin.flavors.extras.views import IndexView
|
||||
from openstack_dashboard.dashboards.admin.flavors.extras import views
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
url(r'^create/$', CreateView.as_view(), name='create'),
|
||||
url(r'^(?P<key>[^/]+)/edit/$', EditView.as_view(), name='edit')
|
||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
||||
url(r'^create/$', views.CreateView.as_view(), name='create'),
|
||||
url(r'^(?P<key>[^/]+)/edit/$', views.EditView.as_view(), name='edit')
|
||||
)
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
@ -28,12 +28,10 @@ from horizon import tables
|
||||
|
||||
from openstack_dashboard import api
|
||||
|
||||
from openstack_dashboard.dashboards.admin.flavors.extras.forms \
|
||||
import CreateExtraSpec
|
||||
from openstack_dashboard.dashboards.admin.flavors.extras.forms \
|
||||
import EditExtraSpec
|
||||
from openstack_dashboard.dashboards.admin.flavors.extras.tables \
|
||||
import ExtraSpecsTable
|
||||
from openstack_dashboard.dashboards.admin.flavors.extras \
|
||||
import forms as project_forms
|
||||
from openstack_dashboard.dashboards.admin.flavors.extras \
|
||||
import tables as project_tables
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -52,7 +50,7 @@ class ExtraSpecMixin(object):
|
||||
|
||||
|
||||
class IndexView(ExtraSpecMixin, forms.ModalFormMixin, tables.DataTableView):
|
||||
table_class = ExtraSpecsTable
|
||||
table_class = project_tables.ExtraSpecsTable
|
||||
template_name = 'admin/flavors/extras/index.html'
|
||||
|
||||
def get_data(self):
|
||||
@ -68,7 +66,7 @@ class IndexView(ExtraSpecMixin, forms.ModalFormMixin, tables.DataTableView):
|
||||
|
||||
|
||||
class CreateView(ExtraSpecMixin, forms.ModalFormView):
|
||||
form_class = CreateExtraSpec
|
||||
form_class = project_forms.CreateExtraSpec
|
||||
template_name = 'admin/flavors/extras/create.html'
|
||||
|
||||
def get_initial(self):
|
||||
@ -79,7 +77,7 @@ class CreateView(ExtraSpecMixin, forms.ModalFormView):
|
||||
|
||||
|
||||
class EditView(ExtraSpecMixin, forms.ModalFormView):
|
||||
form_class = EditExtraSpec
|
||||
form_class = project_forms.EditExtraSpec
|
||||
template_name = 'admin/flavors/extras/edit.html'
|
||||
|
||||
def get_initial(self):
|
||||
|
@ -20,7 +20,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
|
@ -18,7 +18,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
import horizon
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import tables
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django import http
|
||||
from mox import IsA
|
||||
from mox import IsA # noqa
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.test import helpers as test
|
||||
|
@ -18,19 +18,17 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.conf.urls.defaults import include
|
||||
from django.conf.urls.defaults import patterns
|
||||
from django.conf.urls.defaults import url
|
||||
from django.conf.urls.defaults import include # noqa
|
||||
from django.conf.urls.defaults import patterns # noqa
|
||||
from django.conf.urls.defaults import url # noqa
|
||||
|
||||
from openstack_dashboard.dashboards.admin.flavors.extras \
|
||||
import urls as extras_urls
|
||||
from openstack_dashboard.dashboards.admin.flavors.views import CreateView
|
||||
from openstack_dashboard.dashboards.admin.flavors.views import EditView
|
||||
from openstack_dashboard.dashboards.admin.flavors.views import IndexView
|
||||
from openstack_dashboard.dashboards.admin.flavors import views
|
||||
|
||||
urlpatterns = patterns('openstack_dashboard.dashboards.admin.flavors.views',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
url(r'^create/$', CreateView.as_view(), name='create'),
|
||||
url(r'^(?P<id>[^/]+)/edit/$', EditView.as_view(), name='edit'),
|
||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
||||
url(r'^create/$', views.CreateView.as_view(), name='create'),
|
||||
url(r'^(?P<id>[^/]+)/edit/$', views.EditView.as_view(), name='edit'),
|
||||
url(r'^(?P<id>[^/]+)/extras/', include(extras_urls, namespace='extras')),
|
||||
)
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse_lazy # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
@ -29,16 +29,17 @@ from horizon import tables
|
||||
|
||||
from openstack_dashboard import api
|
||||
|
||||
from openstack_dashboard.dashboards.admin.flavors.forms import CreateFlavor
|
||||
from openstack_dashboard.dashboards.admin.flavors.forms import EditFlavor
|
||||
from openstack_dashboard.dashboards.admin.flavors.tables import FlavorsTable
|
||||
from openstack_dashboard.dashboards.admin.flavors \
|
||||
import forms as project_forms
|
||||
from openstack_dashboard.dashboards.admin.flavors \
|
||||
import tables as project_tables
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class IndexView(tables.DataTableView):
|
||||
table_class = FlavorsTable
|
||||
table_class = project_tables.FlavorsTable
|
||||
template_name = 'admin/flavors/index.html'
|
||||
|
||||
def get_data(self):
|
||||
@ -55,13 +56,13 @@ class IndexView(tables.DataTableView):
|
||||
|
||||
|
||||
class CreateView(forms.ModalFormView):
|
||||
form_class = CreateFlavor
|
||||
form_class = project_forms.CreateFlavor
|
||||
template_name = 'admin/flavors/create.html'
|
||||
success_url = reverse_lazy('horizon:admin:flavors:index')
|
||||
|
||||
|
||||
class EditView(forms.ModalFormView):
|
||||
form_class = EditFlavor
|
||||
form_class = project_forms.EditFlavor
|
||||
template_name = 'admin/flavors/edit.html'
|
||||
success_url = reverse_lazy('horizon:admin:flavors:index')
|
||||
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
|
@ -14,11 +14,11 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
import horizon
|
||||
|
||||
from openstack_dashboard.api.keystone import VERSIONS as IDENTITY_VERSIONS
|
||||
from openstack_dashboard.api.keystone import VERSIONS as IDENTITY_VERSIONS # noqa
|
||||
from openstack_dashboard.dashboards.admin import dashboard
|
||||
|
||||
|
||||
|
@ -16,22 +16,15 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django.template import defaultfilters
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import tables
|
||||
|
||||
from openstack_dashboard import api
|
||||
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_ADD_MEMBER_URL
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_CREATE_URL
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_MANAGE_URL
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_UPDATE_URL
|
||||
from openstack_dashboard.dashboards.admin.groups import constants
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
@ -45,7 +38,7 @@ STATUS_CHOICES = (
|
||||
class CreateGroupLink(tables.LinkAction):
|
||||
name = "create"
|
||||
verbose_name = _("Create Group")
|
||||
url = GROUPS_CREATE_URL
|
||||
url = constants.GROUPS_CREATE_URL
|
||||
classes = ("ajax-modal", "btn-create")
|
||||
|
||||
def allowed(self, request, group):
|
||||
@ -55,7 +48,7 @@ class CreateGroupLink(tables.LinkAction):
|
||||
class EditGroupLink(tables.LinkAction):
|
||||
name = "edit"
|
||||
verbose_name = _("Edit Group")
|
||||
url = GROUPS_UPDATE_URL
|
||||
url = constants.GROUPS_UPDATE_URL
|
||||
classes = ("ajax-modal", "btn-edit")
|
||||
|
||||
def allowed(self, request, group):
|
||||
@ -78,7 +71,7 @@ class DeleteGroupsAction(tables.DeleteAction):
|
||||
class ManageUsersLink(tables.LinkAction):
|
||||
name = "users"
|
||||
verbose_name = _("Modify Users")
|
||||
url = GROUPS_MANAGE_URL
|
||||
url = constants.GROUPS_MANAGE_URL
|
||||
classes = ("btn-edit")
|
||||
|
||||
def allowed(self, request, datum):
|
||||
@ -148,7 +141,7 @@ class AddMembersLink(tables.LinkAction):
|
||||
name = "add_user_link"
|
||||
verbose_name = _("Add...")
|
||||
classes = ("ajax-modal", "btn-create")
|
||||
url = GROUPS_ADD_MEMBER_URL
|
||||
url = constants.GROUPS_ADD_MEMBER_URL
|
||||
|
||||
def allowed(self, request, user=None):
|
||||
return api.keystone.keystone_can_edit_group()
|
||||
@ -183,7 +176,7 @@ class AddMembers(tables.BatchAction):
|
||||
data_type_plural = _("Users")
|
||||
classes = ("btn-create", )
|
||||
requires_input = True
|
||||
success_url = GROUPS_MANAGE_URL
|
||||
success_url = constants.GROUPS_MANAGE_URL
|
||||
|
||||
def allowed(self, request, user=None):
|
||||
return api.keystone.keystone_can_edit_group()
|
||||
|
@ -14,36 +14,23 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django import http
|
||||
|
||||
from mox import IgnoreArg
|
||||
from mox import IsA
|
||||
from mox import IgnoreArg # noqa
|
||||
from mox import IsA # noqa
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.test import helpers as test
|
||||
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_ADD_MEMBER_URL as add_member_url
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_CREATE_URL as create_url
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_INDEX_URL as index_url
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_INDEX_VIEW_TEMPLATE
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_MANAGE_URL as manage_url
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_MANAGE_VIEW_TEMPLATE
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_UPDATE_URL as update_url
|
||||
from openstack_dashboard.dashboards.admin.groups import constants
|
||||
|
||||
|
||||
GROUPS_INDEX_URL = reverse(index_url)
|
||||
GROUP_CREATE_URL = reverse(create_url)
|
||||
GROUP_UPDATE_URL = reverse(update_url, args=[1])
|
||||
GROUP_MANAGE_URL = reverse(manage_url, args=[1])
|
||||
GROUP_ADD_MEMBER_URL = reverse(add_member_url, args=[1])
|
||||
GROUPS_INDEX_URL = reverse(constants.GROUPS_INDEX_URL)
|
||||
GROUP_CREATE_URL = reverse(constants.GROUPS_CREATE_URL)
|
||||
GROUP_UPDATE_URL = reverse(constants.GROUPS_UPDATE_URL, args=[1])
|
||||
GROUP_MANAGE_URL = reverse(constants.GROUPS_MANAGE_URL, args=[1])
|
||||
GROUP_ADD_MEMBER_URL = reverse(constants.GROUPS_ADD_MEMBER_URL, args=[1])
|
||||
|
||||
|
||||
class GroupsViewTests(test.BaseAdminViewTests):
|
||||
@ -70,7 +57,7 @@ class GroupsViewTests(test.BaseAdminViewTests):
|
||||
|
||||
res = self.client.get(GROUPS_INDEX_URL)
|
||||
|
||||
self.assertTemplateUsed(res, GROUPS_INDEX_VIEW_TEMPLATE)
|
||||
self.assertTemplateUsed(res, constants.GROUPS_INDEX_VIEW_TEMPLATE)
|
||||
self.assertItemsEqual(res.context['table'].data, groups)
|
||||
if domain_id:
|
||||
for group in res.context['table'].data:
|
||||
@ -101,7 +88,7 @@ class GroupsViewTests(test.BaseAdminViewTests):
|
||||
|
||||
res = self.client.get(GROUPS_INDEX_URL)
|
||||
|
||||
self.assertTemplateUsed(res, GROUPS_INDEX_VIEW_TEMPLATE)
|
||||
self.assertTemplateUsed(res, constants.GROUPS_INDEX_VIEW_TEMPLATE)
|
||||
self.assertItemsEqual(res.context['table'].data, groups)
|
||||
|
||||
self.assertNotContains(res, 'Create Group')
|
||||
@ -189,7 +176,7 @@ class GroupsViewTests(test.BaseAdminViewTests):
|
||||
|
||||
res = self.client.get(GROUP_MANAGE_URL)
|
||||
|
||||
self.assertTemplateUsed(res, GROUPS_MANAGE_VIEW_TEMPLATE)
|
||||
self.assertTemplateUsed(res, constants.GROUPS_MANAGE_VIEW_TEMPLATE)
|
||||
self.assertItemsEqual(res.context['table'].data, group_members)
|
||||
|
||||
@test.create_stubs({api.keystone: ('user_list',
|
||||
|
@ -14,23 +14,19 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.conf.urls.defaults import patterns
|
||||
from django.conf.urls.defaults import url
|
||||
from django.conf.urls.defaults import patterns # noqa
|
||||
from django.conf.urls.defaults import url # noqa
|
||||
|
||||
from openstack_dashboard.dashboards.admin.groups.views import CreateView
|
||||
from openstack_dashboard.dashboards.admin.groups.views import IndexView
|
||||
from openstack_dashboard.dashboards.admin.groups.views import ManageMembersView
|
||||
from openstack_dashboard.dashboards.admin.groups.views import NonMembersView
|
||||
from openstack_dashboard.dashboards.admin.groups.views import UpdateView
|
||||
from openstack_dashboard.dashboards.admin.groups import views
|
||||
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^$', IndexView.as_view(), name='index'),
|
||||
url(r'^create$', CreateView.as_view(), name='create'),
|
||||
url(r'^$', views.IndexView.as_view(), name='index'),
|
||||
url(r'^create$', views.CreateView.as_view(), name='create'),
|
||||
url(r'^(?P<group_id>[^/]+)/update/$',
|
||||
UpdateView.as_view(), name='update'),
|
||||
views.UpdateView.as_view(), name='update'),
|
||||
url(r'^(?P<group_id>[^/]+)/manage_members/$',
|
||||
ManageMembersView.as_view(), name='manage_members'),
|
||||
views.ManageMembersView.as_view(), name='manage_members'),
|
||||
url(r'^(?P<group_id>[^/]+)/add_members/$',
|
||||
NonMembersView.as_view(), name='add_members'),
|
||||
views.NonMembersView.as_view(), name='add_members'),
|
||||
)
|
||||
|
@ -14,9 +14,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django.core.urlresolvers import reverse_lazy # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import forms
|
||||
@ -24,32 +24,16 @@ from horizon import tables
|
||||
|
||||
from openstack_dashboard import api
|
||||
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_ADD_MEMBER_AJAX_VIEW_TEMPLATE
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_ADD_MEMBER_VIEW_TEMPLATE
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_CREATE_VIEW_TEMPLATE
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_INDEX_URL
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_INDEX_VIEW_TEMPLATE
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_MANAGE_VIEW_TEMPLATE
|
||||
from openstack_dashboard.dashboards.admin.groups.constants \
|
||||
import GROUPS_UPDATE_VIEW_TEMPLATE
|
||||
from openstack_dashboard.dashboards.admin.groups.forms import CreateGroupForm
|
||||
from openstack_dashboard.dashboards.admin.groups.forms import UpdateGroupForm
|
||||
from openstack_dashboard.dashboards.admin.groups.tables \
|
||||
import GroupMembersTable
|
||||
from openstack_dashboard.dashboards.admin.groups.tables \
|
||||
import GroupNonMembersTable
|
||||
from openstack_dashboard.dashboards.admin.groups.tables import GroupsTable
|
||||
from openstack_dashboard.dashboards.admin.groups import constants
|
||||
from openstack_dashboard.dashboards.admin.groups \
|
||||
import forms as project_forms
|
||||
from openstack_dashboard.dashboards.admin.groups \
|
||||
import tables as project_tables
|
||||
|
||||
|
||||
class IndexView(tables.DataTableView):
|
||||
table_class = GroupsTable
|
||||
template_name = GROUPS_INDEX_VIEW_TEMPLATE
|
||||
table_class = project_tables.GroupsTable
|
||||
template_name = constants.GROUPS_INDEX_VIEW_TEMPLATE
|
||||
|
||||
def get_data(self):
|
||||
groups = []
|
||||
@ -64,15 +48,15 @@ class IndexView(tables.DataTableView):
|
||||
|
||||
|
||||
class CreateView(forms.ModalFormView):
|
||||
form_class = CreateGroupForm
|
||||
template_name = GROUPS_CREATE_VIEW_TEMPLATE
|
||||
success_url = reverse_lazy(GROUPS_INDEX_URL)
|
||||
form_class = project_forms.CreateGroupForm
|
||||
template_name = constants.GROUPS_CREATE_VIEW_TEMPLATE
|
||||
success_url = reverse_lazy(constants.GROUPS_INDEX_URL)
|
||||
|
||||
|
||||
class UpdateView(forms.ModalFormView):
|
||||
form_class = UpdateGroupForm
|
||||
template_name = GROUPS_UPDATE_VIEW_TEMPLATE
|
||||
success_url = reverse_lazy(GROUPS_INDEX_URL)
|
||||
form_class = project_forms.UpdateGroupForm
|
||||
template_name = constants.GROUPS_UPDATE_VIEW_TEMPLATE
|
||||
success_url = reverse_lazy(constants.GROUPS_INDEX_URL)
|
||||
|
||||
def get_object(self):
|
||||
if not hasattr(self, "_object"):
|
||||
@ -80,7 +64,7 @@ class UpdateView(forms.ModalFormView):
|
||||
self._object = api.keystone.group_get(self.request,
|
||||
self.kwargs['group_id'])
|
||||
except Exception:
|
||||
redirect = reverse(GROUPS_INDEX_URL)
|
||||
redirect = reverse(constants.GROUPS_INDEX_URL)
|
||||
exceptions.handle(self.request,
|
||||
_('Unable to update group.'),
|
||||
redirect=redirect)
|
||||
@ -125,8 +109,8 @@ class GroupManageMixin(object):
|
||||
|
||||
|
||||
class ManageMembersView(GroupManageMixin, tables.DataTableView):
|
||||
table_class = GroupMembersTable
|
||||
template_name = GROUPS_MANAGE_VIEW_TEMPLATE
|
||||
table_class = project_tables.GroupMembersTable
|
||||
template_name = constants.GROUPS_MANAGE_VIEW_TEMPLATE
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(ManageMembersView, self).get_context_data(**kwargs)
|
||||
@ -145,9 +129,9 @@ class ManageMembersView(GroupManageMixin, tables.DataTableView):
|
||||
|
||||
class NonMembersView(GroupManageMixin, forms.ModalFormMixin,
|
||||
tables.DataTableView):
|
||||
template_name = GROUPS_ADD_MEMBER_VIEW_TEMPLATE
|
||||
ajax_template_name = GROUPS_ADD_MEMBER_AJAX_VIEW_TEMPLATE
|
||||
table_class = GroupNonMembersTable
|
||||
template_name = constants.GROUPS_ADD_MEMBER_VIEW_TEMPLATE
|
||||
ajax_template_name = constants.GROUPS_ADD_MEMBER_AJAX_VIEW_TEMPLATE
|
||||
table_class = project_tables.GroupNonMembersTable
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(NonMembersView, self).get_context_data(**kwargs)
|
||||
|
@ -14,7 +14,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
import horizon
|
||||
from openstack_dashboard.dashboards.admin import dashboard
|
||||
|
@ -16,7 +16,7 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import tables
|
||||
from horizon.templatetags import sizeformat
|
||||
|
@ -14,9 +14,9 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django import http
|
||||
from mox import IsA
|
||||
from mox import IsA # noqa
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.test import helpers as test
|
||||
|
@ -14,14 +14,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.conf.urls.defaults import patterns
|
||||
from django.conf.urls.defaults import url
|
||||
from django.conf.urls.defaults import patterns # noqa
|
||||
from django.conf.urls.defaults import url # noqa
|
||||
|
||||
from openstack_dashboard.dashboards.admin.hypervisors.views \
|
||||
import AdminIndexView
|
||||
from openstack_dashboard.dashboards.admin.hypervisors import views
|
||||
|
||||
|
||||
urlpatterns = patterns(
|
||||
'openstack_dashboard.dashboards.admin.hypervisors.views',
|
||||
url(r'^$', AdminIndexView.as_view(), name='index')
|
||||
url(r'^$', views.AdminIndexView.as_view(), name='index')
|
||||
)
|
||||
|
@ -16,19 +16,19 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tables
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.dashboards.admin.hypervisors.tables import \
|
||||
AdminHypervisorsTable
|
||||
from openstack_dashboard.dashboards.admin.hypervisors \
|
||||
import tables as project_tables
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class AdminIndexView(tables.DataTableView):
|
||||
table_class = AdminHypervisorsTable
|
||||
table_class = project_tables.AdminHypervisorsTable
|
||||
template_name = 'admin/hypervisors/index.html'
|
||||
|
||||
def get_data(self):
|
||||
|
@ -18,7 +18,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
import horizon
|
||||
|
||||
|
@ -14,25 +14,19 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import tables
|
||||
|
||||
from openstack_dashboard.dashboards.project.images_and_snapshots \
|
||||
.images.tables import CreateImage
|
||||
from openstack_dashboard.dashboards.project.images_and_snapshots \
|
||||
.images.tables import DeleteImage
|
||||
from openstack_dashboard.dashboards.project.images_and_snapshots \
|
||||
.images.tables import EditImage
|
||||
from openstack_dashboard.dashboards.project.images_and_snapshots \
|
||||
.images.tables import ImagesTable
|
||||
from openstack_dashboard.dashboards.project.images_and_snapshots.images \
|
||||
import tables as project_tables
|
||||
|
||||
|
||||
class AdminCreateImage(CreateImage):
|
||||
class AdminCreateImage(project_tables.CreateImage):
|
||||
url = "horizon:admin:images:create"
|
||||
|
||||
|
||||
class AdminDeleteImage(DeleteImage):
|
||||
class AdminDeleteImage(project_tables.DeleteImage):
|
||||
def allowed(self, request, image=None):
|
||||
if image and image.protected:
|
||||
return False
|
||||
@ -40,14 +34,14 @@ class AdminDeleteImage(DeleteImage):
|
||||
return True
|
||||
|
||||
|
||||
class AdminEditImage(EditImage):
|
||||
class AdminEditImage(project_tables.EditImage):
|
||||
url = "horizon:admin:images:update"
|
||||
|
||||
def allowed(self, request, image=None):
|
||||
return True
|
||||
|
||||
|
||||
class AdminImagesTable(ImagesTable):
|
||||
class AdminImagesTable(project_tables.ImagesTable):
|
||||
name = tables.Column("name",
|
||||
link="horizon:admin:images:detail",
|
||||
verbose_name=_("Image Name"))
|
||||
|
@ -14,17 +14,17 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.conf import settings
|
||||
from django.core.urlresolvers import reverse
|
||||
from django.conf import settings # noqa
|
||||
from django.core.urlresolvers import reverse # noqa
|
||||
from django import http
|
||||
from django.test.utils import override_settings
|
||||
from django.test.utils import override_settings # noqa
|
||||
|
||||
from mox import IsA
|
||||
from mox import IsA # noqa
|
||||
|
||||
from openstack_dashboard import api
|
||||
from openstack_dashboard.test import helpers as test
|
||||
|
||||
from openstack_dashboard.dashboards.admin.images.tables import AdminImagesTable
|
||||
from openstack_dashboard.dashboards.admin.images import tables
|
||||
|
||||
|
||||
class ImageCreateViewTest(test.BaseAdminViewTests):
|
||||
@ -90,16 +90,16 @@ class ImagesViewTest(test.BaseAdminViewTests):
|
||||
settings.API_RESULT_PAGE_SIZE)
|
||||
|
||||
url = "?".join([reverse('horizon:admin:images:index'),
|
||||
"=".join([AdminImagesTable._meta.pagination_param,
|
||||
images[2].id])])
|
||||
"=".join([tables.AdminImagesTable._meta.pagination_param,
|
||||
images[2].id])])
|
||||
res = self.client.get(url)
|
||||
# get second page (items 2-4)
|
||||
self.assertEqual(len(res.context['images_table'].data),
|
||||
settings.API_RESULT_PAGE_SIZE)
|
||||
|
||||
url = "?".join([reverse('horizon:admin:images:index'),
|
||||
"=".join([AdminImagesTable._meta.pagination_param,
|
||||
images[4].id])])
|
||||
"=".join([tables.AdminImagesTable._meta.pagination_param,
|
||||
images[4].id])])
|
||||
res = self.client.get(url)
|
||||
# get third page (item 5)
|
||||
self.assertEqual(len(res.context['images_table'].data),
|
||||
|
@ -18,18 +18,17 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from django.conf.urls.defaults import patterns
|
||||
from django.conf.urls.defaults import url
|
||||
from django.conf.urls.defaults import patterns # noqa
|
||||
from django.conf.urls.defaults import url # noqa
|
||||
|
||||
from openstack_dashboard.dashboards.admin.images.views import CreateView
|
||||
from openstack_dashboard.dashboards.admin.images.views import DetailView
|
||||
from openstack_dashboard.dashboards.admin.images.views import IndexView
|
||||
from openstack_dashboard.dashboards.admin.images.views import UpdateView
|
||||
from openstack_dashboard.dashboards.admin.images import views
|
||||
|
||||
|
||||
urlpatterns = patterns('openstack_dashboard.dashboards.admin.images.views',
|
||||
url(r'^images/$', IndexView.as_view(), name='index'),
|
||||
url(r'^create/$', CreateView.as_view(), name='create'),
|
||||
url(r'^(?P<image_id>[^/]+)/update/$', UpdateView.as_view(), name='update'),
|
||||
url(r'^(?P<image_id>[^/]+)/detail/$', DetailView.as_view(), name='detail')
|
||||
url(r'^images/$', views.IndexView.as_view(), name='index'),
|
||||
url(r'^create/$', views.CreateView.as_view(), name='create'),
|
||||
url(r'^(?P<image_id>[^/]+)/update/$',
|
||||
views.UpdateView.as_view(), name='update'),
|
||||
url(r'^(?P<image_id>[^/]+)/detail/$',
|
||||
views.DetailView.as_view(), name='detail')
|
||||
)
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
import logging
|
||||
|
||||
from django.core.urlresolvers import reverse_lazy
|
||||
from django.utils.translation import ugettext_lazy as _
|
||||
from django.core.urlresolvers import reverse_lazy # noqa
|
||||
from django.utils.translation import ugettext_lazy as _ # noqa
|
||||
|
||||
from horizon import exceptions
|
||||
from horizon import tables
|
||||
@ -30,19 +30,16 @@ from openstack_dashboard import api
|
||||
from openstack_dashboard.dashboards.project \
|
||||
.images_and_snapshots.images import views
|
||||
|
||||
from openstack_dashboard.dashboards.admin.images.forms \
|
||||
import AdminCreateImageForm
|
||||
from openstack_dashboard.dashboards.admin.images.forms \
|
||||
import AdminUpdateImageForm
|
||||
from openstack_dashboard.dashboards.admin.images.tables \
|
||||
import AdminImagesTable
|
||||
from openstack_dashboard.dashboards.admin.images import forms
|
||||
from openstack_dashboard.dashboards.admin.images \
|
||||
import tables as project_tables
|
||||
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class IndexView(tables.DataTableView):
|
||||
table_class = AdminImagesTable
|
||||
table_class = project_tables.AdminImagesTable
|
||||
template_name = 'admin/images/index.html'
|
||||
|
||||
def has_more_data(self, table):
|
||||
@ -50,8 +47,8 @@ class IndexView(tables.DataTableView):
|
||||
|
||||
def get_data(self):
|
||||
images = []
|
||||
marker = self.request.GET.get(AdminImagesTable._meta.pagination_param,
|
||||
None)
|
||||
marker = self.request.GET.get(
|
||||
project_tables.AdminImagesTable._meta.pagination_param, None)
|
||||
try:
|
||||
images, self._more = api.glance.image_list_detailed(self.request,
|
||||
marker=marker,
|
||||
@ -65,13 +62,13 @@ class IndexView(tables.DataTableView):
|
||||
|
||||
class CreateView(views.CreateView):
|
||||
template_name = 'admin/images/create.html'
|
||||
form_class = AdminCreateImageForm
|
||||
form_class = forms.AdminCreateImageForm
|
||||
success_url = reverse_lazy('horizon:admin:images:index')
|
||||
|
||||
|
||||
class UpdateView(views.UpdateView):
|
||||
template_name = 'admin/images/update.html'
|
||||
form_class = AdminUpdateImageForm
|
||||
form_class = forms.AdminUpdateImageForm
|
||||
success_url = reverse_lazy('horizon:admin:images:index')
|
||||
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user