Refactored CSS and HTML templates and polished UI (#10), changed JavaScript variable names to camelCase, adjusted filenames and some url parameter names in urlpatterns, and more.

This commit is contained in:
W13R 2022-11-04 20:35:28 +01:00
parent 1e32e2b5dd
commit 8599f49857
30 changed files with 401 additions and 403 deletions

View file

@ -16,13 +16,13 @@
<body>
<div class="baseLayout">
<div class="baselayout">
{% include "globalMessage.html" %}
{% include "globalmessage.html" %}
{% if user.is_authenticated %}
{% include "userPanel.html" %}
{% include "userpanel.html" %}
{% endif %}
@ -30,14 +30,13 @@
{% if user.is_authenticated or "accounts/login/" in request.path or "accounts/logout/" in request.path or "admin/logout/" in request.path %}
<h1>{% block heading %}{% endblock %}</h1>
<div class="content">
{% block content %}{% endblock %}
</div>
{% else %}
<div class="centeringFlex">
<div class="centeringflex">
{% translate "An error occured. Please log out and log in again." %}
<br>
<a href="/accounts/logout">log out</a>

View file

@ -1,4 +1,4 @@
{% extends "baseLayout.html" %}
{% extends "baselayout.html" %}
{% load i18n %}
@ -7,29 +7,29 @@
{% endblock %}
{% block headAdditional %}
<link rel="stylesheet" href="/static/css/deposit.css">
<link rel="stylesheet" href="/static/css/appform.css">
{% endblock %}
{% block heading %}
{% translate "Deposit" %}
{% endblock %}
{% block content %}
<form id="depositForm">
<form id="depositform" class="appform">
{% csrf_token %}
<div class="row">
<div class="column">{% translate "Amount" %} {{ currency_suffix }}:</div>
<div class="column"><input type="number" name="depositAmount" id="depositAmount" max="9999.99" min="1.00"
step="0.01" autofocus></div>
<h1 class="formheading">{% translate "Deposit" %}</h1>
<div class="forminput">
<span>{% translate "Amount" %} {{ currency_suffix }}:</span>
<span>
<input type="number" name="depositamount" id="depositamount" max="9999.99" min="1.00" step="0.01" autofocus>
</span>
</div>
<div id="statusInfo"></div>
<div id="statusinfo"></div>
<div class="horizontalButtonList">
<div class="formbuttons">
<a href="/" class="button">{% translate "cancel" %}</a>
<input type="submit" id="depositSubmitBtn" class="button" value='{% translate "confirm" %}'>
<input type="submit" id="depositsubmitbtn" class="button" value='{% translate "confirm" %}'>
</div>
</form>

View file

@ -1,5 +1,5 @@
{% if global_message != "" %}
<div class="globalMessage">
<div class="globalmessage">
<div>{{ global_message }}</div>
</div>
{% endif %}

View file

@ -1,4 +1,4 @@
{% extends "baseLayout.html" %}
{% extends "baselayout.html" %}
{% load i18n %}
@ -10,12 +10,11 @@
<link rel="stylesheet" href="/static/css/history.css">
{% endblock %}
{% block heading %}
{% translate "History" %}
{% endblock %}
{% block content %}
<h1 class="heading">{% translate "History" %}</h1>
{% if history %}
<table class="history">
<tr>
@ -25,7 +24,7 @@
{% for h in history %}
<tr>
<td>{{ h.0 }}</td>
<td class="historyDate">{{ h.1 }}</td>
<td class="historydate">{{ h.1 }}</td>
</tr>
{% endfor %}
</table>

View file

@ -1,4 +1,4 @@
{% extends "baseLayout.html" %}
{% extends "baselayout.html" %}
{% load i18n %}
@ -10,15 +10,13 @@
<link rel="stylesheet" href="/static/css/index.css">
{% endblock %}
{% block heading %}
{% translate "Available Drinks" %}
{% endblock %}
{% block content %}
<h1 class="heading">{% translate "Available Drinks" %}</h1>
{% if available_drinks %}
<ul class="availableDrinksList">
<ul class="availabledrinkslist">
{% for drink in available_drinks %}
{% if drink.do_not_count %}
<li>

View file

@ -1,4 +1,4 @@
{% extends "baseLayout.html" %}
{% extends "baselayout.html" %}
{% load i18n %}
{% load l10n %}
@ -8,13 +8,10 @@
{% endblock %}
{% block headAdditional %}
<link rel="stylesheet" href="/static/css/order.css">
<link rel="stylesheet" href="/static/css/customNumberInput.css">
<link rel="stylesheet" href="/static/css/appform.css">
<link rel="stylesheet" href="/static/css/custom_number_input.css">
{% endblock %}
{% block heading %}
{% translate "Order" %}
{% endblock %}
{% block content %}
@ -22,66 +19,67 @@
{% if user.balance > 0 or user.allow_order_with_negative_balance %}
<form id="orderForm">
<form id="orderform" class="appform">
{% csrf_token %}
<div class="row">
<div class="column">{% translate "Drink" %}:</div>
<div class="column">{{ drink.product_name }}</div>
</div>
<h1 class="formheading">{% translate "Order" %}</h1>
<div class="row">
<div class="column">{% translate "Price per Item" %} ({{ currency_suffix }}):</div>
<div class="column" id="pricePerDrink" data-drink-price="{% localize off %}{{ drink.price }}{% endlocalize %}">{{ drink.price }}</div>
<div class="forminfo">
<span>{% translate "Drink" %}:</span>
<span>{{ drink.product_name }}</span>
</div>
<div class="forminfo">
<span>{% translate "Price per Item" %} ({{ currency_suffix }}):</span>
<span id="priceperdrink" data-drink-price="{% localize off %}{{ drink.price }}{% endlocalize %}">
{{ drink.price }}
</span>
</div>
{% if not drink.do_not_count %}
<div class="row">
<div class="column">{% translate "Available" %}:</div>
<div class="column">{{ drink.available }}</div>
<div class="forminfo">
<span>{% translate "Available" %}:</span>
<span>{{ drink.available }}</span>
</div>
{% endif %}
<div class="row">
<div class="column">{% translate "Count" %}:</div>
<div class="column">
<span class="customNumberInput">
<button type="button" class="customNumberInput-minus" id="numberOfDrinksBtnA">-</button>
{% if drink.do_not_count %}
<input type="number" class="customNumberInputField" name="numberOfDrinks" id="numberOfDrinks"
min="1" max="100" value="1">
{% else %}
<input type="number" class="customNumberInputField" name="numberOfDrinks" id="numberOfDrinks"
max="{{ drink.available }}" min="1" max="100" value="1">
{% endif %}
<button type="button" class="customNumberInput-plus" id="numberOfDrinksBtnB">+</button>
</span>
</div>
<div class="forminfo">
<span>{% translate "Sum" %} ({{ currency_suffix }}):</span>
<span id="ordercalculatedsum">{{ drink.price }}</span>
</div>
<div class="row">
<div class="column">{% translate "Sum" %} ({{ currency_suffix }}):</div>
<div class="column" id="orderCalculatedSum">{{ drink.price }}</div>
<div class="forminput">
<span>{% translate "Count" %}:</span>
<span class="customnumberinput">
<button type="button" class="customnumberinput-minus" id="numberofdrinks-btn-minus">-</button>
{% if drink.do_not_count %}
<input type="number" class="customnumberinput-field" name="numberofdrinks" id="numberofdrinks"
min="1" max="100" value="1">
{% else %}
<input type="number" class="customnumberinput-field" name="numberofdrinks" id="numberofdrinks"
max="{{ drink.available }}" min="1" max="100" value="1">
{% endif %}
<button type="button" class="customnumberinput-plus" id="numberofdrinks-btn-plus">+</button>
</span>
</div>
<div id="statusInfo"></div>
<input type="hidden" name="drinkID" id="drinkID" value="{{ drink.id }}">
<div id="statusinfo"></div>
<div class="horizontalButtonList">
<input type="hidden" name="drinkid" id="drinkid" value="{{ drink.id }}">
<div class="formbuttons">
<a href="/" class="button">{% translate "cancel" %}</a>
<input type="submit" id="orderSubmitBtn" class="button" value='{% translate "order" %}'>
<input type="submit" id="ordersubmitbtn" class="button" value='{% translate "order" %}'>
</div>
</form>
<script src="/static/js/order.js"></script>
<script src="/static/js/customNumberInput.js"></script>
<script src="/static/js/custom_number_input.js"></script>
{% else %}
<div class="centeringFlex">
<div class="centeringflex">
<p>{% translate "Your balance is too low to order a drink." %}</p>
<a href="/">{% translate "back" %}</a>
</div>
@ -90,7 +88,7 @@
{% else %}
<div class="centeringFlex">
<div class="centeringflex">
<p>{% translate "This drink is not available." %}</p>
<a href="/">{% translate "back" %}</a>
</div>

View file

@ -1,5 +1,5 @@
{% extends "baseLayout.html" %}
{% extends "baselayout.html" %}
{% load i18n %}
@ -13,7 +13,7 @@
{% block content %}
<div class="centeringFlex">
<div class="centeringflex">
{% translate "Logged out! You will be redirected shortly." %}
<br><br>
<a href="/">{% translate "Click here if automatic redirection does not work." %}</a>

View file

@ -1,5 +1,5 @@
{% extends "baseLayout.html" %}
{% extends "baselayout.html" %}
{% load i18n %}
{% load static %}
@ -15,14 +15,14 @@
{% block content %}
{% if error_message %}
<p class="errorText">{{ error_message }}</p>
<p class="errortext">{{ error_message }}</p>
{% endif %}
<div class="passwordOverlayContainer nodisplay" id="passwordOverlayContainer">
<div class="passwordoverlaycontainer nodisplay" id="passwordoverlaycontainer">
<div class="passwordOverlay">
<div class="passwordoverlay">
<form method="post" action="{% url 'login' %}">
<form method="post" action="{% url 'login' %}" class="loginform">
{% csrf_token %}
<h1>{% translate "Log in" %}</h1>
<input type="text" name="username" autofocus="" autocapitalize="none" autocomplete="username" maxlength="150" required="" id="id_username">
@ -31,30 +31,30 @@
<div class="pinpad">
<table>
<tr>
<td><button type="button" class="pinpadBtn" data-btn="1">1</button></td>
<td><button type="button" class="pinpadBtn" data-btn="2">2</button></td>
<td><button type="button" class="pinpadBtn" data-btn="3">3</button></td>
<td><button type="button" class="pinpadbtn" data-btn="1">1</button></td>
<td><button type="button" class="pinpadbtn" data-btn="2">2</button></td>
<td><button type="button" class="pinpadbtn" data-btn="3">3</button></td>
</tr>
<tr>
<td><button type="button" class="pinpadBtn" data-btn="4">4</button></td>
<td><button type="button" class="pinpadBtn" data-btn="5">5</button></td>
<td><button type="button" class="pinpadBtn" data-btn="6">6</button></td>
<td><button type="button" class="pinpadbtn" data-btn="4">4</button></td>
<td><button type="button" class="pinpadbtn" data-btn="5">5</button></td>
<td><button type="button" class="pinpadbtn" data-btn="6">6</button></td>
</tr>
<tr>
<td><button type="button" class="pinpadBtn" data-btn="7">7</button></td>
<td><button type="button" class="pinpadBtn" data-btn="8">8</button></td>
<td><button type="button" class="pinpadBtn" data-btn="9">9</button></td>
<td><button type="button" class="pinpadbtn" data-btn="7">7</button></td>
<td><button type="button" class="pinpadbtn" data-btn="8">8</button></td>
<td><button type="button" class="pinpadbtn" data-btn="9">9</button></td>
</tr>
<tr>
<td><button type="button" class="pinpadBtn" data-btn="x">x</button></td>
<td><button type="button" class="pinpadBtn" data-btn="0">0</button></td>
<td><button type="button" class="pinpadBtn" data-btn="enter">&#9166;</button></td>
<td><button type="button" class="pinpadbtn" data-btn="x">x</button></td>
<td><button type="button" class="pinpadbtn" data-btn="0">0</button></td>
<td><button type="button" class="pinpadbtn" data-btn="enter">&#9166;</button></td>
</tr>
</table>
</div>
<div class="horizontalButtonList">
<button type="button" id="pwoCancel">{% translate "cancel" %}</button>
<div class="horizontalbuttonlist">
<button type="button" id="pwocancel">{% translate "cancel" %}</button>
<input class="button" id="submit_login" type="submit" value='{% translate "login" %}' />
</div>
@ -65,10 +65,10 @@
<h1>{% translate "Choose your account" %}</h1>
<div class="userlistContainer" id="userlistContainer">
<div class="userlistcontainer" id="userlistcontainer">
<ul class="userlist">
{% for user_ in user_list %}
<li class="userlistButton button" data-username="{{ user_.username }}">
<li class="userlistbutton button" data-username="{{ user_.username }}">
<img src="/profilepictures?name={{ user_.profile_picture_filename|urlencode }}">
<div>
{% if user_.first_name %}

View file

@ -1,4 +1,4 @@
{% extends "baseLayout.html" %}
{% extends "baselayout.html" %}
{% load i18n %}
@ -11,18 +11,15 @@
{% endblock %}
{% block heading %}
{% translate "Statistics" %}
{% endblock %}
{% block content %}
<div class="mainContainer">
<h1 class="heading">{% translate "Statistics" %}</h1>
<div class="tablesContainer">
<div class="maincontainer">
<div id="noyopd" class="statisticsTable">
<div class="tablescontainer">
<div id="noyopd" class="statisticstable">
<h1>{% translate "Your orders per drink" %}</h1>
{% if noyopd %}
<table>
@ -42,7 +39,7 @@
{% endif %}
</div>
<div id="noaopd" class="statisticsTable">
<div id="noaopd" class="statisticstable">
<h1>{% translate "All orders per drink" %}</h1>
{% if noaopd %}
<table>
@ -62,7 +59,7 @@
{% endif %}
</div>
<div id="yopml12m" class="statisticsTable">
<div id="yopml12m" class="statisticstable">
<h1>{% translate "Your orders per month (last 12 months)" %}</h1>
{% if yopml12m %}
<table>
@ -82,7 +79,7 @@
{% endif %}
</div>
<div id="aopml12m" class="statisticsTable">
<div id="aopml12m" class="statisticstable">
<h1>{% translate "All orders per month (last 12 months)" %}</h1>
{% if aopml12m %}
<table>
@ -102,7 +99,7 @@
{% endif %}
</div>
<div id="yopwd" class="statisticsTable">
<div id="yopwd" class="statisticstable">
<h1>{% translate "Your orders per weekday" %}</h1>
{% if yopwd %}
<table>
@ -122,7 +119,7 @@
{% endif %}
</div>
<div id="aopwd" class="statisticsTable">
<div id="aopwd" class="statisticstable">
<h1>{% translate "All orders per weekday" %}</h1>
{% if aopwd %}
<table>

View file

@ -1,4 +1,4 @@
{% extends "baseLayout.html" %}
{% extends "baselayout.html" %}
{% load i18n %}
{% load l10n %}
@ -8,48 +8,49 @@
{% endblock %}
{% block headAdditional %}
<link rel="stylesheet" href="/static/css/supply.css">
<link rel="stylesheet" href="/static/css/customNumberInput.css">
<link rel="stylesheet" href="/static/css/appform.css">
<link rel="stylesheet" href="/static/css/custom_number_input.css">
{% endblock %}
{% block heading %}
{% translate "Supply" %}
{% endblock %}
{% block content %}
{% if user.is_superuser or user.allowed_to_supply %}
<form id="supplyForm">
<form id="supplyform" class="appform">
{% csrf_token %}
<div class="row">
<div class="column">{% translate "Description" %}:</div>
<input type="text" name="supplyDescription" id="supplyDescription" autofocus>
<h1 class="formheading">{% translate "Supply" %}</h1>
<div class="forminput">
<span>{% translate "Description" %}:</span>
<span>
<input type="text" name="supplydescription" id="supplydescription" autofocus>
</span>
</div>
<div class="row">
<div class="column">{% translate "Price" %} ({{ currency_suffix }}):</div>
<div class="column">
<input type="number" name="supplyPrice" id="supplyPrice" max="9999.99" min="1.00" step="0.01">
</div>
<div class="forminput">
<span>{% translate "Price" %} ({{ currency_suffix }}):</span>
<span>
<input type="number" name="supplyprice" id="supplyprice" max="9999.99" min="1.00" step="0.01">
</span>
</div>
<div id="statusInfo"></div>
<div id="statusinfo"></div>
<div class="horizontalButtonList">
<div class="formbuttons">
<a href="/" class="button">{% translate "cancel" %}</a>
<input type="submit" id="supplySubmitBtn" class="button" value='{% translate "submit" %}'>
<input type="submit" id="supplysubmitbtn" class="button" value='{% translate "submit" %}'>
</div>
</form>
<script src="/static/js/supply.js"></script>
<script src="/static/js/customNumberInput.js"></script>
<script src="/static/js/custom_number_input.js"></script>
{% else %}
<div class="centeringFlex">
<div class="centeringflex">
<p>{% translate "You are not allowed to view this site." %}</p>
<a href="/">{% translate "back" %}</a>
</div>

View file

@ -1,8 +1,8 @@
{% load i18n %}
{% load static %}
<div class="userPanel">
<div class="userInfo">
<div class="userpanel">
<div class="userinfo">
<img src="/profilepictures?name={{ user.profile_picture_filename|urlencode }}">
<span>
{% if user.first_name != "" %}
@ -12,30 +12,30 @@
{% endif %}
&nbsp;-&nbsp;
{% if user.balance < 0.01 %}
<span class="userBalanceWarn">{% translate "Balance" %}: {{ user.balance }}{{ currency_suffix }}</span>
<span class="userbalancewarn">{% translate "Balance" %}: {{ user.balance }}{{ currency_suffix }}</span>
{% else %}
<span>{% translate "Balance" %}: {{ user.balance }}{{ currency_suffix }}</span>
{% endif %}
</span>
</div>
<div class="horizontalButtonList">
<a class="button" id="navBarBtnHome" href="/">Home</a>
<a class="button" id="navBarBtnDeposit" href="/deposit">{% translate "Deposit" %}</a>
<div class="horizontalbuttonlist">
<a class="button" href="/">Home</a>
<a class="button" href="/deposit">{% translate "Deposit" %}</a>
<a class="button" href="/accounts/logout">{% translate "Logout" %}</a>
<div class="dropDownMenu" id="dropDownMenu">
<button class="dropDownButton" id="dropDownMenuButton">
<div class="dropdownmenu" id="dropdownmenu">
<button class="dropdownbutton" id="dropdownmenu-button">
<div>{% translate "Account" %}</div>
</button>
<div class="dropDownList">
<a class="button dropDownChoice" id="navBarBtnHistory" href="/history">{% translate "History" %}</a>
<a class="button dropDownChoice" id="navBarBtnStatistics" href="/statistics">{% translate "Statistics" %}</a>
<div class="dropdownlist">
<a class="button dropdownchoice" href="/history">{% translate "History" %}</a>
<a class="button dropdownchoice" href="/statistics">{% translate "Statistics" %}</a>
{% if user.is_superuser or user.is_staff %}
<a class="button dropDownChoice" href="/admin/">Admin Panel</a>
<a class="button dropdownchoice" href="/admin/">Admin Panel</a>
{% endif %}
{% if user.is_superuser or user.allowed_to_supply %}
<a class="button dropDownChoice" href="/supply/">{% translate "Supply" %}</a>
<a class="button dropdownchoice" href="/supply/">{% translate "Supply" %}</a>
{% endif %}
<a class="button dropDownChoice" href="/accounts/password_change/">{% translate "Change Password" %}</a>
<a class="button dropdownchoice" href="/accounts/password_change/">{% translate "Change Password" %}</a>
</div>
</div>
</div>

View file

@ -6,7 +6,7 @@ from .admin import adminSite
urlpatterns = [
path('', views.index),
path('order/<drinkID>/', views.order),
path('order/<drinkid>/', views.order),
path('history/', views.history),
path('deposit/', views.deposit),
path('statistics/', views.statistics),

View file

@ -84,9 +84,9 @@ def history(request):
return render(request, "history.html", context)
@login_required
def order(request, drinkID):
def order(request, drinkid):
try:
drink_ = Drink.objects.get(pk=drinkID)
drink_ = Drink.objects.get(pk=drinkid)
context = {
"drink": drink_
}
@ -148,10 +148,10 @@ def api_order_drink(request):
if user.allow_order_with_negative_balance or user.balance > 0:
drinkID = int(request.POST["drinkID"])
amount = int(request.POST["numberOfDrinks"])
drinkid = int(request.POST["drinkid"])
amount = int(request.POST["numberofdrinks"])
drink = Drink.objects.get(pk=drinkID)
drink = Drink.objects.get(pk=drinkid)
if ((drink.do_not_count and drink.available > 0) or (drink.available >= amount)) and not drink.deleted:
Order.objects.create(drink=drink, user=user, amount=amount)
@ -175,7 +175,7 @@ def api_deposit(request):
try:
amount = decimal.Decimal(request.POST["depositAmount"])
amount = decimal.Decimal(request.POST["depositamount"])
if 0.00 < amount < 9999.99:
# create transaction
@ -202,8 +202,8 @@ def api_supply(request):
try:
price = decimal.Decimal(request.POST["supplyPrice"])
description = str(request.POST["supplyDescription"])
price = decimal.Decimal(request.POST["supplyprice"])
description = str(request.POST["supplydescription"])
if 0.00 < price < 9999.99 and (user.allowed_to_supply or user.is_superuser):
# create transaction