예제 #1
0
 def test_get_request_redirects_to_login_if_user_not_logged_in(self):
     request = self.factory.get('/fake/')
     request.user = ''
     response = TripDetailView.as_view()(request)
     self.assertEqual(response.status_code, 302)
     redirect_url = reverse('authentication:login') + '?next=' + '/fake/'
     self.assertEqual(response.url, redirect_url)
예제 #2
0
 def test_view_uses_correct_template(self):
     request = self.factory.get('/fake/')
     request.user = self.user
     response = TripDetailView.as_view()(request, pk=self.trip.id)
     self.assertTrue('trips/detail.html' in response.template_name)
예제 #3
0
 def test_200_response_from_get_request(self):
     request = self.factory.get('/fake/')
     request.user = self.user
     response = TripDetailView.as_view()(request, pk=self.trip.id)
     self.assertEqual(response.status_code, 200)
예제 #4
0
urlpatterns = [
    path('', home_view, name='home'),
    path('contact/', contact_view),
    path('product/', product_detail_view),
    path('create/', product_create_view),
    path('about/', about_view),
    path('admin/', admin.site.urls),
    # Login and Profile
    path('register/', user_views.register, name='register'),
    path('profile/', user_views.profile, name='profile'),
    path('login/', auth_views.LoginView.as_view(template_name='users/login.html'), name='login'),
    path('logout/', auth_views.LogoutView.as_view(template_name='users/logout.html'), name='logout'),
    # Flights
    path('flights/', search_flights_view, name='flights'),
    path('result_flights/', flights_results_view, name='result_flights'),
    path('add_flight/', add_flight, name='add_flight'),
    # Hotels
    path('hotels/<str:location>', search_hotels_view, name='hotels'),
    # Trips
    path('trips/', login_required(user_views.FlightListView.as_view()), name='trips'),
    path('dashboard/', login_required(TripsDashboard.as_view()), name='dashboard'),
    path('add_trip/', add_trip, name='add_trip'),
    path('add_image_url/', add_image_url, name='add_image_url'),
    path('trip/<int:pk>/', login_required(TripDetailView.as_view()), name='trip-detail')

]

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)