From 1eda45ffeb6dbaf5d37545305b57beb16c02653d Mon Sep 17 00:00:00 2001 From: Matt Griswold Date: Sat, 30 Oct 2021 10:20:04 -0500 Subject: [PATCH] ignore new ixf field (#1082) * ignore new ixf field * pre-commit * gh actions linting fix --- .github/workflows/tests.yml | 19 +++++-------------- Ctl/VERSION | 2 +- docs/dev/commands.md | 1 - docs/dev/design.md | 8 ++++---- docs/dev/modules.md | 1 - docs/dev/modules/api_key_views.py.md | 2 +- docs/dev/modules/autocomplete_views.py.md | 1 - docs/dev/modules/context.py.md | 2 +- docs/dev/modules/data_views.py.md | 2 +- docs/dev/modules/db_router.py.md | 1 - docs/dev/modules/import_views.py.md | 2 +- docs/dev/modules/mail.py.md | 2 +- docs/dev/modules/org_admin_views.py.md | 2 +- docs/dev/modules/renderers.py.md | 1 - docs/dev/modules/request.py.md | 2 +- docs/dev/modules/search.py.md | 2 +- docs/dev/modules/signals.py.md | 2 +- docs/dev/modules/validators.py.md | 2 +- docs/dev/search.md | 2 +- docs/dev/settings.md | 2 +- docs/dev/users_and_permissios.md | 8 ++++---- docs/dev/views.md | 12 +++++------- peeringdb_server/client_adaptor/backend.py | 6 +++++- 23 files changed, 36 insertions(+), 48 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 6c0ab6d4..ce69ec59 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -9,33 +9,24 @@ jobs: steps: - uses: actions/checkout@v2 - uses: actions/setup-python@v2 - - uses: actions/cache@v2 with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip - restore-keys: ${{ runner.os }}-pip + python-version: 3.9 - name: Install Poetry - uses: snok/install-poetry@v1.1.1 + uses: snok/install-poetry@v1 with: virtualenvs-create: true virtualenvs-in-project: true - # virtualenvs-path: ~/.venv - + installer-parallel: true - name: Load cached venv id: cached-poetry-dependencies uses: actions/cache@v2 with: path: .venv key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }} - - name: Ensure cache is healthy - if: steps.cache.outputs.cache-hit == 'true' - shell: bash - run: timeout 10s poetry run pip --version || rm -rf .venv - # install dependencies if cache does not exist - name: Check cache and install dependencies - run: poetry install - + run: poetry install --no-interaction --no-root + if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true' - name: Run linters run: | source .venv/bin/activate diff --git a/Ctl/VERSION b/Ctl/VERSION index 30397faa..70ff1993 100644 --- a/Ctl/VERSION +++ b/Ctl/VERSION @@ -1 +1 @@ -2.31.1 \ No newline at end of file +2.31.1 diff --git a/docs/dev/commands.md b/docs/dev/commands.md index 14f16b7a..9eed8b47 100644 --- a/docs/dev/commands.md +++ b/docs/dev/commands.md @@ -118,4 +118,3 @@ Command line whois. ## pdb_wipe.py Wipe all peering data. - diff --git a/docs/dev/design.md b/docs/dev/design.md index 27c7b707..8f708878 100644 --- a/docs/dev/design.md +++ b/docs/dev/design.md @@ -24,7 +24,7 @@ Generally speaking, anything that is going to be exposed to the public on Peerin ### Migrations -For concrete models, `django-peeringdb` and `peeringdb_server` maintain their own set of migrations. +For concrete models, `django-peeringdb` and `peeringdb_server` maintain their own set of migrations. Please make sure that when you add fields or models to django-peeringdb that migrations for the changes exist in both places. @@ -37,7 +37,7 @@ Refer to [django migration documentation](https://docs.djangoproject.com/en/3.2/ - has a parent `Organization` relationship - `Network` (`net`): represents a network (asn) - has a parent `Organization` relationship -- `InternetExchange` (`ix`): represents an internet exchange +- `InternetExchange` (`ix`): represents an internet exchange - has a parent `Organization` relationship - `IXLan` (`ixlan`): represents LAN information for an exchange - has a parent `InternetExchange` relationship @@ -68,7 +68,7 @@ Through `django-handleref` each of the above objects maintains a status field th - `ok`: object is approved and currently live - `pending`: object is pending approval through admin-com -- `deleted`: object is marked as deleted +- `deleted`: object is marked as deleted ### Soft delete @@ -76,7 +76,7 @@ With the exception of stale `poc` objects, public peering data is *never* hard d Soft deleting an object means flipping its status from `ok` to `deleted`. -Note that `django-handleref` overrides the model's `delete` method to do this automatically. +Note that `django-handleref` overrides the model's `delete` method to do this automatically. ```py net = Network.objects.get(id=20) diff --git a/docs/dev/modules.md b/docs/dev/modules.md index 9701a0e8..5de036fd 100644 --- a/docs/dev/modules.md +++ b/docs/dev/modules.md @@ -280,4 +280,3 @@ View definitions: - Entity views (network, facility, internet exchange and organization) - Sponsorships - User Registration - diff --git a/docs/dev/modules/api_key_views.py.md b/docs/dev/modules/api_key_views.py.md index 711fae31..ee52a843 100644 --- a/docs/dev/modules/api_key_views.py.md +++ b/docs/dev/modules/api_key_views.py.md @@ -35,4 +35,4 @@ Save key permissions for the specified org and key. Perms should be a dict of permissioning ids and permission levels. ---- \ No newline at end of file +--- diff --git a/docs/dev/modules/autocomplete_views.py.md b/docs/dev/modules/autocomplete_views.py.md index fa450585..fa985451 100644 --- a/docs/dev/modules/autocomplete_views.py.md +++ b/docs/dev/modules/autocomplete_views.py.md @@ -288,4 +288,3 @@ ToolHistory(peeringdb_server.autocomplete_views.CommandLineToolHistoryAutocomple ``` Autocomplete for command line tools that were run via the admin ui. - diff --git a/docs/dev/modules/context.py.md b/docs/dev/modules/context.py.md index 0eb6823a..9054d433 100644 --- a/docs/dev/modules/context.py.md +++ b/docs/dev/modules/context.py.md @@ -15,4 +15,4 @@ Will yield the current request, if there is one. To se the current request for the context pass it to the request parameter. ---- \ No newline at end of file +--- diff --git a/docs/dev/modules/data_views.py.md b/docs/dev/modules/data_views.py.md index 83291861..6f36798b 100644 --- a/docs/dev/modules/data_views.py.md +++ b/docs/dev/modules/data_views.py.md @@ -56,4 +56,4 @@ available to site administrators. Return all sponsorships. ---- \ No newline at end of file +--- diff --git a/docs/dev/modules/db_router.py.md b/docs/dev/modules/db_router.py.md index 2b9aebf6..8e446516 100644 --- a/docs/dev/modules/db_router.py.md +++ b/docs/dev/modules/db_router.py.md @@ -27,4 +27,3 @@ TestRouter(peeringdb_server.db_router.DatabaseRouter) A very basic database router that routes to a different read and write db. - diff --git a/docs/dev/modules/import_views.py.md b/docs/dev/modules/import_views.py.md index 75442849..e5248a13 100644 --- a/docs/dev/modules/import_views.py.md +++ b/docs/dev/modules/import_views.py.md @@ -12,4 +12,4 @@ Define ix-f import preview, review and post-mortem views. A simple decorator to enable basic auth for a specific view. ---- \ No newline at end of file +--- diff --git a/docs/dev/modules/mail.py.md b/docs/dev/modules/mail.py.md index e48661bb..5d3f95ed 100644 --- a/docs/dev/modules/mail.py.md +++ b/docs/dev/modules/mail.py.md @@ -39,4 +39,4 @@ Arguments: - entity_source : handleref object, entity that was merged - entity_target : handleref object, entity that was merged into ---- \ No newline at end of file +--- diff --git a/docs/dev/modules/org_admin_views.py.md b/docs/dev/modules/org_admin_views.py.md index 59a37d1c..0a275148 100644 --- a/docs/dev/modules/org_admin_views.py.md +++ b/docs/dev/modules/org_admin_views.py.md @@ -72,4 +72,4 @@ Should be below org_admin_required. Also sets "user" in kwargs. ---- \ No newline at end of file +--- diff --git a/docs/dev/modules/renderers.py.md b/docs/dev/modules/renderers.py.md index 2f7d448f..7e46fae9 100644 --- a/docs/dev/modules/renderers.py.md +++ b/docs/dev/modules/renderers.py.md @@ -58,4 +58,3 @@ MungeRenderer(rest_framework.renderers.BaseRenderer) All renderers should extend this class, setting the `media_type` and `format` attributes, and override the `.render()` method. - diff --git a/docs/dev/modules/request.py.md b/docs/dev/modules/request.py.md index a89546da..94f5fbf6 100644 --- a/docs/dev/modules/request.py.md +++ b/docs/dev/modules/request.py.md @@ -19,4 +19,4 @@ context. If no request can be obtained this will return False. ---- \ No newline at end of file +--- diff --git a/docs/dev/modules/search.py.md b/docs/dev/modules/search.py.md index 91bb7035..83a9e68e 100644 --- a/docs/dev/modules/search.py.md +++ b/docs/dev/modules/search.py.md @@ -20,4 +20,4 @@ Search searchable objects (ixp, network, facility ...) by term. Returns result dict. ---- \ No newline at end of file +--- diff --git a/docs/dev/modules/signals.py.md b/docs/dev/modules/signals.py.md index a76e419a..834229ee 100644 --- a/docs/dev/modules/signals.py.md +++ b/docs/dev/modules/signals.py.md @@ -82,4 +82,4 @@ and update net_count for the related InternetExchange. Updates 'attribute' field in Network whenever it's called. ---- \ No newline at end of file +--- diff --git a/docs/dev/modules/validators.py.md b/docs/dev/modules/validators.py.md index 30cce0a9..1e2012f0 100644 --- a/docs/dev/modules/validators.py.md +++ b/docs/dev/modules/validators.py.md @@ -97,4 +97,4 @@ Raises: Returns: - str: zipcode ---- \ No newline at end of file +--- diff --git a/docs/dev/search.md b/docs/dev/search.md index fc53148c..985d8fd4 100644 --- a/docs/dev/search.md +++ b/docs/dev/search.md @@ -16,7 +16,7 @@ REST API filtering happens when filter parameters are passed to REST API list re This is almost a straight pass through to django query set filters (after some sanitizing of course). -Most querying logic for this is defined in `rest.py` +Most querying logic for this is defined in `rest.py` Note that there is some extra effort involved for more intricate query filters, such as relationship queries or customized queries like the `whereis` filter for `ixpfx` diff --git a/docs/dev/settings.md b/docs/dev/settings.md index 4d31562f..7c19e0ac 100644 --- a/docs/dev/settings.md +++ b/docs/dev/settings.md @@ -14,6 +14,6 @@ export GOOGLE_GEOLOC_API_KEY=abcde When adding a setting use the `set_from_env` and the `set_option` wrappers to do so. -These ensure that the overrides mentioned above are functional. Use `set_from_env` for variables you anticipate are definitely going to be overridden on a per environment basis. +These ensure that the overrides mentioned above are functional. Use `set_from_env` for variables you anticipate are definitely going to be overridden on a per environment basis. Use `set_option` for everything else. diff --git a/docs/dev/users_and_permissios.md b/docs/dev/users_and_permissios.md index c482fc1a..1b5a12a9 100644 --- a/docs/dev/users_and_permissios.md +++ b/docs/dev/users_and_permissios.md @@ -1,4 +1,4 @@ -## django-grainy +## django-grainy PeeringDB users [grainy](https://github.com/20c/grainy) and [django-grainy](https://github.com/20c/django-grainy) to manage user permissions. @@ -28,10 +28,10 @@ and all the objects permissioned within it. A user given permissions to `peeringdb.organization.1.network.1` would only have permissions to the network with id `1` assuming that network belongs to the organization with id `1`. -A user given permissions to `peeringdb.organization` has permissions to ALL organizations and ALL objects +A user given permissions to `peeringdb.organization` has permissions to ALL organizations and ALL objects permissioned within them. -A user given permissions to `peeringdb.organization.*.network.*.poc_set.users` has permission to view all `user` +A user given permissions to `peeringdb.organization.*.network.*.poc_set.users` has permission to view all `user` visible points of contact. ### Setting permissions @@ -59,6 +59,6 @@ When handling a django request to the REST API, it needs to be determined who or It is either a guest (unauthenticated user), a user (through session or user api key auth) or an organization (through org api key auth). -The logic for this exists in `permissions.py`. +The logic for this exists in `permissions.py`. This is already wired up to all API views, but needs to be kept in mind when adding new views. diff --git a/docs/dev/views.md b/docs/dev/views.md index 96336d42..8dd84e2a 100644 --- a/docs/dev/views.md +++ b/docs/dev/views.md @@ -13,7 +13,7 @@ PeeringDB uses the following third party js libraries: - [20c-edit](https://github.com/20c/js-edit) wiring of forms to REST API, seamless switching between view and editor - [20c-list-util](https://github.com/20c/js-listutil) list filtering and sorting - [autocomplete-light](https://django-autocomplete-light.readthedocs.io/en/master/) autocomplete fields -- [dom-purify](https://github.com/cure53/DOMPurify) santize DOM +- [dom-purify](https://github.com/cure53/DOMPurify) santize DOM - [showdown](https://github.com/showdownjs/showdown) markdown to html - [js-cookie](https://github.com/js-cookie/js-cookie) cookie utils @@ -26,7 +26,7 @@ PeeringDB specific javascript code can be found in these files: - advanced search - custom 20c-edit input types - custom 20c-edit editor handlers - - data loaders + - data loaders - ix-f post mortem, preview and review tools - quick search - api key permissions @@ -85,7 +85,7 @@ Some types have specific properties, find those listed below: - `flags`: renders checkboxes for boolean flags - `value` (`list`): one entry for each checkbox (flag), each item should be a `dict` containing `name` and `value` keys (*required*) -- `url` +- `url` - `list` - `data` (`str`): data loader name (*required*) - reference to data loaders below - `multiple` (`bool`): allow multi select @@ -133,7 +133,7 @@ therefore the value of `"my_organizations"` in the response is NOT arbitrary. #### `urls.py` -URL routing needs to be set up: +URL routing needs to be set up: ```py url(r"^data/my_organizations$", peeringdb_server.data_views.my_organizations), @@ -141,7 +141,7 @@ URL routing needs to be set up: #### `static/peeringdb.js` -The front-end needs to assign the loader: +The front-end needs to assign the loader: ```js twentyc.data.loaders.assign("my_organizations", "data"); @@ -177,5 +177,3 @@ In instances where you want to check permissions after the data has been seriali ``` PeeringDB uses [django-grainy](https://github.com/20c/django-grainy) for granular permission checking and handling. - - diff --git a/peeringdb_server/client_adaptor/backend.py b/peeringdb_server/client_adaptor/backend.py index 1a69353a..a0a40037 100644 --- a/peeringdb_server/client_adaptor/backend.py +++ b/peeringdb_server/client_adaptor/backend.py @@ -56,7 +56,7 @@ class Backend(BaseBackend): return self.CONCRETE_MAP.get(cls) @reftag_to_cls - def get_fields(self, concrete): + def get_fields(self, concrete, ignore_fields=None): """ Sync currently doesnt support OneToOne relationships and none of the ones that exist in peeringdb_server @@ -66,12 +66,16 @@ class Backend(BaseBackend): Here we make sure to not process OneToOneRel relationships """ + if not ignore_fields: + ignore_fields = ["ixf_import_request_user"] _fields = super().get_fields(concrete) fields = [] for field in _fields: if isinstance(field, OneToOneRel): continue + if field.name in ignore_fields: + continue fields.append(field) return fields