Skip to content
Snippets Groups Projects
Verified Commit a486ec60 authored by Frank Sauerburger's avatar Frank Sauerburger
Browse files

Protect plot count against math domain error

parent 8cf6e84b
No related branches found
No related tags found
No related merge requests found
...@@ -5,7 +5,13 @@ ...@@ -5,7 +5,13 @@
<div class="jumbotron jumbo-fluid plot-background shadow"> <div class="jumbotron jumbo-fluid plot-background shadow">
<div class="container"> <div class="container">
<h1 class="display-4">uhepp hub</h1> <h1 class="display-4">uhepp hub</h1>
<h2>Home of over {{ plot_count }} plots</h2> <h2>
{% if plot_count < 10 %}
Home of plots
{% else %}
Home of over {{ plot_count }} plots
{% endif %}
</h2>
</div> </div>
</div> </div>
{% endblock %} {% endblock %}
......
...@@ -22,6 +22,9 @@ from .models import PUBLIC_LEVEL, INTERNAL_LEVEL, PUBLIC_LEVEL, \ ...@@ -22,6 +22,9 @@ from .models import PUBLIC_LEVEL, INTERNAL_LEVEL, PUBLIC_LEVEL, \
from .forms import TokenForm from .forms import TokenForm
def quantize(value, sig_digits): def quantize(value, sig_digits):
if value <= 100:
return value
magnitude = math.floor(math.log10(value)) magnitude = math.floor(math.log10(value))
scale = magnitude - sig_digits + 1 scale = magnitude - sig_digits + 1
return math.floor(value / 10**scale) * 10**scale return math.floor(value / 10**scale) * 10**scale
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment