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>
|
{% extends "webshop/base.html" %}
|
||||||
<head>
|
{% block section_title %}{{ article.name }}{% endblock %}
|
||||||
<link rel="stylesheet" href="{{ STATIC_URL }}/static/admin/css/base.css" />
|
{% block content %}
|
||||||
</head>
|
<h3>Description</h3>
|
||||||
<body>
|
<p>{{ article.description }}</p>
|
||||||
<div id="content" class="flex">
|
<p><b>Stock:</b> {{ article.stock }}</p>
|
||||||
<h1>{{ article.name }}</h1>
|
<p><b>Status:</b> {{ article.status}}</p>
|
||||||
<h3>Description</h3>
|
<p><b>Price:</b> {{ article.price_in_chf }}</p>
|
||||||
<p>{{ article.description }}</p>
|
{% endblock %}
|
||||||
<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>
|
|
||||||
|
|
|
@ -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>
|
{% extends "webshop/base.html" %}
|
||||||
<html>
|
{% block section_title %}Category Overview{% endblock %}
|
||||||
<head>
|
{% block content %}
|
||||||
<link rel="stylesheet" href="{{ STATIC_URL }}/static/admin/css/base.css" />
|
{% if article_list %}
|
||||||
</head>
|
<ul>
|
||||||
<body>
|
{% for article in article_list %}
|
||||||
|
<li><a href="{% url 'details' article.id %}">{{ article.name }}</a></li>
|
||||||
<div id="content" class="flex">
|
{% endfor %}
|
||||||
<h1>{{ category.name }}</h1>
|
</ul>
|
||||||
{% if article_list %}
|
{% else %}
|
||||||
<ul>
|
<p>There are no articles in this category.</p>
|
||||||
{% for article in article_list %}
|
{% endif %}
|
||||||
<li><a href="{% url 'details' article.id %}">{{ article.name }}</a></li>
|
{% endblock %}
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
{% else %}
|
|
||||||
<p>There are no articles in this category.</p>
|
|
||||||
{% endif %}
|
|
||||||
</div>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
|
@ -1,10 +1,5 @@
|
||||||
<!DOCTYPE html>
|
{% extends "webshop/base.html" %}
|
||||||
<head>
|
{% block content %}
|
||||||
<link rel="stylesheet" href="{{ STATIC_URL }}/static/admin/css/base.css" />
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div id="content" class="flex">
|
|
||||||
<h1>Music Shop</h1>
|
|
||||||
{% if category_list %}
|
{% if category_list %}
|
||||||
<ul>
|
<ul>
|
||||||
{% for category, sub_category in category_list.items %}
|
{% for category, sub_category in category_list.items %}
|
||||||
|
@ -18,7 +13,5 @@
|
||||||
</ul>
|
</ul>
|
||||||
{% else %}
|
{% else %}
|
||||||
<p>No categories are available.</p>
|
<p>No categories are available.</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
{% endblock %}
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
|
|
|
@ -1,7 +1,4 @@
|
||||||
from django.shortcuts import get_object_or_404, render
|
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
|
from .models import Article, Category, ArticleStatus
|
||||||
|
|
||||||
# Create your views here.
|
# Create your views here.
|
||||||
|
@ -15,11 +12,9 @@ def index(request):
|
||||||
category_list.update(
|
category_list.update(
|
||||||
{i: Category.objects.filter(parent_category=i.id)})
|
{i: Category.objects.filter(parent_category=i.id)})
|
||||||
|
|
||||||
template = loader.get_template('webshop/index.html')
|
return render(request,
|
||||||
context = {
|
'webshop/index.html',
|
||||||
'category_list': category_list,
|
{'category_list': category_list})
|
||||||
}
|
|
||||||
return HttpResponse(template.render(context, request))
|
|
||||||
|
|
||||||
|
|
||||||
def articles_in_category(request, category_id):
|
def articles_in_category(request, category_id):
|
||||||
|
@ -29,16 +24,12 @@ def articles_in_category(request, category_id):
|
||||||
article_list = Article.objects.filter(
|
article_list = Article.objects.filter(
|
||||||
category=selected_category.id).exclude(status=hidden.id)
|
category=selected_category.id).exclude(status=hidden.id)
|
||||||
|
|
||||||
template = loader.get_template('webshop/category.html')
|
return render(request, 'webshop/category.html',
|
||||||
context = {
|
{'article_list': article_list,
|
||||||
'article_list': article_list,
|
'category': selected_category})
|
||||||
'category': selected_category,
|
|
||||||
}
|
|
||||||
return HttpResponse(template.render(context, request))
|
|
||||||
|
|
||||||
|
|
||||||
def article_details(request, article_id):
|
def article_details(request, article_id):
|
||||||
article = get_object_or_404(Article, pk=article_id)
|
article = get_object_or_404(Article, pk=article_id)
|
||||||
return render(request,
|
return render(request, 'webshop/article_details.html',
|
||||||
'webshop/article_details.html',
|
|
||||||
{'article': article})
|
{'article': article})
|
||||||
|
|
Loading…
Reference in New Issue