2023-10-19 22:44:24 +00:00
|
|
|
from django.shortcuts import render
|
|
|
|
|
2023-10-19 22:54:35 +00:00
|
|
|
from ... import ParameterValidator
|
2016-12-02 17:50:21 +00:00
|
|
|
|
2023-10-19 22:44:24 +00:00
|
|
|
|
2016-12-02 17:50:21 +00:00
|
|
|
def index(request):
|
2023-10-19 22:54:35 +00:00
|
|
|
with ParameterValidator(request.GET, 'upgrade_id') as validator:
|
2016-12-02 20:07:35 +00:00
|
|
|
try:
|
|
|
|
amount_param = float(request.GET['upgrade'])
|
|
|
|
except (KeyError, ValueError):
|
|
|
|
validator.fail()
|
|
|
|
else:
|
2016-12-02 20:15:49 +00:00
|
|
|
validator.validate('{:.2f}'.format(amount_param))
|
2016-12-02 20:07:35 +00:00
|
|
|
partial_amount = amount_param if validator.valid else 0
|
2016-12-02 17:50:21 +00:00
|
|
|
context = {
|
|
|
|
'partial_amount': partial_amount,
|
|
|
|
'minimum_amount': 120 - partial_amount,
|
|
|
|
}
|
2023-10-19 22:44:24 +00:00
|
|
|
return render(request, "supporter/index.html", context)
|