Commit f0b85398 authored by cianlaguesma's avatar cianlaguesma

fixed views and urls

parent 377eb7bd
from django.conf.urls import url from django.conf.urls import url
from .views import ingredients_list, ingredients_detail, ingredients_update_form, ingredients_create_form, recipes_list, recipes_detail, recipes_update_form, recipes_create_form, orders_list, orders_detail, orders_update_form, orders_create_form, home_page from .views import ingredients_list, ingredients_detail, ingredients_update_form, ingredients_create_form, recipes_list, recipes_detail, recipes_update_form, recipes_create_form, orders_list, orders_detail, orders_update_form, orders_create_form, home_page
urlpatterns = [ urlpatterns = [
url(r'^index$', home_page, name='home_page'), url(r'^index$', home_page.as_view(), name='home_page'),
url(r'^ingredients/list$', ingredients_list, name='ingredients_list'), url(r'^ingredients/list$', ingredients_list.as_view(), name='ingredients_list'),
url(r'^ingredients/detail$', ingredients_detail, name='ingredients_detail'), url(r'^ingredients/detail$', ingredients_detail.as_view(), name='ingredients_detail'),
url(r'^ingredients/update_form$', ingredients_update_form, name='ingredients_update_form'), url(r'^ingredients/update_form$', ingredients_update_form.as_view(), name='ingredients_update_form'),
url(r'^ingredients/create_form$', ingredients_create_form, name='ingredients_create_form'), url(r'^ingredients/create_form$', ingredients_create_form.as_view(), name='ingredients_create_form'),
url(r'^recipes/list$', recipes_list, name='recipes_list'), url(r'^recipes/list$', recipes_list.as_view(), name='recipes_list'),
url(r'^recipes/detail$', recipes_detail, name='recipes_detail'), url(r'^recipes/detail$', recipes_detail.as_view(), name='recipes_detail'),
url(r'^recipes/update_form$', recipes_update_form, name='recipes_update_form'), url(r'^recipes/update_form$', recipes_update_form.as_view(), name='recipes_update_form'),
url(r'^recipes/create_form$', recipes_create_form, name='recipes_create_form'), url(r'^recipes/create_form$', recipes_create_form.as_view(), name='recipes_create_form'),
url(r'^orders/list$', orders_list, name='orders_list'), url(r'^orders/list$', orders_list.as_view(), name='orders_list'),
url(r'^orders/detail$', orders_detail, name='orders_detail'), url(r'^orders/detail$', orders_detail.as_view(), name='orders_detail'),
url(r'^orders/update_form$', orders_update_form, name='orders_update_form'), url(r'^orders/update_form$', orders_update_form.as_view(), name='orders_update_form'),
url(r'^orders/create_form$', orders_create_form, name='recipes_create_form'), url(r'^orders/create_form$', orders_create_form.as_view(), name='recipes_create_form'),
] ]
from django.shortcuts import render from django.views.generic.base import TemplateView
def home_page(request): class home_page(TemplateView):
return render(request, 'index.html') template_name = 'index.html'
def ingredients_list(request): class ingredients_list(TemplateView):
return render(request,'ingredients_list.html') template_name = 'ingredients_list.html'
def ingredients_detail(request): class ingredients_detail(TemplateView):
return render(request,'ingredients_detail.html') template_name = 'ingredients_detail.html'
def ingredients_update_form(request): class ingredients_update_form(TemplateView):
return render(request,'ingredients_update_form.html') template_name = 'ingredients_update_form.html'
def ingredients_create_form(request): class ingredients_create_form(TemplateView):
return render(request,'ingredients_create_form.html') template_name = 'ingredients_create_form.html'
def recipes_list(request): class recipes_list(TemplateView):
return render(request,'recipes_list.html') template_name = 'recipes_list.html'
def recipes_detail(request): class recipes_detail(TemplateView):
return render(request,'recipes_detail.html') template_name = 'recipes_detail.html'
def recipes_update_form(request): class recipes_update_form(TemplateView):
return render(request,'recipes_update_form.html') template_name = 'recipes_update_form.html'
def recipes_create_form(request): class recipes_create_form(TemplateView):
return render(request,'recipes_create_form.html') template_name = 'recipes_create_form.html'
def orders_list(request): class orders_list(TemplateView):
return render(request,'orders_list.html') template_name = 'orders_list.html'
def orders_detail(request): class orders_detail(TemplateView):
return render(request,'orders_detail.html') template_name = 'orders_detail.html'
def orders_update_form(request): class orders_update_form(TemplateView):
return render(request,'orders_update_form.html') template_name = 'orders_update_form.html'
def orders_create_form(request): class orders_create_form(TemplateView):
return render(request,'orders_create_form.html') template_name = 'orders_create_form.html'
# Create your views here. # Create your views here.
...@@ -61,7 +61,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -61,7 +61,7 @@ class NewVisitorTest(unittest.TestCase):
time.sleep(1) time.sleep(1)
self.assertEqual('http://localhost:8000/ingredients/detail',self.browser.current_url) self.assertEqual('http://localhost:8000/ingredients/detail',self.browser.current_url)
self.assertTrue(self.browser.find_element_by_id("ingredients_detail_header")) self.assertTrue(self.browser.find_element_by_id("ingredients_detail_header"))
# After Updating the ingredient, he went back home # After this, he went back home
home = self.browser.find_element_by_id('home') home = self.browser.find_element_by_id('home')
home.click() home.click()
time.sleep(1) time.sleep(1)
...@@ -79,7 +79,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -79,7 +79,7 @@ class NewVisitorTest(unittest.TestCase):
time.sleep(1) time.sleep(1)
self.assertEqual('http://localhost:8000/ingredients/list',self.browser.current_url) self.assertEqual('http://localhost:8000/ingredients/list',self.browser.current_url)
self.assertTrue(self.browser.find_element_by_id("ingredients_list_header")) self.assertTrue(self.browser.find_element_by_id("ingredients_list_header"))
# After Updating the ingredient, he went back home # After this, he went back home
home = self.browser.find_element_by_id('home') home = self.browser.find_element_by_id('home')
home.click() home.click()
time.sleep(1) time.sleep(1)
...@@ -96,7 +96,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -96,7 +96,7 @@ class NewVisitorTest(unittest.TestCase):
time.sleep(1) time.sleep(1)
self.assertEqual('http://localhost:8000/orders/create_form',self.browser.current_url) self.assertEqual('http://localhost:8000/orders/create_form',self.browser.current_url)
self.assertTrue(self.browser.find_element_by_id("orders_create_form_header")) self.assertTrue(self.browser.find_element_by_id("orders_create_form_header"))
# After Updating the ingredient, he went back home # After creating the form, he went back home
home = self.browser.find_element_by_id('home') home = self.browser.find_element_by_id('home')
home.click() home.click()
time.sleep(1) time.sleep(1)
...@@ -114,8 +114,8 @@ class NewVisitorTest(unittest.TestCase): ...@@ -114,8 +114,8 @@ class NewVisitorTest(unittest.TestCase):
update_order.click() update_order.click()
time.sleep(1) time.sleep(1)
self.assertEqual('http://localhost:8000/orders/update_form',self.browser.current_url) self.assertEqual('http://localhost:8000/orders/update_form',self.browser.current_url)
self.assertTrue(self.browser.find_element_by_id("orders_create_form_header")) self.assertTrue(self.browser.find_element_by_id("orders_update_form_header"))
# After Updating the ingredient, he went back home # After Updating the order, he went back home
home = self.browser.find_element_by_id('home') home = self.browser.find_element_by_id('home')
home.click() home.click()
time.sleep(1) time.sleep(1)
...@@ -126,7 +126,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -126,7 +126,7 @@ class NewVisitorTest(unittest.TestCase):
def test_froyo_display_detail_orders(self): def test_froyo_display_detail_orders(self):
#He also wanted to look at the detail of a record for an orderso he went and looked at one and he noticed the header Orders - Detail #He also wanted to look at the detail of a record for an order so he went and looked at one and he noticed the header Orders - Detail
self.browser.get('http://localhost:8000/index') self.browser.get('http://localhost:8000/index')
...@@ -135,7 +135,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -135,7 +135,7 @@ class NewVisitorTest(unittest.TestCase):
time.sleep(1) time.sleep(1)
self.assertEqual('http://localhost:8000/orders/detail',self.browser.current_url) self.assertEqual('http://localhost:8000/orders/detail',self.browser.current_url)
self.assertTrue(self.browser.find_element_by_id("orders_detail_header")) self.assertTrue(self.browser.find_element_by_id("orders_detail_header"))
# After Updating the ingredient, he went back home # After this, he went back home
home = self.browser.find_element_by_id('home') home = self.browser.find_element_by_id('home')
home.click() home.click()
time.sleep(1) time.sleep(1)
...@@ -153,7 +153,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -153,7 +153,7 @@ class NewVisitorTest(unittest.TestCase):
time.sleep(1) time.sleep(1)
self.assertEqual('http://localhost:8000/orders/list',self.browser.current_url) self.assertEqual('http://localhost:8000/orders/list',self.browser.current_url)
self.assertTrue(self.browser.find_element_by_id("orders_list_header")) self.assertTrue(self.browser.find_element_by_id("orders_list_header"))
# After Updating the ingredient, he went back home # After this, he went back home
home = self.browser.find_element_by_id('home') home = self.browser.find_element_by_id('home')
home.click() home.click()
time.sleep(1) time.sleep(1)
...@@ -170,7 +170,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -170,7 +170,7 @@ class NewVisitorTest(unittest.TestCase):
time.sleep(1) time.sleep(1)
self.assertEqual('http://localhost:8000/recipes/create_form',self.browser.current_url) self.assertEqual('http://localhost:8000/recipes/create_form',self.browser.current_url)
self.assertTrue(self.browser.find_element_by_id("recipes_create_form_header")) self.assertTrue(self.browser.find_element_by_id("recipes_create_form_header"))
# After Updating the ingredient, he went back home # After this, he went back home
home = self.browser.find_element_by_id('home') home = self.browser.find_element_by_id('home')
home.click() home.click()
time.sleep(1) time.sleep(1)
...@@ -187,7 +187,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -187,7 +187,7 @@ class NewVisitorTest(unittest.TestCase):
time.sleep(1) time.sleep(1)
self.assertEqual('http://localhost:8000/recipes/update_form',self.browser.current_url) self.assertEqual('http://localhost:8000/recipes/update_form',self.browser.current_url)
self.assertTrue(self.browser.find_element_by_id("recipes_update_form_header")) self.assertTrue(self.browser.find_element_by_id("recipes_update_form_header"))
# After Updating the ingredient, he went back home # After this, he went back home
home = self.browser.find_element_by_id('home') home = self.browser.find_element_by_id('home')
home.click() home.click()
time.sleep(1) time.sleep(1)
...@@ -204,7 +204,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -204,7 +204,7 @@ class NewVisitorTest(unittest.TestCase):
time.sleep(1) time.sleep(1)
self.assertEqual('http://localhost:8000/recipes/detail',self.browser.current_url) self.assertEqual('http://localhost:8000/recipes/detail',self.browser.current_url)
self.assertTrue(self.browser.find_element_by_id("recipes_detail_header")) self.assertTrue(self.browser.find_element_by_id("recipes_detail_header"))
# After Updating the ingredient, he went back home # After this, he went back home
home = self.browser.find_element_by_id('home') home = self.browser.find_element_by_id('home')
home.click() home.click()
time.sleep(1) time.sleep(1)
...@@ -221,7 +221,7 @@ class NewVisitorTest(unittest.TestCase): ...@@ -221,7 +221,7 @@ class NewVisitorTest(unittest.TestCase):
time.sleep(1) time.sleep(1)
self.assertEqual('http://localhost:8000/recipes/list',self.browser.current_url) self.assertEqual('http://localhost:8000/recipes/list',self.browser.current_url)
self.assertTrue(self.browser.find_element_by_id("recipes_list_header")) self.assertTrue(self.browser.find_element_by_id("recipes_list_header"))
# After Updating the ingredient, he went back home # After this, he went back home
home = self.browser.find_element_by_id('home') home = self.browser.find_element_by_id('home')
home.click() home.click()
time.sleep(1) time.sleep(1)
......
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