Skip to content

Commit 1ccb02a

Browse files
committed
ajustando whitenoise no projeto
1 parent 82a91a3 commit 1ccb02a

File tree

14 files changed

+40
-49
lines changed

14 files changed

+40
-49
lines changed

catalog/models.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ class Meta:
3939
def __str__(self):
4040
return self.name
4141

42+
def get_absolut_url(self):
43+
return reverse('catalog:product', kwargs = {'slug': self.slug})
44+
4245

4346

4447

catalog/templates/catalog/category.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ <h1>{{ current_category }}</h1>
1212
{% for product in product_list %}
1313
<div class="col-sm-6 col-md-4">
1414
<div class="thumbnail">
15-
<a href="#">
15+
<a href="{{ product.get_absolut_url }}">
1616
<img src="http://placehold.it/350x250" alt="" />
1717
</a>
1818
<div class="caption">
1919
<h3>{{ product }}</h3>
2020
{{ product.description|linebreaks }}
21-
<p><a href="#" class="btn btn-success" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
21+
<p><a href="{{ product.get_absolut_url }}" class="btn btn-success" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
2222
</div>
2323
</div>
2424
</div>

catalog/templates/catalog/product_list.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@ <h1>Produtos</h1>
1212
{% for product in product_list %}
1313
<div class="col-sm-6 col-md-4">
1414
<div class="thumbnail">
15-
<a href="#">
15+
<a href="{{ product.get_absolut_url }}">
1616
<img src="http://placehold.it/350x250" alt="" />
1717
</a>
1818
<div class="caption">
1919
<h3>{{ product }}</h3>
2020
{{ product.description|linebreaks }}
21-
<p><a href="#" class="btn btn-success" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
21+
<p><a href="{{ product.get_absolut_url }}" class="btn btn-success" role="button">Button</a> <a href="#" class="btn btn-default" role="button">Button</a></p>
2222
</div>
2323
</div>
2424
</div>

catalog/tests.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

catalog/urls.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44

55
urlpatterns = [
66
url(r'^$', views.product_list, name = 'product_list'),
7-
url(r'^(?P<slug>[\w_-]+)$', views.category, name = 'category'),
7+
url(r'^(?P<slug>[\w_-]+)/$', views.category, name = 'category'),
8+
url(r'^produtos/(?P<slug>[\w_-]+)/$', views.product, name = 'product'),
89
]

catalog/views.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,12 @@ def category(request, slug):
1414
'current_category': category,
1515
'product_list': Product.objects.filter(category = category),
1616
}
17-
return render(request, 'catalog/category.html',context)
17+
return render(request, 'catalog/category.html',context)
18+
19+
20+
def product(request, slug):
21+
product = Product.objects.get(slug = slug)
22+
context = {
23+
'product': product
24+
}
25+
return render(request, 'catalog/product.html',context)
-122 Bytes
Binary file not shown.

core/templates/product.html

Lines changed: 0 additions & 32 deletions
This file was deleted.
9 Bytes
Binary file not shown.

core/views.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,3 @@ def index(request):
1010

1111
def contact(request):
1212
return render(request, 'contact.html')
13-
14-
15-
def product(request):
16-
return render(request, 'product.html')

0 commit comments

Comments
 (0)