Commit 7d98fc11 authored by Bengfort's avatar Bengfort
Browse files

rm UUID compatibility interface

see !13
parent 9d0207e0
Pipeline #9070 passed with stages
in 2 minutes and 48 seconds
......@@ -153,10 +153,8 @@ class InvitationApiView(View):
})
def put(self, request, *args, **kwargs):
if 'schedule__uuid' in kwargs:
schedule = get_object_or_404(Schedule, uuid=kwargs.pop('schedule__uuid'))
kwargs['schedule_id'] = schedule.id
invitation, _ = Invitation.objects.get_or_create(**kwargs)
schedule = get_object_or_404(Schedule, uuid=kwargs['schedule__uuid'])
invitation, _ = Invitation.objects.get_or_create(schedule=schedule, token=kwargs['token'])
return HttpResponse(status=204)
def delete(self, request, *args, **kwargs):
......
......@@ -7,31 +7,6 @@ from .main.models import Schedule
from .main.models import Invitation
class TestLegacyInvitationApiView(TestCase):
def setUp(self):
self.client.defaults['HTTP_AUTHORIZATION'] = 'token ' + settings.API_TOKEN
def test_get(self):
invitation = baker.make(Invitation)
url = '/api/{}/{}/'.format(invitation.schedule.id, invitation.token)
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
def test_put(self):
schedule = baker.make(Schedule)
url = '/api/{}/{}/'.format(schedule.id, 'sometoken')
response = self.client.put(url)
self.assertEqual(response.status_code, 204)
self.assertTrue(Invitation.objects.filter(token='sometoken').exists())
def test_delete(self):
invitation = baker.make(Invitation)
url = '/api/{}/{}/'.format(invitation.schedule.id, invitation.token)
response = self.client.delete(url)
self.assertEqual(response.status_code, 204)
self.assertFalse(Invitation.objects.filter(token=invitation.token).exists())
class TestInvitationApiView(TestCase):
def setUp(self):
self.client.defaults['HTTP_AUTHORIZATION'] = 'token ' + settings.API_TOKEN
......
......@@ -35,25 +35,13 @@ from .main.views import ScheduleUpdateView
urlpatterns = [
path('', ScheduleListView.as_view(), name='index'),
path('new/', ScheduleCreateView.as_view(), name='schedule-create'),
path('<int:pk>/', ScheduleUpdateView.as_view(), name='schedule-update-legacy'),
path('<uuid:uuid>/', ScheduleUpdateView.as_view(), name='schedule-update'),
path('<int:pk>/delete/', ScheduleDeleteView.as_view(), name='schedule-delete-legacy'),
path('<uuid:uuid>/delete/', ScheduleDeleteView.as_view(), name='schedule-delete'),
path(
'invitations/<int:schedule_id>/<token>/',
InvitationUpdateView.as_view(),
name='invitation-legacy',
),
path(
'invitations/<uuid:schedule__uuid>/<token>/',
InvitationUpdateView.as_view(),
name='invitation',
),
path(
'api/<int:schedule_id>/<token>/',
InvitationApiView.as_view(),
name='api-invitation-legacy',
),
path(
'api/<uuid:schedule__uuid>/<token>/',
InvitationApiView.as_view(),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment