Improved readability of python code by adding/removing newlines, identation, etc.
This commit is contained in:
parent
0aa8c7f15b
commit
626f596cd3
5 changed files with 10 additions and 21 deletions
17
app/views.py
17
app/views.py
|
@ -25,17 +25,12 @@ from .models import RegisterTransaction
|
|||
|
||||
|
||||
def login_page(request):
|
||||
|
||||
userlist = get_user_model().objects.filter(is_superuser=False).filter(is_active=True).order_by("username")
|
||||
|
||||
if request.method == "POST":
|
||||
|
||||
form = AuthenticationForm(request.POST)
|
||||
username = request.POST['username']
|
||||
password = request.POST['password']
|
||||
|
||||
user = authenticate(username=username,password=password)
|
||||
|
||||
if user:
|
||||
if user.is_active:
|
||||
login(request, user)
|
||||
|
@ -46,14 +41,10 @@ def login_page(request):
|
|||
"user_list": userlist,
|
||||
"error_message": _("Invalid username or password.")
|
||||
})
|
||||
|
||||
else:
|
||||
|
||||
if request.user.is_authenticated:
|
||||
return HttpResponseRedirect("/")
|
||||
|
||||
form = AuthenticationForm()
|
||||
|
||||
return render(request,'registration/login.html', {
|
||||
"form": form,
|
||||
"user_list": userlist
|
||||
|
@ -80,9 +71,7 @@ def history(request):
|
|||
def order(request, drinkid):
|
||||
try:
|
||||
drink_ = Drink.objects.get(pk=drinkid)
|
||||
context = {
|
||||
"drink": drink_
|
||||
}
|
||||
context = {"drink": drink_}
|
||||
return render(request, "order.html", context)
|
||||
except Drink.DoesNotExist:
|
||||
return HttpResponseRedirect("/")
|
||||
|
@ -150,14 +139,14 @@ def api_deposit(request):
|
|||
transaction_sum=amount,
|
||||
comment=f"User deposit by user {user.username}",
|
||||
is_user_deposit=True,
|
||||
user=user
|
||||
)
|
||||
user=user)
|
||||
return HttpResponse("success", status=200)
|
||||
else: raise Exception("Deposit amount too big or small.")
|
||||
except Exception as e:
|
||||
print(f"An exception occured while processing a transaction: User: {user.username} - Exception: {e}", file=sys.stderr)
|
||||
return HttpResponse(b"", status=500)
|
||||
|
||||
|
||||
@login_required
|
||||
def api_supply(request):
|
||||
# check request -> supply
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue