Verified Commit 88f4cefc authored by Elger Jonker's avatar Elger Jonker

fallback if there is no database present (no crashhes, just empty screens)

parent f25fe952
......@@ -250,7 +250,6 @@ const report_mixin = {
vulnerability_timeline_for_organization: function(organization_id){
fetch('/data/organization_vulnerability_timeline/' + organization_id)
.then(response => response.json()).then(data => {
// data
let labels = Array();
let high = Array();
......@@ -784,6 +783,11 @@ function views() {
fetch('/data/vulnstats/' + this.country + '/' + this.category + '/0')
.then(response => response.json()).then(data => {
// no data returned.
if(jQuery.isEmptyObject(data)){
return;
}
this.vulnerability_graph('timeline_all_vulnerabilities', data.total, 'hml');
for(let i=0; i<data.total.length; i++){
......
......@@ -101,6 +101,9 @@ def get_defaults(request, ):
is_the_default_option=True
).order_by('display_order').values('country', 'organization_type__name').first()
if not data:
return JsonResponse({'country': "NL", 'category': "municipality"}, safe=False, encoder=JSEncoder)
return JsonResponse({'country': data['country'], 'category': data['organization_type__name']},
safe=False, encoder=JSEncoder)
......@@ -1293,6 +1296,10 @@ def map_default(request, days_back: int = 0, displayed_issue: str = None):
is_the_default_option=True
).order_by('display_order').values('country', 'organization_type__name').first()
# On an empty database, just get the Netherlands.
if not defaults:
return map_data(request, "NL", "municipality", days_back, displayed_issue)
return map_data(request, defaults['country'], defaults['organization_type__name'], days_back, displayed_issue)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment