Skip to content

Commit

Permalink
Update for django-ansible-base split (ansible#14783)
Browse files Browse the repository at this point in the history
* update paths and names

* temp to get tests passing

* fix typo
  • Loading branch information
jessicamack authored Jan 19, 2024
1 parent d91da39 commit 209747d
Show file tree
Hide file tree
Showing 21 changed files with 26 additions and 29 deletions.
4 changes: 2 additions & 2 deletions awx/api/generics.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
from rest_framework.renderers import StaticHTMLRenderer
from rest_framework.negotiation import DefaultContentNegotiation

from ansible_base.filters.rest_framework.field_lookup_backend import FieldLookupBackend
from ansible_base.utils.models import get_all_field_names
from ansible_base.rest_filters.rest_framework.field_lookup_backend import FieldLookupBackend
from ansible_base.lib.utils.models import get_all_field_names

# AWX
from awx.main.models import UnifiedJob, UnifiedJobTemplate, User, Role, Credential, WorkflowJobTemplateNode, WorkflowApprovalTemplate
Expand Down
2 changes: 1 addition & 1 deletion awx/api/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
# Django-Polymorphic
from polymorphic.models import PolymorphicModel

from ansible_base.utils.models import get_type_for_model
from ansible_base.lib.utils.models import get_type_for_model

# AWX
from awx.main.access import get_user_capabilities
Expand Down
2 changes: 1 addition & 1 deletion awx/conf/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Django
from django.db import models

from ansible_base.utils.models import prevent_search
from ansible_base.lib.utils.models import prevent_search

# AWX
from awx.main.models.base import CreatedModifiedModel
Expand Down
2 changes: 1 addition & 1 deletion awx/main/access.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# Django OAuth Toolkit
from awx.main.models.oauth import OAuth2Application, OAuth2AccessToken

from ansible_base.utils.validation import to_python_boolean
from ansible_base.lib.utils.validation import to_python_boolean

# AWX
from awx.main.utils import (
Expand Down
2 changes: 1 addition & 1 deletion awx/main/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from django.db import connection
from django.db.models.signals import pre_delete # noqa

from ansible_base.utils.models import prevent_search
from ansible_base.lib.utils.models import prevent_search

# AWX
from awx.main.models.base import BaseModel, PrimordialModel, accepts_json, CLOUD_INVENTORY_SOURCES, VERBOSITY_CHOICES # noqa
Expand Down
2 changes: 1 addition & 1 deletion awx/main/models/ad_hoc_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from django.utils.translation import gettext_lazy as _
from django.core.exceptions import ValidationError

from ansible_base.utils.models import prevent_search
from ansible_base.lib.utils.models import prevent_search

# AWX
from awx.api.versioning import reverse
Expand Down
2 changes: 1 addition & 1 deletion awx/main/models/ha.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import redis
from solo.models import SingletonModel

from ansible_base.utils.models import prevent_search
from ansible_base.lib.utils.models import prevent_search

# AWX
from awx import __version__ as awx_application_version
Expand Down
2 changes: 1 addition & 1 deletion awx/main/models/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
# REST Framework
from rest_framework.exceptions import ParseError

from ansible_base.utils.models import prevent_search
from ansible_base.lib.utils.models import prevent_search

# AWX
from awx.api.versioning import reverse
Expand Down
2 changes: 1 addition & 1 deletion awx/main/models/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# REST Framework
from rest_framework.exceptions import ParseError

from ansible_base.utils.models import prevent_search
from ansible_base.lib.utils.models import prevent_search

# AWX
from awx.api.versioning import reverse
Expand Down
2 changes: 1 addition & 1 deletion awx/main/models/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from django.utils.crypto import get_random_string
from django.utils.translation import gettext_lazy as _

from ansible_base.utils.models import prevent_search
from ansible_base.lib.utils.models import prevent_search

# AWX
from awx.main.models.rbac import Role, RoleAncestorEntry
Expand Down
2 changes: 1 addition & 1 deletion awx/main/models/notifications.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from jinja2 import sandbox, ChainableUndefined
from jinja2.exceptions import TemplateSyntaxError, UndefinedError, SecurityError

from ansible_base.utils.models import prevent_search
from ansible_base.lib.utils.models import prevent_search

# AWX
from awx.api.versioning import reverse
Expand Down
2 changes: 1 addition & 1 deletion awx/main/models/unified_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# Django-Polymorphic
from polymorphic.models import PolymorphicModel

from ansible_base.utils.models import prevent_search, get_type_for_model
from ansible_base.lib.utils.models import prevent_search, get_type_for_model

# AWX
from awx.main.models.base import CommonModelNameNotUnique, PasswordFieldsModel, NotificationFieldsModel
Expand Down
2 changes: 1 addition & 1 deletion awx/main/models/workflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from jinja2 import sandbox
from jinja2.exceptions import TemplateSyntaxError, UndefinedError, SecurityError

from ansible_base.utils.models import prevent_search
from ansible_base.lib.utils.models import prevent_search

# AWX
from awx.api.versioning import reverse
Expand Down
2 changes: 1 addition & 1 deletion awx/main/scheduler/task_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from django.conf import settings
from django.contrib.contenttypes.models import ContentType

from ansible_base.utils.models import get_type_for_model
from ansible_base.lib.utils.models import get_type_for_model

# AWX
from awx.main.dispatch.reaper import reap_job
Expand Down
2 changes: 1 addition & 1 deletion awx/main/tests/functional/api/test_survey_spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pytest
import json

from ansible_base.utils.models import get_type_for_model
from ansible_base.lib.utils.models import get_type_for_model

from awx.api.versioning import reverse
from awx.main.models.jobs import JobTemplate, Job
Expand Down
2 changes: 1 addition & 1 deletion awx/main/tests/unit/api/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Django
from rest_framework.exceptions import PermissionDenied

from ansible_base.filters.rest_framework.field_lookup_backend import FieldLookupBackend
from ansible_base.rest_filters.rest_framework.field_lookup_backend import FieldLookupBackend

from awx.main.models import (
AdHocCommand,
Expand Down
2 changes: 1 addition & 1 deletion awx/main/tests/unit/utils/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

from rest_framework.exceptions import ParseError

from ansible_base.utils.models import get_type_for_model
from ansible_base.lib.utils.models import get_type_for_model

from awx.main.utils import common
from awx.api.validators import HostnameRegexValidator
Expand Down
2 changes: 1 addition & 1 deletion awx/main/tests/unit/utils/test_filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def __init__(self):
@mock.patch('awx.main.utils.filters.get_model', return_value=mockHost())
class TestSmartFilterQueryFromString:
@mock.patch(
'ansible_base.filters.rest_framework.field_lookup_backend.get_fields_from_path', lambda model, path: ([model], path)
'ansible_base.rest_filters.rest_framework.field_lookup_backend.get_fields_from_path', lambda model, path: ([model], path)
) # disable field filtering, because a__b isn't a real Host field
@pytest.mark.parametrize(
"filter_string,q_expected",
Expand Down
2 changes: 1 addition & 1 deletion awx/main/utils/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def __init__(self, t):
else:
# detect loops and restrict access to sensitive fields
# this import is intentional here to avoid a circular import
from ansible_base.filters.rest_framework.field_lookup_backend import FieldLookupBackend
from ansible_base.rest_filters.rest_framework.field_lookup_backend import FieldLookupBackend

FieldLookupBackend().get_field_from_lookup(Host, k)
kwargs[k] = v
Expand Down
13 changes: 5 additions & 8 deletions awx/settings/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
'awx.ui',
'awx.sso',
'solo',
'ansible_base',
'ansible_base.rest_filters',
]

INTERNAL_IPS = ('127.0.0.1',)
Expand Down Expand Up @@ -1077,13 +1077,10 @@


# django-ansible-base
ANSIBLE_BASE_FEATURES = {'AUTHENTICATION': False, 'SWAGGER': False, 'FILTERING': True}
ANSIBLE_BASE_TEAM_MODEL = 'main.Team'
ANSIBLE_BASE_ORGANIZATION_MODEL = 'main.Organization'

from ansible_base import settings # noqa: E402
from ansible_base.lib import dynamic_config # noqa: E402

settings_file = os.path.join(os.path.dirname(settings.__file__), 'dynamic_settings.py')
settings_file = os.path.join(os.path.dirname(dynamic_config.__file__), 'dynamic_settings.py')
include(settings_file)

ANSIBLE_BASE_TEAM_MODEL = 'main.Team'

ANSIBLE_BASE_ORGANIZATION_MODEL = 'main.Organization'
2 changes: 1 addition & 1 deletion requirements/requirements_git.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ git+https://github.com/ansible/ansible-runner.git@devel#egg=ansible-runner
# specifically need https://github.com/robgolding/django-radius/pull/27
git+https://github.com/ansible/django-radius.git@develop#egg=django-radius
git+https://github.com/ansible/python3-saml.git@devel#egg=python3-saml
git+https://github.com/ansible/django-ansible-base.git@devel#egg=django-ansible-base[filtering]
django-ansible-base @ git+https://github.com/john-westcott-iv/django-ansible-base@app_split#egg=django-ansible-base[rest_filters]

0 comments on commit 209747d

Please sign in to comment.