cleanup
This commit is contained in:
parent
f8a6932bde
commit
ab30417a80
|
@ -31,7 +31,7 @@ def parse_rss(urlsocket):
|
||||||
def pass_local_file():
|
def pass_local_file():
|
||||||
rss_tree = ET.ElementTree(file='rss')
|
rss_tree = ET.ElementTree(file='rss')
|
||||||
return(rss_tree)
|
return(rss_tree)
|
||||||
|
|
||||||
|
|
||||||
def get_exchange_rate(rss_tree, ns):
|
def get_exchange_rate(rss_tree, ns):
|
||||||
# Pathvariables to XML Namespaces with
|
# Pathvariables to XML Namespaces with
|
||||||
|
@ -111,5 +111,4 @@ def get_exchange_rate(rss_tree, ns):
|
||||||
'exchangerate': foreign_value_round}]
|
'exchangerate': foreign_value_round}]
|
||||||
exchange_rates.append(data)
|
exchange_rates.append(data)
|
||||||
# Print the Dictionary:
|
# Print the Dictionary:
|
||||||
print(exchange_rates)
|
|
||||||
return(exchange_rates)
|
return(exchange_rates)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{% extends "webshop/base.html" %}
|
{% extends "webshop/base.html" %}
|
||||||
{% block section_title %}Currencies in CHF{% endblock %}
|
{% block section_title %}Currencies in CHF{% endblock %}
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<h2> {{ message }} </h2>
|
<h5> {{ message }} </h5>
|
||||||
<h3> Frühere Daten: </h3>
|
<h3> Frühere Daten: </h3>
|
||||||
<h4> US Dollars: </h4>
|
<h4> US Dollars: </h4>
|
||||||
{% if currency_USD_list %}
|
{% if currency_USD_list %}
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
from django.conf.urls import url
|
from django.conf.urls import url
|
||||||
from currencies.views import currencies, currency_update
|
from currencies.views import currencies
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
url(r'^currencies/$', currencies),
|
url(r'^currencies/$', currencies),
|
||||||
url(r'^ajax/currency_update/$',
|
|
||||||
currency_update,
|
|
||||||
name='currency_update'),
|
|
||||||
]
|
]
|
||||||
|
|
|
@ -7,20 +7,6 @@ from currencies import exchange_rates
|
||||||
from django.http import JsonResponse
|
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):
|
def currencies(request):
|
||||||
|
|
||||||
"""this function fetches the data from swiss national bank
|
"""this function fetches the data from swiss national bank
|
||||||
|
|
|
@ -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<obj.options.length; i++){
|
|
||||||
// if(obj.options[i].value == "USD"){
|
|
||||||
// obj.selectedIndex = i;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// var e document.getElementById("id_currency_update");
|
|
||||||
//e.value = currency_update;
|
|
|
@ -93,7 +93,6 @@
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
|
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
|
||||||
<script src="{% static 'js/app.js' %}"></script>
|
|
||||||
<script>{% block javascript %}{% endblock %}</script>
|
<script>{% block javascript %}{% endblock %}</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Reference in New Issue