refactor and clean
This commit is contained in:
parent
db1fb337ba
commit
3a8a5ea1da
|
@ -1,5 +1,5 @@
|
|||
from django import forms
|
||||
from currencies.models import ExchangeRate_name
|
||||
from currencies.models import ExchangeRate, ExchangeRate_name
|
||||
|
||||
|
||||
class CurrenciesForm(forms.Form):
|
||||
|
|
|
@ -1,88 +1,28 @@
|
|||
{% extends "webshop/base.html" %}
|
||||
{% block section_title %}Currencies in CHF{% endblock %}
|
||||
{% block content %}
|
||||
<h5> {{ message }} </h5>
|
||||
<h3> Frühere Daten: </h3>
|
||||
<h4> US Dollars: </h4>
|
||||
{% if currency_USD_list %}
|
||||
<h4> Currency List: </h4>
|
||||
{% if ordered_currency_list %}
|
||||
<table>
|
||||
<tr>
|
||||
<th scope="col">DATE</th>
|
||||
<th scope="col">NAME</th>
|
||||
<th scope="col">RATE</th>
|
||||
</tr>
|
||||
{% for currency in currency_USD_list %}
|
||||
{% for currency in ordered_currency_list %}
|
||||
<tr>
|
||||
<td scope="col">{{ currency.date.date }}</td>
|
||||
<td scope="col">{{ currency.date }}</td>
|
||||
<td scope="col">{{ currency.name }}</td>
|
||||
<td scope="col">{{ currency.exchange_rate_to_chf }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<p> {{ message }} </p>
|
||||
{% else %}
|
||||
<br>
|
||||
<p class="alert">
|
||||
currency_USD_list missing.
|
||||
currency_list missing.
|
||||
</p>
|
||||
{% endif %}
|
||||
<br>
|
||||
<h4> EURO: </h4>
|
||||
{% if currency_EUR_list %}
|
||||
<table>
|
||||
<tr>
|
||||
<th scope="col">DATE</th>
|
||||
<th scope="col">RATE</th>
|
||||
</tr>
|
||||
{% for currency in currency_EUR_list %}
|
||||
<tr>
|
||||
<td scope="col">{{ currency.date.date }}</td>
|
||||
<td scope="col">{{ currency.exchange_rate_to_chf }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
{% else %}
|
||||
<p class="alert">
|
||||
currency_EUR_list missing.
|
||||
</p>
|
||||
{% endif %}
|
||||
<br>
|
||||
<h4> Japanese Yenn: </h4>
|
||||
{% if currency_JPY_list %}
|
||||
<table>
|
||||
<tr>
|
||||
<th scope="col">DATE</th>
|
||||
<th scope="col">RATE</th>
|
||||
</tr>
|
||||
{% for currency in currency_JPY_list %}
|
||||
<tr>
|
||||
<td scope="col">{{ currency.date.date }}</td>
|
||||
<td scope="col">{{ currency.exchange_rate_to_chf }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
</table>
|
||||
{% else %}
|
||||
<p class="alert">
|
||||
currency_JPY_list missing.
|
||||
</p>
|
||||
{% endif %}
|
||||
<br>
|
||||
<h4> Great Britain Pounds: </h4>
|
||||
{% if currency_GBP_list %}
|
||||
<table>
|
||||
<tr>
|
||||
<th scope="col">DATE</th>
|
||||
<th scope="col">RATE</th>
|
||||
</tr>
|
||||
{% for currency in currency_GBP_list %}
|
||||
<tr>
|
||||
<td scope="col">{{ currency.date.date }}</td>
|
||||
<td scope="col">{{ currency.exchange_rate_to_chf }}</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
<tr>
|
||||
</table>
|
||||
{% else %}
|
||||
<p class="alert">
|
||||
currency_GBP_list missing.
|
||||
</p>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
|
|
|
@ -1,12 +0,0 @@
|
|||
from django import template
|
||||
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.filter()
|
||||
def boldcoffee(value):
|
||||
# currency_of_customer = request.session['currency']
|
||||
return '%s !!gefiltert!!' % value
|
||||
|
||||
# excample filter: {{ article.price_in_chf|boldcoffee }}
|
|
@ -42,7 +42,7 @@ def currencies(request):
|
|||
message_offline = """
|
||||
Are you offline? - useing stored currencies.
|
||||
This does not efect you, but your purchase prices will be
|
||||
recalculated as soon as you submit your Order.
|
||||
recalculated as soon as you submit your Order. <br>
|
||||
"""
|
||||
try:
|
||||
raw_data = exchange_rates.get_exchange_rate(rss_tree, ns)
|
||||
|
@ -148,32 +148,21 @@ def currencies(request):
|
|||
elif datetime.datetime.today().isoweekday() == 6:
|
||||
message = """Die Abfrage wurde ohne ergebniss beendet.
|
||||
Es ist Samstag, die SNB publiziert nur an Arbeitstagen
|
||||
neue Kurse...
|
||||
neue Kurse... <br>
|
||||
"""
|
||||
elif datetime.datetime.today().isoweekday() == 7:
|
||||
message = """Die Abfrage wurde ohne ergebniss beendet.
|
||||
Es ist Sonntag, die SNB publiziert nur an Arbeitstagen
|
||||
neue Kurse...
|
||||
neue Kurse... <br>
|
||||
"""
|
||||
else:
|
||||
message = """Die Abfrage wurde ohne ergebniss beendet.
|
||||
message = """Die Abfrage wurde ohne ergebniss beendet. <br>
|
||||
"""
|
||||
# know we can query our data for presentaton:
|
||||
currency_list = ExchangeRate.objects.all()
|
||||
currency_USD_list = ExchangeRate.objects.filter(
|
||||
name__name='USD').order_by('date__date')
|
||||
currency_EUR_list = ExchangeRate.objects.filter(
|
||||
name__name='EUR').order_by('date__date')
|
||||
currency_JPY_list = ExchangeRate.objects.filter(
|
||||
name__name='JPY').order_by('date__date')
|
||||
currency_GBP_list = ExchangeRate.objects.filter(
|
||||
name__name='GBP').order_by('date__date')
|
||||
ordered_currency_list = ExchangeRate.objects.order_by('name', 'date')
|
||||
|
||||
# and publish it on template:
|
||||
return render(request,
|
||||
'currencies/index.html',
|
||||
{'currency_list': currency_list,
|
||||
'currency_USD_list': currency_USD_list,
|
||||
'currency_EUR_list': currency_EUR_list,
|
||||
'currency_JPY_list': currency_JPY_list,
|
||||
'currency_GBP_list': currency_GBP_list,
|
||||
{'ordered_currency_list': ordered_currency_list,
|
||||
'message': message})
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
</form>
|
||||
</p>
|
||||
{% else %}
|
||||
<p> please login to fill your basket...</p>
|
||||
<p class="alert">
|
||||
please login to fill your basket...
|
||||
</p>
|
||||
{% endif %}
|
||||
{% for picture in picture_list %}
|
||||
<p><img src="{{ MEDIA_URL }}{{ picture.image }}" width="200" /></p>
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
{% extends "webshop/base.html" %}
|
||||
{% load customfilters %}
|
||||
{% block section_title %}Articles{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
|
|
Loading…
Reference in New Issue