diff --git a/django/didgeridoo/currencies/exchange_rates.py b/django/didgeridoo/currencies/exchange_rates.py index bf23ab6..43afbc7 100644 --- a/django/didgeridoo/currencies/exchange_rates.py +++ b/django/didgeridoo/currencies/exchange_rates.py @@ -31,7 +31,7 @@ def parse_rss(urlsocket): def pass_local_file(): rss_tree = ET.ElementTree(file='rss') return(rss_tree) - + def get_exchange_rate(rss_tree, ns): # Pathvariables to XML Namespaces with @@ -111,5 +111,4 @@ def get_exchange_rate(rss_tree, ns): 'exchangerate': foreign_value_round}] exchange_rates.append(data) # Print the Dictionary: - print(exchange_rates) return(exchange_rates) diff --git a/django/didgeridoo/currencies/templates/currencies/index.html b/django/didgeridoo/currencies/templates/currencies/index.html index 2f28ccb..acd63fb 100644 --- a/django/didgeridoo/currencies/templates/currencies/index.html +++ b/django/didgeridoo/currencies/templates/currencies/index.html @@ -1,7 +1,7 @@ {% extends "webshop/base.html" %} {% block section_title %}Currencies in CHF{% endblock %} {% block content %} -

{{ message }}

+
{{ message }}

Frühere Daten:

US Dollars:

{% if currency_USD_list %} diff --git a/django/didgeridoo/currencies/urls.py b/django/didgeridoo/currencies/urls.py index aa24648..91fa530 100644 --- a/django/didgeridoo/currencies/urls.py +++ b/django/didgeridoo/currencies/urls.py @@ -1,9 +1,6 @@ from django.conf.urls import url -from currencies.views import currencies, currency_update +from currencies.views import currencies urlpatterns = [ url(r'^currencies/$', currencies), - url(r'^ajax/currency_update/$', - currency_update, - name='currency_update'), ] diff --git a/django/didgeridoo/currencies/views.py b/django/didgeridoo/currencies/views.py index 52d8aed..62de99a 100644 --- a/django/didgeridoo/currencies/views.py +++ b/django/didgeridoo/currencies/views.py @@ -7,20 +7,6 @@ from currencies import exchange_rates from django.http import JsonResponse -def currency_update(request): - # https://simpleisbetterthancomplex.com/tutorial/2016/08/29/how-to-work-with-ajax-request-with-django.html - if request.GET.get('currency_update', None) == 'CHF': - data = {} - else: - currency = request.GET.get('currency_update', None) - data = ExchangeRate.objects.filter( - name__name=currency).values( - 'exchange_rate_to_chf').latest( - 'date__date') - print('currency:', currency, 'data: ', data) - return JsonResponse(data) - - def currencies(request): """this function fetches the data from swiss national bank diff --git a/django/didgeridoo/static/js/app.js b/django/didgeridoo/static/js/app.js deleted file mode 100644 index fefddab..0000000 --- a/django/didgeridoo/static/js/app.js +++ /dev/null @@ -1,30 +0,0 @@ - $("#id_currency_update").change(function () { - var currency_update = $(this).val(); - $("#id_currency_update").val(currency_update); - $.ajax({ - url: '/ajax/currency_update/', - data: { - 'currency_update': currency_update - }, - dataType: 'json', - success: function (data) { - var foo = jQuery.parseJSON(data); - alert("es pop auf! --dies kommt von: static/js/app.js--." + foo.currency_update); - - } - }); - }); - - //document.getElementById('id_currency_update').getElementsByTagName('currency_update') - //$("#id_currency_update").val('USD').selected = 'selected'; - - //https://stackoverflow.com/a/30489067/4061870 - // var obj = document.getElementById("id_currency_update"); - // for(i=0; i -