Skip to content
This repository has been archived by the owner on Dec 7, 2022. It is now read-only.
/ pulp Public archive

Commit

Permalink
Namespace plugin endpoints with Django app label
Browse files Browse the repository at this point in the history
  • Loading branch information
goosemania committed Jan 23, 2019
1 parent 7d32f8e commit 7654d5d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .travis/before_script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export PULP_CONTENT_HOST=localhost:8080
pulp-manager migrate --noinput

if [ "$TEST" != 'docs' ]; then
pulp-manager makemigrations pulp_file --noinput
pulp-manager makemigrations file --noinput
pulp-manager migrate --noinput
fi

Expand Down
6 changes: 3 additions & 3 deletions docs/contributing/dev-setup/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ the `Forklift <https://github.com/theforeman/forklift>`_ project and utilizes
`Ansible <https://docs.ansible.com/ansible/index.html>`_ roles and playbooks to provide supported
`Vagrant <https://docs.vagrantup.com/>`_ boxes that are more consistent with the user experience.

Clone the 'pulplift', 'pulp', and 'pulp-file' (or any plugins that you'll be working on) repos into
Clone the 'pulplift', 'pulp', and 'pulp_file' (or any plugins that you'll be working on) repos into
the same directory so that they are peers.

Navigate into the pulplift directory. Run the setup.sh script which will clone the 'forklift' and
Expand All @@ -23,10 +23,10 @@ start with /home/vagrant/devel/. For example::

pulp_install_plugins:
pulp-python:
app_label: "pulp_python"
app_label: "python"
source_dir: "/home/vagrant/devel/pulp_python"
pulp-file:
app_label: "pulp_file"
app_label: "file"
source_dir: "/home/vagrant/devel/pulp_file"

Once this is complete, take a look at available boxes with 'vagrant status' and then spin up your
Expand Down
12 changes: 9 additions & 3 deletions pulpcore/app/viewsets/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ def is_master_viewset(cls):

# ViewSet is related to a MasterModel subclass that doesn't have its own related
# master model, which makes this viewset a master viewset.
if (issubclass(cls.queryset.model, MasterModel) and
cls.queryset.model._meta.master_model is None):
if issubclass(cls.queryset.model, MasterModel) and \
cls.queryset.model._meta.master_model is None:
return True

return False
Expand Down Expand Up @@ -199,7 +199,13 @@ def endpoint_pieces(cls):
# no endpoint_name defined, need to get more specific in the MRO
continue

pieces = [master_endpoint_name, cls.endpoint_name]
# prepend endpoint of a plugin model with its Django app label
app_label = cls.queryset.model._meta.app_label
detail_endpoint_name = '{app_label}/{plugin_endpoint_name}'.format(
app_label=app_label,
plugin_endpoint_name=cls.endpoint_name)

pieces = [master_endpoint_name, detail_endpoint_name]

# ensure that neither piece is None/empty and that they are not equal.
if not all(pieces) or pieces[0] == pieces[1]:
Expand Down
7 changes: 4 additions & 3 deletions pulpcore/tests/functional/api/using_plugin/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
CONTENT_PATH
)

FILE_CONTENT_NAME = 'pulp_file.file'

FILE_CONTENT_NAME = 'file.file'

FILE_CONTENT_PATH = urljoin(CONTENT_PATH, 'file/files/')

FILE_REMOTE_PATH = urljoin(BASE_REMOTE_PATH, 'file/')
FILE_REMOTE_PATH = urljoin(BASE_REMOTE_PATH, 'file/file/')

FILE_PUBLISHER_PATH = urljoin(BASE_PUBLISHER_PATH, 'file/')
FILE_PUBLISHER_PATH = urljoin(BASE_PUBLISHER_PATH, 'file/file/')

FILE_FIXTURE_URL = urljoin(PULP_FIXTURES_BASE_URL, 'file/')
"""The URL to a file repository."""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ def test_02_sync_content(self):

self.assertIsNotNone(repo['_latest_version_href'])

content_hrefs = get_content(repo)['pulp_file.file']
content_hrefs = get_content(repo)[FILE_CONTENT_NAME]
self.assertEqual(
len(content_hrefs), FILE_FIXTURE_COUNT, content_hrefs
)
Expand Down Expand Up @@ -159,7 +159,7 @@ def test_03_remove_content(self):

self.assertIsNotNone(repo['_latest_version_href'])

content_hrefs = get_content(repo)['pulp_file.file']
content_hrefs = get_content(repo)[FILE_CONTENT_NAME]
self.assertEqual(
len(content_hrefs), FILE_FIXTURE_COUNT - 1, content_hrefs
)
Expand Down Expand Up @@ -202,7 +202,7 @@ def test_04_add_content(self):

self.assertIsNotNone(repo['_latest_version_href'])

content_hrefs = get_content(repo)['pulp_file.file']
content_hrefs = get_content(repo)[FILE_CONTENT_NAME]
self.assertEqual(
len(content_hrefs), FILE_FIXTURE_COUNT, content_hrefs
)
Expand Down

0 comments on commit 7654d5d

Please sign in to comment.