Skip to content
This repository has been archived by the owner on Jan 27, 2023. It is now read-only.

Commit

Permalink
Adapts error message to z-score settings
Browse files Browse the repository at this point in the history
Fix #8
  • Loading branch information
cuducos committed Dec 29, 2019
1 parent 67b1805 commit b52ff79
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions web/core/context_processors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.conf import settings


def confidence(request):
value = settings.Z_SCORE_CONFIDENCE_TABLE.get(settings.Z_SCORE)
return {"CONFIDENCE": f"Errors for {value} confidence." if value else ""}
2 changes: 2 additions & 0 deletions web/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
"django.template.context_processors.request",
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"web.core.context_processors.confidence",
]
},
}
Expand Down Expand Up @@ -145,6 +146,7 @@
MAIN_ADMIN_VIEW = "admin:core_job_changelist"

Z_SCORE = config("Z_SCORE", default="1.96", cast=float) # default 0.95 confidence
Z_SCORE_CONFIDENCE_TABLE = {1.96: "95%", 2.58: "99%", 1.64: "90"}

CACHE_BOTOMETER_RESULTS_FOR_DAYS = config(
"CACHE_BOTOMETER_RESULTS_FOR_DAYS",
Expand Down
4 changes: 3 additions & 1 deletion web/templates/admin/change_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,12 +79,14 @@ <h2>{% trans 'Filter' %}</h2>
{% if action_form and actions_on_bottom and cl.show_admin_actions %}{% admin_actions %}{% endif %}
{% endblock %}
{% block pagination %}{% pagination cl %}{% endblock %}
{% if CONFIDENCE %}
<div style="text-align:right">
<small>* Errors for 95% confidence.</small>
<small>{{ CONFIDENCE }}</small>
</div>
<br>
&nbsp;
<br>
{% endif %}
<div id="toolbar">
<form action="{% url 'start' %}" method="post">
{% csrf_token %}
Expand Down

0 comments on commit b52ff79

Please sign in to comment.