Merge commit 'bc3b14b5dd697f1784acbcbfa0ef0948de4ef560' into currency
* commit 'bc3b14b5dd697f1784acbcbfa0ef0948de4ef560': add a base.html file and refactor the other html files refactor the views
This commit is contained in:
commit
4da981e5d6
|
@ -1,15 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="{{ STATIC_URL }}/static/admin/css/base.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="content" class="flex">
|
||||
<h1>{{ article.name }}</h1>
|
||||
<h3>Description</h3>
|
||||
<p>{{ article.description }}</p>
|
||||
<p><b>Stock:</b> {{ article.stock }}</p>
|
||||
<p><b>Status:</b> {{ article.status}}</p>
|
||||
<p><b>Price:</b> {{ article.price_in_chf }}</p>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{% extends "webshop/base.html" %}
|
||||
{% block section_title %}{{ article.name }}{% endblock %}
|
||||
{% block content %}
|
||||
<h3>Description</h3>
|
||||
<p>{{ article.description }}</p>
|
||||
<p><b>Stock:</b> {{ article.stock }}</p>
|
||||
<p><b>Status:</b> {{ article.status}}</p>
|
||||
<p><b>Price:</b> {{ article.price_in_chf }}</p>
|
||||
{% endblock %}
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="{{ STATIC_URL }}/static/admin/css/base.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="content" class="flex">
|
||||
<h1>{% block section_title %}Music Instrument Shop{% endblock %}</h1>
|
||||
{% block content %}{% endblock %}
|
||||
</div>
|
||||
</body>
|
||||
<footer>
|
||||
{% block footer %}
|
||||
<p><font size="1">This is a case study project of Ivan Hörler and Andreas Zweili.
|
||||
It is a school project/excercise and has no commercial intent.</font></p>
|
||||
{% endblock %}
|
||||
</footer>
|
||||
</html>
|
|
@ -1,21 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="{{ STATIC_URL }}/static/admin/css/base.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="content" class="flex">
|
||||
<h1>{{ category.name }}</h1>
|
||||
{% if article_list %}
|
||||
{% extends "webshop/base.html" %}
|
||||
{% block section_title %}Category Overview{% endblock %}
|
||||
{% block content %}
|
||||
{% if article_list %}
|
||||
<ul>
|
||||
{% for article in article_list %}
|
||||
<li><a href="{% url 'details' article.id %}">{{ article.name }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
{% else %}
|
||||
{% else %}
|
||||
<p>There are no articles in this category.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{% endif %}
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<!DOCTYPE html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="{{ STATIC_URL }}/static/admin/css/base.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="content" class="flex">
|
||||
<h1>Music Shop</h1>
|
||||
{% extends "webshop/base.html" %}
|
||||
{% block content %}
|
||||
{% if category_list %}
|
||||
<ul>
|
||||
{% for category, sub_category in category_list.items %}
|
||||
|
@ -19,6 +14,4 @@
|
|||
{% else %}
|
||||
<p>No categories are available.</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,7 +1,4 @@
|
|||
from django.shortcuts import get_object_or_404, render
|
||||
from django.http import HttpResponse
|
||||
from django.template import loader
|
||||
|
||||
from .models import Article, Category, ArticleStatus
|
||||
|
||||
# Create your views here.
|
||||
|
@ -15,11 +12,9 @@ def index(request):
|
|||
category_list.update(
|
||||
{i: Category.objects.filter(parent_category=i.id)})
|
||||
|
||||
template = loader.get_template('webshop/index.html')
|
||||
context = {
|
||||
'category_list': category_list,
|
||||
}
|
||||
return HttpResponse(template.render(context, request))
|
||||
return render(request,
|
||||
'webshop/index.html',
|
||||
{'category_list': category_list})
|
||||
|
||||
|
||||
def articles_in_category(request, category_id):
|
||||
|
@ -29,16 +24,12 @@ def articles_in_category(request, category_id):
|
|||
article_list = Article.objects.filter(
|
||||
category=selected_category.id).exclude(status=hidden.id)
|
||||
|
||||
template = loader.get_template('webshop/category.html')
|
||||
context = {
|
||||
'article_list': article_list,
|
||||
'category': selected_category,
|
||||
}
|
||||
return HttpResponse(template.render(context, request))
|
||||
return render(request, 'webshop/category.html',
|
||||
{'article_list': article_list,
|
||||
'category': selected_category})
|
||||
|
||||
|
||||
def article_details(request, article_id):
|
||||
article = get_object_or_404(Article, pk=article_id)
|
||||
return render(request,
|
||||
'webshop/article_details.html',
|
||||
return render(request, 'webshop/article_details.html',
|
||||
{'article': article})
|
||||
|
|
Loading…
Reference in New Issue