diff --git a/core/inventory/api_v2.py b/core/inventory/api_v2.py index da98a3f..cf7afb9 100644 --- a/core/inventory/api_v2.py +++ b/core/inventory/api_v2.py @@ -35,8 +35,8 @@ def filter_items(items, query): @api_view(['GET']) @permission_classes([]) -#@permission_classes([IsAuthenticated]) -#@permission_required('view_item', raise_exception=True) +# @permission_classes([IsAuthenticated]) +# @permission_required('view_item', raise_exception=True) def search_items(request, event_slug, query): try: event = Event.objects.get(slug=event_slug) @@ -112,6 +112,10 @@ router.register(r'boxes', ContainerViewSet, basename='boxes') router.register(r'box', ContainerViewSet, basename='boxes') urlpatterns = router.urls + [ + # path('/items/', item), + # path('/items//', search_items), + # path('/item/', item), + # path('/item//', item_by_id), re_path(r'^(?P[\w-]+)/items/$', item, name='item'), re_path(r'^(?P[\w-]+)/items/(?P[-A-Za-z0-9+/]*={0,3})/$', search_items, name='search_items'), re_path(r'^(?P[\w-]+)/item/$', item, name='item'), diff --git a/core/tickets/api_v2.py b/core/tickets/api_v2.py index d32aca0..7286df8 100644 --- a/core/tickets/api_v2.py +++ b/core/tickets/api_v2.py @@ -160,10 +160,13 @@ router.register(r'tickets', IssueViewSet, basename='issues') # router.register(r'comments', CommentViewSet, basename='comments') router.register(r'shipping_vouchers', ShippingVoucherViewSet, basename='shipping_vouchers') + +# [-A-Za-z0-9+/]*={0,3} urlpatterns = ([ re_path(r'tickets/states/$', get_available_states, name='get_available_states'), re_path(r'^tickets/(?P\d+)/reply/$', reply, name='reply'), re_path(r'^tickets/(?P\d+)/comment/$', add_comment, name='add_comment'), re_path(r'^(?P[\w-]+)/tickets/manual/$', manual_ticket, name='manual_ticket'), - re_path(r'^(?P[\w-]+)/tickets/(?P.+)/$', search_issues, name='search_issues'), + re_path(r'^(?P[\w-]+)/tickets/(?P[-A-Za-z0-9+/]*={0,3})/$', search_issues, + name='search_issues'), ] + router.urls) diff --git a/core/tickets/tests/v2/test_tickets.py b/core/tickets/tests/v2/test_tickets.py index e76e422..6b7f90d 100644 --- a/core/tickets/tests/v2/test_tickets.py +++ b/core/tickets/tests/v2/test_tickets.py @@ -368,6 +368,7 @@ class IssueSearchTest(TestCase): def setUp(self): super().setUp() + self.event = Event.objects.create(slug='EVENT', name='Event') self.user = ExtendedUser.objects.create_user('testuser', 'test', 'test') self.user.user_permissions.add(*Permission.objects.all()) self.user.save() @@ -376,6 +377,6 @@ class IssueSearchTest(TestCase): def test_search(self): search_query = b64encode(b'abc').decode('utf-8') - response = self.client.get(f'/api/2/evt/tickets/{search_query}/') + response = self.client.get(f'/api/2/{self.event.slug}/tickets/{search_query}/') self.assertEqual(200, response.status_code) self.assertEqual([], response.json())