Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Tests and Doc] Implemented SavedView Model #5678

Merged
merged 45 commits into from
May 16, 2024

Conversation

HanlinMiao
Copy link
Contributor

Closes #1758

What's Changed

Test and documentation update for SavedView Model.

TODO

  • Explanation of Change(s)
  • Unit, Integration Tests
  • Documentation Updates (when adding/changing features)

reverse(list_view_name)
VIEW_NAMES.append(f"{app_label}:{model}_list")
except NoReverseMatch:
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we have any SavedView models that are missing list-views? That would seem like a bug to me.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consoleport template and other templates are missing list views. This try and except block is attempting to exclude them.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, but doesn't that mean we should set those models to is_saved_view_model = False for now?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the except: pass now?

nautobot/docs/development/apps/api/models/index.md Outdated Show resolved Hide resolved
nautobot/docs/release-notes/version-2.3.md Outdated Show resolved Hide resolved
nautobot/users/tests/test_filters.py Outdated Show resolved Hide resolved
nautobot/users/tests/test_views.py Outdated Show resolved Hide resolved
nautobot/users/tests/test_views.py Outdated Show resolved Hide resolved
nautobot/users/tests/test_views.py Outdated Show resolved Hide resolved
nautobot/users/tests/test_views.py Outdated Show resolved Hide resolved
nautobot/project-static/js/forms.js Outdated Show resolved Hide resolved
nautobot/project-static/js/forms.js Outdated Show resolved Hide resolved
@HanlinMiao HanlinMiao marked this pull request as ready for review May 10, 2024 19:48
<div class="modal-body">
{% csrf_token %}
<div class="form-group">
{% render_field form.name %}
<input type="hidden" id="view" name="view" value="{{view}}">
<input type="hidden" id="params" name="params" value="{{params}}">
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you test whether we need to urlencode params here if it contains special characters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Special characters are already encoded in params as you can see in the screenshot, e.g. # to %23. We actually have to decode it in the backend with unquote from urllib.parse
Screenshot 2024-05-10 at 7 59 49 PM

nautobot/core/views/generic.py Outdated Show resolved Hide resolved
nautobot/core/views/mixins.py Outdated Show resolved Hide resolved
nautobot/core/views/utils.py Outdated Show resolved Hide resolved
reverse(list_view_name)
VIEW_NAMES.append(f"{app_label}:{model}_list")
except NoReverseMatch:
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove the except: pass now?

nautobot/users/views.py Outdated Show resolved Hide resolved
nautobot/core/models/utils.py Outdated Show resolved Hide resolved
nautobot/extras/models/groups.py Outdated Show resolved Hide resolved
Comment on lines 265 to 266
# Custom action requires custom permission
self.add_permissions("users.clear_savedview")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's definitely not ideal... will be a tripping point for users setting up permissions.

nautobot/users/views.py Outdated Show resolved Hide resolved
nautobot/users/factory.py Outdated Show resolved Hide resolved
nautobot/users/factory.py Outdated Show resolved Hide resolved
nautobot/users/tests/test_views.py Outdated Show resolved Hide resolved
nautobot/users/views.py Show resolved Hide resolved
nautobot/users/views.py Outdated Show resolved Hide resolved
@HanlinMiao HanlinMiao merged commit 33c04c0 into u/hanlin-#1758 May 16, 2024
9 of 10 checks passed
@HanlinMiao HanlinMiao deleted the u/hanlin-#1758-tests-and-doc branch May 16, 2024 04:23
HanlinMiao added a commit that referenced this pull request May 18, 2024
* first commit

* model changes

* various changes to make update current view working

* create new view complete

* change savedview to a changelogged model

* hacking table_config workflow together

* material design icons update

* Last UI changes

* added changelogs

* address feedback from standup and PR

* more refactoring

* added SavedViewMixin and refactored models based on that

* fix unittests

* ruff fix

* unittests

* unittests

* address most PR feedback

* unittests

* address PR feedback

* refactor table_config, pagination_count, filter_params and sort_order into one field config

* address review feedback

* use urllib.parse.urlencode

* address review feedback

* revert changes from users: to user:

* revert minor change

* user vs users

* address PR feedback

* address PR feedback

* Make 'saved_view=...' query param imply the correct filtering, sorting, config, and pagination values (#5682)

* Make 'saved_view=...' query param imply the correct filtering, sorting, config, and pagination values

* Fix update behavior and create behavior when given an existing instance

* Test fix

* [Tests and Doc] Implemented SavedView Model (#5678)

* added factories and some documentation

* added api and view tests

* filter test and ruff fix

* include savedview.md in nav

* delete print statement

* user factory modifications

* fix user unittest

* delete comment

* address PR feedback

* add additional tests

* factory changes

* delete output.txt

* added saved view clear view

* added all_filters_removed non_filter_params

* added tooltip title to asterik

* added user guide for creating and updating saved view

* added refereneces to user guide

* completed user guide

* refactor create saved view

* address some pr feedback

* refactored SavedViewModal

* attempt to fix unittests

* fix screenshots

* specify is_saved_view_model=False on ComponentTemplateModel

* added clear_view_modal

* fixed saved view edit url

* address pr feedback on user guide

* fix all unittests

* markdownlint

* fix unittest

* ruff

* fix factory and tests

* refactored SavedViewClearView to custom action on SavedViewUIViewSet

* address PR feedback

* ruff fix

* pylint and unittest fixes

* fix unittest

* address pr feedabck

* refactor and remove is_saved_view_model=False on StaticGroup

* ruff fix

* unittests

* Enforce users:change_savedview instead of users:clear_savedview

* pylint

* fix clear_view_modal bug

* address PR feedback

* add json blob on saved_view_modal

* gray out json blob on saved_view_modal

* move get_table_class_string_from_view_name() to nautobot.core.utils.lookup

* update migration file

* include missing savedview doc

* refactor StaticGroupFactory

* unittests

---------

Co-authored-by: Glenn Matthews <glenn.matthews@networktocode.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants