unfinished part of currency dropdown

This commit is contained in:
Ivan Hörler 2018-01-14 17:13:41 +01:00
parent ec92099fc9
commit 05b77b8845
4 changed files with 35 additions and 29 deletions

View File

@ -3,5 +3,5 @@ from currencies.models import ExchangeRate_name
class CurrencyForm(forms.Form):
currencies = forms.ModelChoiceField(
queryset=ExchangeRate_name.objects.all())
currencies = forms.ModelChoiceField(
queryset=ExchangeRate_name.objects.all())

View File

@ -4,6 +4,4 @@ from currencies.views import currencies, CurrencyUpdate
urlpatterns = [
url(r'^currencies/$', currencies),
url(r'^/$', CurrencyUpdate.as_view(),
name='CurrencyUpdate'),
]

View File

@ -9,11 +9,15 @@ from currencies import exchange_rates
from currencies.forms import CurrencyForm
class CurrencyUpdate(UpdateView):
model = ExchangeRate_name
currency_form = CurrencyForm
template_name = 'webshop/base.html'
success_url = 'webshop/base.html'
def CurrencyUpdate(request):
if request.method == 'POST':
currency_form = CurrencyForm
assert False
else:
currency_form = CurrencyForm
assert False
return render(request,
{'currency_form': currency_form})
def currencies(request):
# this function fetches the data from exchange_rates.py

View File

@ -34,27 +34,31 @@
<a class="navbar-brand" href="{% url 'index' %}">
HOME
</a>
<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 %}
</ul>
<form action="" method="POST" novalidate>
{% csrf_token %}
<select name="CurrencyUpdate" id="CurrencyUpdate" onchange="this.form.submit()">
<option value="CHF">CHF</option>
<option value="USD">USD</option>
<option value="GBP">GBP</option>
<option value="JPY">JPY</option>
</select>
</form>
</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 %}
<div class="dropdown">
<button class="btn btn-primary dropdown-toggle" type="button" data-toggle="dropdown">Currency:
<span class="caret"></span>
</button>
<ul class="dropdown-menu dropdown-menu-center">
<li class="disabled"><a href="#">CHF</a></li>
<li class="active"><a href="#">USD</a></li>
<li class="active"><a href="#">JPYS</a></li>
<li class="active"><a href="#">GBP</a></li>
</ul>
</div>
</ul>
</div>
</nav>
<div class="container-fluid">