-
Notifications
You must be signed in to change notification settings - Fork 10
Tables for export-, refresh- and forwarding configs to support pagination and automatic refresh. #195
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
Open
kaapstorm
wants to merge
29
commits into
master
Choose a base branch
from
nh/config-tables
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Tables for export-, refresh- and forwarding configs to support pagination and automatic refresh. #195
Changes from 3 commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
33bb108
feat(web): add get_config_page_size and get_page_from_request utilities
kaapstorm 3697f94
test: move export_config fixture to apps/exports/tests/fixtures.py
kaapstorm 0756739
feat(exports): add edit_url and last_run_log_url to ExportConfigBase
kaapstorm 11930b7
feat(exports): add config_table HTMX endpoint with pagination and ETag
kaapstorm 65466f2
refactor: move last_run() into ScheduleMixin
kaapstorm c97be5f
perf: use prefetched _all_runs in ScheduleMixin.last_run()
kaapstorm ba0af89
fix(exports): eliminate N+1 queries in config_table via prefetch_related
kaapstorm d343843
feat(exports): replace two-table layout with merged paginated config_…
kaapstorm a70577e
chore(exports): remove dead legacy exports context
kaapstorm 7a40433
feat(refreshes): add config_table partial with pagination, ETag, and …
kaapstorm fed1eec
feat(forwarding): add config_table partial with pagination, ETag, and…
kaapstorm 6e9b3a5
test: add smoke tests for list pages
kaapstorm 930dc31
feat: add status filter constant and pagination to run history views
kaapstorm 7af9250
feat: run history component — inline status filter dropdown, remove o…
kaapstorm cbb336f
feat: redesign detail page headers — inline buttons, Schedule field
kaapstorm ada5817
feat(exports): run history table — new columns, pagination, HTMX log …
kaapstorm 792f01f
feat(refreshes): run history table — new columns, pagination, HTMX lo…
kaapstorm 4c94eca
feat(forwarding): run history table — new columns, pagination, HTMX l…
kaapstorm 4ce4c77
test: smoke tests for detail pages and run history table endpoints
kaapstorm 2a47fa2
fix: Lint
kaapstorm 72c6d83
Move `edit_url` and `last_run_log_url` to subclasses
kaapstorm 60e30dc
Add tests with run instances
kaapstorm bbe1cb7
Reuse `VALID_CONFIG_PAGE_SIZES` const
kaapstorm 8a9233f
Rename "configs" to "page_obj"
kaapstorm 8719d9f
Suppress false-positive mypy error
kaapstorm 74322b0
Test the function's contract, not the constant's value
kaapstorm 3cfaab5
Drop unnecessary variable
kaapstorm fa3adbb
Nit: Variable names
kaapstorm c777228
Nit: Linebreaks
kaapstorm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| import pytest | ||
| from django.test import RequestFactory | ||
|
|
||
| from commcare_sync.views import get_config_page_size, get_page_from_request | ||
|
|
||
| VALID_PAGE_SIZES = [10, 20, 50] | ||
|
|
||
|
|
||
| class TestGetConfigPageSize: | ||
| def _req(self, params=''): | ||
| rf = RequestFactory() | ||
| return rf.get(f'/?{params}') | ||
|
|
||
| def test_default_is_10(self): | ||
| assert get_config_page_size(self._req()) == 10 | ||
|
jingcheng16 marked this conversation as resolved.
Outdated
|
||
|
|
||
| def test_valid_sizes_accepted(self): | ||
| for size in VALID_PAGE_SIZES: | ||
| assert get_config_page_size(self._req(f'page_size={size}')) == size | ||
|
|
||
| def test_invalid_size_falls_back_to_default(self): | ||
| assert get_config_page_size(self._req('page_size=7')) == 10 | ||
|
|
||
| def test_non_integer_falls_back_to_default(self): | ||
| assert get_config_page_size(self._req('page_size=abc')) == 10 | ||
|
|
||
|
|
||
| class TestGetPageFromRequest: | ||
| def _req(self, params=''): | ||
| rf = RequestFactory() | ||
| return rf.get(f'/?{params}') | ||
|
|
||
| def test_default_is_1(self): | ||
| assert get_page_from_request(self._req()) == 1 | ||
|
|
||
| def test_valid_page_returned(self): | ||
| assert get_page_from_request(self._req('page=3')) == 3 | ||
|
|
||
| def test_zero_clamped_to_1(self): | ||
| assert get_page_from_request(self._req('page=0')) == 1 | ||
|
|
||
| def test_negative_clamped_to_1(self): | ||
| assert get_page_from_request(self._req('page=-5')) == 1 | ||
|
|
||
| def test_non_integer_returns_1(self): | ||
| assert get_page_from_request(self._req('page=abc')) == 1 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.