Merge commit '0048475a2d63a08805050d767834606e6547eab9' into currency
* commit '0048475a2d63a08805050d767834606e6547eab9': remove a migration file add a cronjob to trigger the currency updates add migrations to the ignore list remove a duplicate entry changed some of the views and implemented a more selfish perspective of a shop. For shure not ideal and in NO way DRY but a solution for now. selfmade css file unfinshed atempt to make a nav abandoned for later use maybe add bootstrap to ansible and vagrant for django-bootstrap3 support
This commit is contained in:
commit
d5ad3c77d5
|
@ -267,3 +267,4 @@ fabric.properties
|
||||||
# End of https://www.gitignore.io/api/pycharm
|
# End of https://www.gitignore.io/api/pycharm
|
||||||
/django/.idea/workspace.xml
|
/django/.idea/workspace.xml
|
||||||
/docs/main.listing
|
/docs/main.listing
|
||||||
|
/django/didgeridoo/currencies/migrations/*.py
|
||||||
|
|
|
@ -30,7 +30,8 @@ Vagrant.configure("2") do |config|
|
||||||
#zu installierende Pakete
|
#zu installierende Pakete
|
||||||
apt-get install -y apache2 python3-django mariadb-server avahi-daemon \
|
apt-get install -y apache2 python3-django mariadb-server avahi-daemon \
|
||||||
libnss-mdns libapache2-mod-wsgi-py3 python3-mysqldb python3-pip
|
libnss-mdns libapache2-mod-wsgi-py3 python3-mysqldb python3-pip
|
||||||
pip3 install django-extensions Pillow pyaml
|
pip3 install django-extensions Pillow pyaml django-bootstrap3
|
||||||
|
|
||||||
|
|
||||||
#Copy the apache configuration for django to the correct place
|
#Copy the apache configuration for django to the correct place
|
||||||
cp /vagrant/apache/000-default.conf /etc/apache2/sites-available/
|
cp /vagrant/apache/000-default.conf /etc/apache2/sites-available/
|
||||||
|
@ -42,6 +43,10 @@ Vagrant.configure("2") do |config|
|
||||||
systemctl restart apache2.service
|
systemctl restart apache2.service
|
||||||
|
|
||||||
/vagrant/ansible/roles/web_AI-5/tasks/setup_script.sh
|
/vagrant/ansible/roles/web_AI-5/tasks/setup_script.sh
|
||||||
|
|
||||||
|
#insert the currency update cronjob
|
||||||
|
echo "wget -O /dev/null http://localhost:8080" > /etc/cron.hourly/currency_update
|
||||||
|
chmod +x /etc/cron.hourly/currency_update
|
||||||
SHELL
|
SHELL
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
- django-extensions
|
- django-extensions
|
||||||
- Pillow
|
- Pillow
|
||||||
- pyaml
|
- pyaml
|
||||||
|
- django-bootstrap3
|
||||||
executable: pip3
|
executable: pip3
|
||||||
|
|
||||||
- name: Run the setup script to add some final touches
|
- name: Run the setup script to add some final touches
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
# Generated by Django 1.10.7 on 2018-01-09 18:21
|
|
||||||
from __future__ import unicode_literals
|
|
||||||
|
|
||||||
from django.db import migrations, models
|
|
||||||
import django.db.models.deletion
|
|
||||||
|
|
||||||
|
|
||||||
class Migration(migrations.Migration):
|
|
||||||
|
|
||||||
initial = True
|
|
||||||
|
|
||||||
dependencies = [
|
|
||||||
]
|
|
||||||
|
|
||||||
operations = [
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='ExchangeRate',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('exchange_rate_to_chf', models.DecimalField(decimal_places=5, max_digits=12)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='ExchangeRate_date',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('date', models.DateField(unique_for_date=True, verbose_name='%Y-%m-%d')),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.CreateModel(
|
|
||||||
name='ExchangeRate_name',
|
|
||||||
fields=[
|
|
||||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
|
||||||
('name', models.CharField(max_length=200, unique=True)),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='exchangerate',
|
|
||||||
name='date',
|
|
||||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='currencies.ExchangeRate_date'),
|
|
||||||
),
|
|
||||||
migrations.AddField(
|
|
||||||
model_name='exchangerate',
|
|
||||||
name='name',
|
|
||||||
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='currencies.ExchangeRate_name'),
|
|
||||||
),
|
|
||||||
]
|
|
|
@ -35,7 +35,6 @@ ALLOWED_HOSTS = [
|
||||||
# Application definition
|
# Application definition
|
||||||
|
|
||||||
INSTALLED_APPS = [
|
INSTALLED_APPS = [
|
||||||
'currencies',
|
|
||||||
'webshop.apps.WebshopConfig',
|
'webshop.apps.WebshopConfig',
|
||||||
'django_extensions',
|
'django_extensions',
|
||||||
'django.contrib.admin',
|
'django.contrib.admin',
|
||||||
|
@ -44,6 +43,8 @@ INSTALLED_APPS = [
|
||||||
'django.contrib.sessions',
|
'django.contrib.sessions',
|
||||||
'django.contrib.messages',
|
'django.contrib.messages',
|
||||||
'django.contrib.staticfiles',
|
'django.contrib.staticfiles',
|
||||||
|
'currencies',
|
||||||
|
'bootstrap3',
|
||||||
]
|
]
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
|
||||||
|
.sidebar-nav {
|
||||||
|
margin-top: 30px;
|
||||||
|
padding: 10;
|
||||||
|
list-style: none;
|
||||||
|
}
|
|
@ -1,23 +1,93 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<head>
|
<head>
|
||||||
<link rel="stylesheet" href="{{ STATIC_URL }}/static/admin/css/base.css" />
|
<meta charset="utf-8">
|
||||||
</head>
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<body>
|
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
|
||||||
<div id="content" class="flex">
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
||||||
<a href="{% url 'index' %}">Home</a> |
|
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
|
||||||
{% if user.is_authenticated %}
|
|
||||||
<a href="{% url 'profile' %}">Profile</a> | <a href="{% url 'logout' %}">Logout</a>
|
<!-- Add additional CSS in static file -->
|
||||||
{% else %}
|
{% load static %}
|
||||||
<a href="{% url 'login' %}">Login</a>
|
<link rel="stylesheet" href="{{ STATIC_URL }}/static/webshop/css/base.css" />
|
||||||
{% endif %}
|
{% block title %}
|
||||||
<h1>{% block section_title %}Music Instrument Shop{% endblock %}</h1>
|
<title>
|
||||||
{% block content %}{% endblock %}
|
Casestudy 'Webshop' IBZ TIAE-5(2017/18)
|
||||||
</div>
|
</title>
|
||||||
</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 %}
|
{% endblock %}
|
||||||
</footer>
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
<h1>
|
||||||
|
{% block shop_name %}Music Instruments Inc.{% endblock %}
|
||||||
|
</h1>
|
||||||
|
<div>
|
||||||
|
{% block search %}{% endblock %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<nav class="navbar navbar-default">
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="navbar-header">
|
||||||
|
<a class="navbar-brand" href="{% url 'index' %}">
|
||||||
|
HOME
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
<ul class="nav navbar-nav">
|
||||||
|
<li><a href="#">CART</a></li>
|
||||||
|
{% if user.is_authenticated %}
|
||||||
|
<li><a href="{% url 'profile' %}">PROFILE</a></li>
|
||||||
|
<li><a href="{% url 'logout' %}">LOGOUT</a></li>
|
||||||
|
{% else %}
|
||||||
|
<li><a href="{% url 'login' %}">LOGIN</a></li>
|
||||||
|
{% endif %}
|
||||||
|
<li><a href="#">CURRENCY</a></li>
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</nav>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-2">
|
||||||
|
{% block sidebar %}
|
||||||
|
{% if category_list %}
|
||||||
|
<ul>
|
||||||
|
{% for category, sub_category in category_list.items %}
|
||||||
|
<li><a href="{% url 'category' category.id %}">{{ category.name }}</a></li>
|
||||||
|
{% for i in sub_category %}
|
||||||
|
<ul>
|
||||||
|
<li><a href="{% url 'category' i.id %}">{{ i.name }}</a></li>
|
||||||
|
</ul>
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
{% else %}
|
||||||
|
<p>No categories are available.</p>
|
||||||
|
{% endif %}
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-10 ">
|
||||||
|
<h1>
|
||||||
|
{% block section_title %}{% endblock %}
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div class="col-sm-10 ">
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<footer>
|
||||||
|
<div class="container-fluid">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-sm-12">
|
||||||
|
{% block footer %}
|
||||||
|
This is a case study project of Ivan Hörler and Andreas Zweili. </br>
|
||||||
|
It is a school project/excercise and has no commercial intent.
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -1,13 +1,31 @@
|
||||||
{% extends "webshop/base.html" %}
|
{% extends "webshop/base.html" %}
|
||||||
{% block section_title %}Category Overview{% endblock %}
|
{% block section_title %}Category Overview{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if article_list %}
|
{% if article_list %}
|
||||||
<ul>
|
<table class="table">
|
||||||
{% for article in article_list %}
|
<tr class="table_header">
|
||||||
<li><a href="{% url 'details' article.id %}">{{ article.name }}</a></li>
|
<th scope="col">ID</th>
|
||||||
{% endfor %}
|
<th scope="col">NAME</th>
|
||||||
</ul>
|
<th scope="col">CATHEGORY</th>
|
||||||
{% else %}
|
<th scope="col">STOCK</th>
|
||||||
<p>There are no articles in this category.</p>
|
<th scope="col">PRICE</th>
|
||||||
{% endif %}
|
</tr>
|
||||||
|
{% for article in article_list %}
|
||||||
|
<tr class="table_content">
|
||||||
|
<td scope="col">{{ article.id }}</td>
|
||||||
|
<td scope="col">
|
||||||
|
<a href="{% url 'details' article.id %}">
|
||||||
|
{{ article.name }}
|
||||||
|
</a></td>
|
||||||
|
<td scope="col">{{ article.category }}</td>
|
||||||
|
<td scope="col">{{ article.stock }}</td>
|
||||||
|
<td scope="col">{{ article.price_in_chf }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<p class="alert">
|
||||||
|
Something whent wrong, no articles are stored.
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -1,17 +1,32 @@
|
||||||
{% extends "webshop/base.html" %}
|
{% extends "webshop/base.html" %}
|
||||||
|
{% block section_title %}Articles{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
{% if category_list %}
|
{% if articles_list %}
|
||||||
<ul>
|
<table class="table">
|
||||||
{% for category, sub_category in category_list.items %}
|
<tr class="table_header">
|
||||||
<li><a href="{% url 'category' category.id %}">{{ category.name }}</a></li>
|
<th scope="col">ID</th>
|
||||||
{% for i in sub_category %}
|
<th scope="col">NAME</th>
|
||||||
<ul>
|
<th scope="col">CATHEGORY</th>
|
||||||
<li><a href="{% url 'category' i.id %}">{{ i.name }}</a></li>
|
<th scope="col">STOCK</th>
|
||||||
</ul>
|
<th scope="col">PRICE</th>
|
||||||
{% endfor %}
|
</tr>
|
||||||
{% endfor %}
|
{% for article in articles_list %}
|
||||||
</ul>
|
<tr class="table_content">
|
||||||
{% else %}
|
<td scope="col">{{ article.id }}</td>
|
||||||
<p>No categories are available.</p>
|
<td scope="col">
|
||||||
{% endif %}
|
<a href="{% url 'details' article.id %}">
|
||||||
|
{{ article.name }}
|
||||||
|
</a>
|
||||||
|
</td>
|
||||||
|
<td scope="col">{{ article.category }}</td>
|
||||||
|
<td scope="col">{{ article.stock }}</td>
|
||||||
|
<td scope="col">{{ article.price_in_chf }}</td>
|
||||||
|
</tr>
|
||||||
|
{% endfor %}
|
||||||
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<p class="alert">
|
||||||
|
Something whent wrong, no articles are stored.
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -17,6 +17,8 @@ from webshop.forms import RegistrationForm
|
||||||
def index(request):
|
def index(request):
|
||||||
parent_category_list = Category.objects.filter(parent_category=None)
|
parent_category_list = Category.objects.filter(parent_category=None)
|
||||||
category_list = {}
|
category_list = {}
|
||||||
|
hidden = ArticleStatus.objects.get(name="hidden")
|
||||||
|
articles_list = Article.objects.all().exclude(status=hidden.id)
|
||||||
|
|
||||||
for i in parent_category_list:
|
for i in parent_category_list:
|
||||||
category_list.update(
|
category_list.update(
|
||||||
|
@ -24,7 +26,8 @@ def index(request):
|
||||||
|
|
||||||
return render(request,
|
return render(request,
|
||||||
'webshop/index.html',
|
'webshop/index.html',
|
||||||
{'category_list': category_list})
|
{'category_list': category_list,
|
||||||
|
'articles_list': articles_list})
|
||||||
|
|
||||||
|
|
||||||
def articles_in_category(request, category_id):
|
def articles_in_category(request, category_id):
|
||||||
|
@ -34,18 +37,32 @@ 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)
|
||||||
|
|
||||||
|
parent_category_list = Category.objects.filter(parent_category=None)
|
||||||
|
category_list = {}
|
||||||
|
|
||||||
|
for i in parent_category_list:
|
||||||
|
category_list.update(
|
||||||
|
{i: Category.objects.filter(parent_category=i.id)})
|
||||||
|
|
||||||
return render(request, 'webshop/category.html',
|
return render(request, 'webshop/category.html',
|
||||||
{'article_list': article_list,
|
{'article_list': article_list,
|
||||||
|
'category_list': category_list,
|
||||||
'category': selected_category})
|
'category': selected_category})
|
||||||
|
|
||||||
|
|
||||||
def article_details(request, article_id):
|
def article_details(request, article_id):
|
||||||
article = get_object_or_404(Article, pk=article_id)
|
parent_category_list = Category.objects.filter(parent_category=None)
|
||||||
picture_list = Picture.objects.filter(article=article_id)
|
category_list = {}
|
||||||
return render(request, 'webshop/article_details.html',
|
|
||||||
{'article': article,
|
|
||||||
'picture_list': picture_list})
|
|
||||||
|
|
||||||
|
for i in parent_category_list:
|
||||||
|
category_list.update(
|
||||||
|
{i: Category.objects.filter(parent_category=i.id)})
|
||||||
|
|
||||||
|
article = get_object_or_404(Article, pk=article_id)
|
||||||
|
|
||||||
|
return render(request, 'webshop/article_details.html',
|
||||||
|
{'article': article,
|
||||||
|
'category_list': category_list})
|
||||||
|
|
||||||
@login_required
|
@login_required
|
||||||
def profile(request):
|
def profile(request):
|
||||||
|
|
Loading…
Reference in New Issue