This commit is contained in:
Ivan Hörler 2017-12-19 21:28:05 +01:00
parent 409b18807b
commit 776f81b3c9
6 changed files with 36 additions and 36 deletions

View File

@ -1,20 +0,0 @@
<!DOCTYPE HTML>
<meta charset="UTF-8">
<html>
<head></head>
<body>
<header>
<h1>audioguide</h1>
<h3>a mobile offline audioguide</h3>
noop
noop
noop
noop
noop
noop
<p>the audioguide that makes a offline usage possible.</p>
</header>
<nav>
</nav>
</body>
</html>

View File

@ -7,13 +7,3 @@ class ExchangeRate(models.Model):
def __str__(self):
return self.name
def exchange_rates():
exchange_rates = currencies.get_exchange_rate()
for i in exchange_rates:
if ExchangeRate.objects.filter(
name='exchange_rates_data[dictionary_value]'):
ExchangeRate.objects.filter(
name='exchange_rates_data[dictionary_key]',
exchange_rate_to_chf=exchange_rates.value).save()

View File

@ -0,0 +1,19 @@
<!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>
{% if currency_list %}
<ul>
{% for currency in currency_list %}
<li>{{ currency.name }} : {{ currency.exchange_rate_to_chf }}</li>
{% endfor %}
</ul>
{% else %}
<p>No categories are available.</p>
{% endif %}
</div>
</body>
</html>

View File

@ -1,7 +1,7 @@
from django.conf.urls import url
from currencies.views import currencies
from . import views
urlpatterns = [
url(r'^$', views.index, name='index'),
url(r'^currencies/$', currencies),
]

View File

@ -1,7 +1,18 @@
from django.shortcuts import render
from django.http import HttpResponse
from .models import ExchangeRate
import exchange_rates
def index(request):
return HttpResponse(exchange_rates)
def currencies(request):
# return HttpResponse("exchange_rates")
currency_list = ExchangeRate.objects.all()
raw_data = exchange_rates.get_exchange_rate()
for i, j in raw_data.items:
ExchangeRate.objects.create(
name=i,
exchange_rate_to_chf=j)
return render(request,
'currencies/index.html',
{'currency_list': currency_list})

View File

@ -18,6 +18,6 @@ from django.contrib import admin
urlpatterns = [
url(r'', include('webshop.urls')),
url(r'^admin/', admin.site.urls),
url(r'', include('currencies.urls')),
url(r'^admin/', admin.site.urls),
]