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

Upstream changes #1

Open
wants to merge 33 commits into
base: ohm
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
d9b1beb
Use try/except in the changeset ingestion commands (#682)
willemarcel Mar 27, 2024
f40ce72
Improve backfill_changesets command (#685)
willemarcel Apr 15, 2024
2540775
Bump sqlparse from 0.4.2 to 0.4.4 in /requirements (#663)
dependabot[bot] Apr 16, 2024
53e1ed1
Handle errors when creating changesets (#687)
willemarcel Apr 16, 2024
680789c
Switch to oauth2 authentication (#697)
willemarcel May 30, 2024
aee0c7f
Add page_size query_param to Reasons and Tags list views (#700)
willemarcel Jun 4, 2024
55db5b1
Increase throtling limits + fix oauth redirect_uri (#701)
willemarcel Jun 4, 2024
f69570a
Update DRF-gis to 1.0 (#705)
willemarcel Aug 7, 2024
c1ef15b
Set user-agent when making requests to the OSM API (#712)
willemarcel Aug 27, 2024
59281c7
Update osmcha lib and pyyaml
willemarcel Aug 27, 2024
2991254
Remove unneeded frontend app (#713)
willemarcel Aug 28, 2024
02f435b
Remove unneeded dependencies and update others (#715)
willemarcel Aug 28, 2024
8f8611e
Move /health endpoint to /api/v1/health (making it public) (#716)
jake-low Sep 24, 2024
da9df57
Fix minor typos in README (#609)
mzagorskirs Sep 26, 2024
cba2872
Update info in README about official instances (#717)
jake-low Oct 1, 2024
329df5f
Remove static/ directory and update frontend deployment docs (#718)
jake-low Oct 1, 2024
ac125e9
Fix OAuth2 env var names in example .env file
jake-low Sep 27, 2024
6ef05bd
Split Postgres client and server env vars
jake-low Sep 27, 2024
78f43f1
Simplify docker entrypoint script
jake-low Sep 30, 2024
d6f009c
Run osmcha-frontend container in compose app
jake-low Oct 1, 2024
d6e3667
Fix Postgres auth for Github Actions test workflow
jake-low Oct 1, 2024
4d950ce
Remove redundant volume definitions from docker-compose.yml
jake-low Oct 24, 2024
b537366
Move some production settings overrides to Dockerfile
jake-low Oct 30, 2024
cc0d27b
Remove broken 404 and 500 error pages
jake-low Oct 30, 2024
c283529
Update GitHub Actions docker build/push workflow
jake-low Nov 6, 2024
2087b98
Merge pull request #719 from OSMCha/jlow/docker-improvements
jake-low Nov 6, 2024
cbbceb6
Update values for ohm
Rub21 Jan 29, 2025
941eaa8
Fix conflicts with ohm branch
Rub21 Jan 29, 2025
f2ec5ab
Update url for osmcha
Rub21 Jan 30, 2025
5d65844
fix date issue with backfill_changesets
Rub21 Jan 31, 2025
74e5e63
Add script to fetch changeset from given changeset id
Rub21 Jan 31, 2025
18a9c0d
Update scripts
Rub21 Jan 31, 2025
1e9d9dd
Update actions to create images with gitsha
Rub21 Jan 31, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add page_size query_param to Reasons and Tags list views (OSMCha#700)
  • Loading branch information
willemarcel authored Jun 4, 2024
commit aee0c7f381e92fd82f97bf47f6749f25b07b2007
18 changes: 16 additions & 2 deletions osmchadjango/changeset/tests/test_reasons_tags_views.py
Original file line number Diff line number Diff line change
@@ -18,6 +18,7 @@ def setUp(self):
name='suspect word',
is_visible=False
)
SuspicionReasons.objects.create(name="another word", is_visible=True)
self.user = User.objects.create_user(
username='test',
password='password',
@@ -33,7 +34,7 @@ def setUp(self):
def test_view(self):
response = self.client.get(reverse('changeset:suspicion-reasons-list'))
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data.get('results')), 1)
self.assertEqual(len(response.data.get('results')), 2)
reason_dict = {
'id': self.reason_1.id,
'name': 'possible import',
@@ -44,11 +45,16 @@ def test_view(self):
}
self.assertIn(reason_dict, response.data.get('results'))

def test_pagination_params(self):
response = self.client.get(reverse("changeset:suspicion-reasons-list"), {"page_size": 1})
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data.get("results")), 1)

def test_admin_user_request(self):
self.client.login(username=self.user.username, password='password')
response = self.client.get(reverse('changeset:suspicion-reasons-list'))
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data.get('results')), 2)
self.assertEqual(len(response.data.get('results')), 3)


class TestTagAPIListView(APITestCase):
@@ -90,6 +96,14 @@ def test_view(self):
response.data.get('results')
)

def test_pagination_params(self):
Tag.objects.create(
name="Bad change", description="A changeset that added bad data."
)
response = self.client.get(reverse("changeset:tags-list"), {"page_size": 1})
self.assertEqual(response.status_code, 200)
self.assertEqual(len(response.data.get("results")), 1)

def test_admin_user_request(self):
self.client.login(username=self.user.username, password='password')
response = self.client.get(reverse('changeset:tags-list'))
9 changes: 9 additions & 0 deletions osmchadjango/changeset/views.py
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
DestroyAPIView
)
from rest_framework.parsers import JSONParser, MultiPartParser, FormParser
from rest_framework.pagination import PageNumberPagination
from rest_framework.permissions import IsAuthenticated, IsAdminUser
from rest_framework.response import Response
from rest_framework.renderers import JSONRenderer, BrowsableAPIRenderer
@@ -46,6 +47,12 @@ class StandardResultsSetPagination(GeoJsonPagination):
max_page_size = 500


class DefaultPagination(PageNumberPagination):
page_size = 50
page_size_query_param = 'page_size'
max_page_size = 500


class PaginatedCSVRenderer (CSVRenderer):
results_field = 'features'

@@ -157,6 +164,7 @@ def get_queryset(self):
class SuspicionReasonsListAPIView(ListAPIView):
"""List SuspicionReasons."""
serializer_class = SuspicionReasonsSerializer
pagination_class = DefaultPagination

def get_queryset(self):
if self.request and self.request.user.is_staff:
@@ -214,6 +222,7 @@ def remove_reason_from_changesets(self, request, pk):
class TagListAPIView(ListAPIView):
"""List Tags."""
serializer_class = TagSerializer
pagination_class = DefaultPagination

def get_queryset(self):
if self.request and self.request.user.is_staff: