From f28af7e71e96c7ab436af3249d7aa884d2250b9c Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 22 May 2024 14:53:01 +0100 Subject: [PATCH 01/31] add to existing shapesData --- seshat/apps/core/templates/core/world_map.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index ed568e9e6..46cc364cf 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -267,9 +267,14 @@

Base Map

fetch('/core/world_map_all/') .then(response => response.json()) .then(data => { - shapesData = data.shapes.map(function (shape) { + data.shapes.forEach(function (shape) { shape.weight = polityBorderWeight; - return shape; + let isDuplicate = shapesData.some(existingShape => + existingShape.geom === shape.geom + ); + if (!isDuplicate) { + shapesData.push(shape); + } }); // Update seshat_id_page_id from the JSON response From 1e57c4aa15092bb61d38e61180fa94c6caf335e7 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 22 May 2024 15:15:15 +0100 Subject: [PATCH 02/31] add id primary key to VideoShapefile --- .../migrations/0065_alter_videoshapefile_id.py | 18 ++++++++++++++++++ seshat/apps/core/models.py | 1 + 2 files changed, 19 insertions(+) create mode 100644 seshat/apps/core/migrations/0065_alter_videoshapefile_id.py diff --git a/seshat/apps/core/migrations/0065_alter_videoshapefile_id.py b/seshat/apps/core/migrations/0065_alter_videoshapefile_id.py new file mode 100644 index 000000000..eb3c28094 --- /dev/null +++ b/seshat/apps/core/migrations/0065_alter_videoshapefile_id.py @@ -0,0 +1,18 @@ +# Generated by Django 4.0.3 on 2024-05-22 14:14 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0064_gadmcountries_gadmprovinces_gadmshapefile_and_more'), + ] + + operations = [ + migrations.AlterField( + model_name='videoshapefile', + name='id', + field=models.AutoField(primary_key=True, serialize=False), + ), + ] diff --git a/seshat/apps/core/models.py b/seshat/apps/core/models.py index a8f4d91af..c20840917 100644 --- a/seshat/apps/core/models.py +++ b/seshat/apps/core/models.py @@ -838,6 +838,7 @@ def __str__(self) -> str: # Shapefile models class VideoShapefile(models.Model): + id = models.AutoField(primary_key=True) geom = models.MultiPolygonField() simplified_geom = models.MultiPolygonField(null=True) name=models.CharField(max_length=100) From dfca4fd59b2cdf65b2ebdcda76c6953593dcefde Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 22 May 2024 15:21:24 +0100 Subject: [PATCH 03/31] Refactor world_map.html to add missing shapes to shapesData by ignoring those with a shape.id already there --- seshat/apps/core/templates/core/world_map.html | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 46cc364cf..35d3bfebf 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -267,15 +267,12 @@

Base Map

fetch('/core/world_map_all/') .then(response => response.json()) .then(data => { - data.shapes.forEach(function (shape) { - shape.weight = polityBorderWeight; - let isDuplicate = shapesData.some(existingShape => - existingShape.geom === shape.geom - ); - if (!isDuplicate) { + data.shapes // Add the rest of the shapes to shapesData + .filter(shape => !shapesData.some(existingShape => existingShape.id === shape.id)) + .forEach(shape => { + shape.weight = polityBorderWeight; shapesData.push(shape); - } - }); + }); // Update seshat_id_page_id from the JSON response seshat_id_page_id = data.seshat_id_page_id; From 48efffb9a15456debef20d0168259a6afc89f6b8 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 22 May 2024 16:39:42 +0100 Subject: [PATCH 04/31] add id to get_polity_shape_content --- seshat/apps/core/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index 4f6c4c3f9..9e6faf9d5 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -2690,7 +2690,7 @@ def get_polity_shape_content(displayed_year="all", seshat_id="all"): else: rows = VideoShapefile.objects.all() - rows = rows.values('seshat_id', 'name', 'polity', 'start_year', 'end_year', 'polity_start_year', 'polity_end_year', 'colour', 'area', 'simplified_geom', 'geom') + rows = rows.values('id', 'seshat_id', 'name', 'polity', 'start_year', 'end_year', 'polity_start_year', 'polity_end_year', 'colour', 'area', 'simplified_geom', 'geom') shapes = [] for shape in rows: From a6a7c03c0068282b39be63c97b5c143f8f001007 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Wed, 22 May 2024 16:40:02 +0100 Subject: [PATCH 05/31] filter properly using string conversion --- seshat/apps/core/templates/core/world_map.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 35d3bfebf..62442a3a3 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -268,7 +268,7 @@

Base Map

.then(response => response.json()) .then(data => { data.shapes // Add the rest of the shapes to shapesData - .filter(shape => !shapesData.some(existingShape => existingShape.id === shape.id)) + .filter(shape => !shapesData.some(existingShape => existingShape.id === shape.id.toString())) .forEach(shape => { shape.weight = polityBorderWeight; shapesData.push(shape); From cc71e707015afb5424922e14d50a4bbc7782fd12 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 09:45:51 +0100 Subject: [PATCH 06/31] rename polityMapShapesData --- seshat/apps/core/templates/core/polity_map.html | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seshat/apps/core/templates/core/polity_map.html b/seshat/apps/core/templates/core/polity_map.html index ff273fb65..74a67973b 100644 --- a/seshat/apps/core/templates/core/polity_map.html +++ b/seshat/apps/core/templates/core/polity_map.html @@ -69,7 +69,7 @@
Base Map:
var displayedShapes = []; // Load inital polity shapes for the displayed year - var shapesData = [ + var polityMapShapesData = [ // JavaScript object representing shape data {% for shape in content.shapes %} { @@ -143,7 +143,7 @@
Base Map:
// Add shapes to the map // Don't plot them if "Base map only" checkbox selected if (!document.getElementById('baseMapOnly').checked) { - shapesData.forEach(function (shape) { + polityMapShapesData.forEach(function (shape) { // If the shape spans the selected year if ((parseInt(shape.start_year) <= selectedYearInt && parseInt(shape.end_year) >= selectedYearInt)) { From 83423e81fcb0ea53fa02f9cfacbbc5c847392833 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 10:22:10 +0100 Subject: [PATCH 07/31] load just british empire II first --- seshat/apps/core/templates/core/world_map.html | 4 ++++ seshat/apps/core/views.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 62442a3a3..998546b76 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -285,6 +285,10 @@

Base Map

allPolitiesLoaded = true; + // Update the date slide to use the earliest and latest years + document.getElementById('dateSlide').min = data.earliest_year; + document.getElementById('dateSlide').max = data.latest_year; + // Hide the loading indicator and enable the buttons after the fetch request is done document.getElementById('loadingIndicator').style.display = 'none'; document.getElementById('enterYear').disabled = false; diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index 9e6faf9d5..2d9b80838 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -2972,7 +2972,8 @@ def map_view_initial(request): # If 'year' parameter is not present, redirect to the same view with 'year' set to 1900 return redirect('{}?year={}'.format(request.path, 1900)) - content = get_polity_shape_content(displayed_year=displayed_year) + # content = get_polity_shape_content(displayed_year=displayed_year) + content = get_polity_shape_content(seshat_id="gb_british_emp_2") # Add in the present/absent variables to view for the shapes content['shapes'], content['variables'] = assign_variables_to_shapes(content['shapes'], app_map) From 5cfae1480dd3223121e69f0fea17501025e0226c Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 10:53:30 +0100 Subject: [PATCH 08/31] use polityBorderWeightSelected --- seshat/apps/core/templates/core/world_map.html | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 998546b76..0a248119d 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -213,6 +213,7 @@

Base Map

var displayedShapes = []; var polityBorderWeight = 0; + var polityBorderWeightSelected = 2; // Load inital polity shapes for the displayed year var shapesData = [ @@ -441,7 +442,7 @@

Base Map

}; }; } else if (variable in categorical_variables){ - shapeWeight = 2; + shapeWeight = polityBorderWeightSelected; // If the shape has a dictionary for the variable the key of the dict is the variable value and the value is a list of start and end years. // Iterate through it and choose the colour based on the number of that variable that are active in the selected year var numberOfThisVariable = 0; // Number of different values of this variable that are active in the selected year @@ -482,7 +483,7 @@

Base Map

} } else { // Absent-present variables - shapeWeight = 2; + shapeWeight = polityBorderWeightSelected; shapeColour = variableColourMapping[shape[variable]]; if (shape[variable + '_dict']) { // Iterate through key/values in the dictionary @@ -678,7 +679,7 @@

Base Map

if (allPolitiesLoaded && variable == 'polity'){ if (shape.weight === 0) { // Increase the weight of the clicked layer - newWeight = 2; + newWeight = polityBorderWeightSelected; this.setStyle({ weight: newWeight }); @@ -686,7 +687,7 @@

Base Map

layer.openPopup(); } else { // Decrease the weight of the clicked layer - newWeight = 0; + newWeight = polityBorderWeight; // Close the popup layer.closePopup(); }; @@ -796,7 +797,7 @@

Base Map

// var marker = L.circleMarker([capital.latitude, capital.longitude], { // color: 'black', // Set the border color // fillColor: shape.colour, // Set the fill color based on the "colour" field - // weight: 2, // Set the border weight + // weight: polityBorderWeightSelected, // Set the border weight // fillOpacity: 0.5, // Set the fill opacity // radius: 5 // }); From 9eae6a407070559bd09f5f8c8fd25f1bdf7556ce Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 11:02:34 +0100 Subject: [PATCH 09/31] set the initial year and polity and highlight it by default --- .../apps/core/templates/core/world_map.html | 9 ++++++++- seshat/apps/core/views.py | 19 +++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 0a248119d..618bff148 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -223,7 +223,6 @@

Base Map

{% for key, value in shape.items %} '{{ key }}': '{{ value|escapejs }}', {% endfor %} - 'weight': polityBorderWeight, }, {% endfor %} ]; @@ -250,6 +249,14 @@

Base Map

shape[key] = JSON.parse(newValue.replace(/'/g, '"')); } } + + // Set the border weights for shapes + if (shape.seshat_id && shape.seshat_id === '{{ world_map_initial_polity }}') { + shape.weight = polityBorderWeightSelected; + } else { + shape.weight = polityBorderWeight; + } + }); // Load seshat_id_page_id dictionary diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index 2d9b80838..a6ac58ea9 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -2733,7 +2733,7 @@ def get_polity_shape_content(displayed_year="all", seshat_id="all"): if displayed_year == "all": displayed_year = initial_displayed_year - if seshat_id != "all": + if seshat_id != "all": # Used in the polity pages earliest_year = min([shape['start_year'] for shape in shapes]) displayed_year = earliest_year latest_year = max([shape['end_year'] for shape in shapes]) @@ -2955,6 +2955,10 @@ def assign_categorical_variables_to_shapes(shapes, variables): 'language': sorted([x[0] for x in POLITY_LANGUAGE_CHOICES]) } +# World map defalut settings +world_map_initial_displayed_year = 1900 +world_map_initial_polity = 'gb_british_emp_2' + def map_view_initial(request): """ This view is used to display a map with polities plotted on it. @@ -2969,11 +2973,11 @@ def map_view_initial(request): request.session['year'] = request.GET['year'] displayed_year = request.GET['year'] else: - # If 'year' parameter is not present, redirect to the same view with 'year' set to 1900 - return redirect('{}?year={}'.format(request.path, 1900)) + # If 'year' parameter is not present, redirect to the same view with 'year' set to world_map_initial_displayed_year + return redirect('{}?year={}'.format(request.path, world_map_initial_displayed_year)) # content = get_polity_shape_content(displayed_year=displayed_year) - content = get_polity_shape_content(seshat_id="gb_british_emp_2") + content = get_polity_shape_content(seshat_id=world_map_initial_polity) # Add in the present/absent variables to view for the shapes content['shapes'], content['variables'] = assign_variables_to_shapes(content['shapes'], app_map) @@ -2990,6 +2994,10 @@ def map_view_initial(request): # TODO: Temporary restriction on the latest year for the map view content['latest_year'] = 2014 + + # Set the initial displayed year and polity to highlight + content['display_year'] = world_map_initial_displayed_year + content['world_map_initial_polity'] = world_map_initial_polity return render(request, 'core/world_map.html', @@ -3018,6 +3026,9 @@ def map_view_all(request): # TODO: Temporary restriction on the latest year for the map view content['latest_year'] = 2014 + + # Set the polity to highlight + content['world_map_initial_polity'] = world_map_initial_polity return JsonResponse(content) From 8160a610a7e9c1427ba05b41f087cc95641861e9 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 11:10:47 +0100 Subject: [PATCH 10/31] always redirect --- seshat/apps/core/views.py | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index a6ac58ea9..3fbdf3cfc 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -2965,15 +2965,11 @@ def map_view_initial(request): The inital view just loads the polities for the initial_displayed_year. """ - # Check if 'year' parameter is in the request + # Check if 'year' parameter is different from the world_map_initial_displayed_year or not present then redirect if 'year' in request.GET: - # If 'year' parameter is present, store it in the session - # Ensures that if a user clicks through to a polity page from the world map, - # then hits the back button in browser, the initial year loaded is what they were previously looking at - request.session['year'] = request.GET['year'] - displayed_year = request.GET['year'] + if request.GET['year'] != str(world_map_initial_displayed_year): + return redirect('{}?year={}'.format(request.path, world_map_initial_displayed_year)) else: - # If 'year' parameter is not present, redirect to the same view with 'year' set to world_map_initial_displayed_year return redirect('{}?year={}'.format(request.path, world_map_initial_displayed_year)) # content = get_polity_shape_content(displayed_year=displayed_year) From e2d82146440516034737fdb1e3005e7b0c7b122d Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 11:19:32 +0100 Subject: [PATCH 11/31] remove page reload --- seshat/apps/core/static/core/js/map_functions.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/seshat/apps/core/static/core/js/map_functions.js b/seshat/apps/core/static/core/js/map_functions.js index ebcd0a90e..7c7baf142 100644 --- a/seshat/apps/core/static/core/js/map_functions.js +++ b/seshat/apps/core/static/core/js/map_functions.js @@ -59,12 +59,6 @@ function stopPlay() { function storeYear() { var year = document.getElementById('enterYear').value; history.pushState(null, '', '/core/world_map/?year=' + year); - if (!allPolitiesLoaded) { - // Refresh the page to load all polities - location.reload(); - var loadingTextElement = document.getElementById('loadingText'); - loadingTextElement.innerHTML = 'Loading polities for ' + year + '...'; - } } function switchBaseMap() { From 7127c96fa7b7c51d7ceba7004825acc101ea4504 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 11:19:46 +0100 Subject: [PATCH 12/31] remove page reload --- seshat/apps/core/templates/core/world_map.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 618bff148..fb1a952cd 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -268,7 +268,7 @@

Base Map

var provinceShapeData; var countryShapeData; - var allPolitiesLoaded = false; // Used within storeYear() function + var allPolitiesLoaded = false; // Load all polity shapes and modern province/country shapes in background window.addEventListener('load', function () { From d862055caba417922548be3ada27dbf9af55e287 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 11:20:16 +0100 Subject: [PATCH 13/31] only set end year to 2014 if it's more recent for initial view --- seshat/apps/core/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index 3fbdf3cfc..e899d1060 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -2989,7 +2989,8 @@ def map_view_initial(request): content['categorical_variables'] = categorical_variables # TODO: Temporary restriction on the latest year for the map view - content['latest_year'] = 2014 + if content['latest_year'] > 2014: + content['latest_year'] = 2014 # Set the initial displayed year and polity to highlight content['display_year'] = world_map_initial_displayed_year From 43fe853841baf722eab73e48df4535baf57fd586 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 11:21:28 +0100 Subject: [PATCH 14/31] update loading text --- seshat/apps/core/templates/core/world_map.html | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index fb1a952cd..7076cf3d3 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -98,8 +98,7 @@

Polities

-

Loading polities for all years...

-

Note: You may adjust the year
now to quickly load a year of interest,
but this will slow loading all polities!

+

Loading all polities for all years...

From 8d9020bb8e5a845ea68dcfccaed86b070c1a0987 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 11:24:56 +0100 Subject: [PATCH 15/31] make rome default --- seshat/apps/core/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index e899d1060..cbddcdff7 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -2956,8 +2956,8 @@ def assign_categorical_variables_to_shapes(shapes, variables): } # World map defalut settings -world_map_initial_displayed_year = 1900 -world_map_initial_polity = 'gb_british_emp_2' +world_map_initial_displayed_year = 117 +world_map_initial_polity = 'it_roman_principate' def map_view_initial(request): """ From 665a04648550073d672e5b515357118d1755aec3 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 11:37:22 +0100 Subject: [PATCH 16/31] ungrey play buttons --- seshat/apps/core/templates/core/world_map.html | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 7076cf3d3..88f132bc3 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -142,10 +142,10 @@

Polities




- -
+ +
-
+


@@ -302,8 +302,6 @@

Base Map

document.getElementById('minusButton').disabled = false; document.getElementById('plusButton').disabled = false; document.getElementById('dateSlide').disabled = false; - document.getElementById('playButton').disabled = false; - document.getElementById('stopButton').disabled = false; document.getElementById('playRate').disabled = false; document.getElementById('chooseVariable').disabled = false; From 01b2381641268973f68be916934ed66ed34baa23 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 11:41:49 +0100 Subject: [PATCH 17/31] add space --- seshat/apps/core/templates/core/world_map.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 88f132bc3..19560ca91 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -140,7 +140,7 @@

Polities



-

+


From 51401df8c740526196cda0ad48ae43cb9c61f3bd Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 14:11:22 +0100 Subject: [PATCH 18/31] order shapes by start year --- seshat/apps/core/views.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index cbddcdff7..dee3c86e3 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -2738,6 +2738,9 @@ def get_polity_shape_content(displayed_year="all", seshat_id="all"): displayed_year = earliest_year latest_year = max([shape['end_year'] for shape in shapes]) + # Order the shapes by start year + shapes = sorted(shapes, key=lambda x: x['start_year']) + content = { 'shapes': shapes, 'earliest_year': earliest_year, From db14c598759880bf5eddc9a99116c78199d2dbbd Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 15:53:11 +0100 Subject: [PATCH 19/31] remove legacy button enabling --- seshat/apps/core/templates/core/world_map.html | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 19560ca91..ea8ef181c 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -296,14 +296,8 @@

Base Map

document.getElementById('dateSlide').min = data.earliest_year; document.getElementById('dateSlide').max = data.latest_year; - // Hide the loading indicator and enable the buttons after the fetch request is done + // Hide the loading indicator after the fetch request is done document.getElementById('loadingIndicator').style.display = 'none'; - document.getElementById('enterYear').disabled = false; - document.getElementById('minusButton').disabled = false; - document.getElementById('plusButton').disabled = false; - document.getElementById('dateSlide').disabled = false; - document.getElementById('playRate').disabled = false; - document.getElementById('chooseVariable').disabled = false; // Start the second fetch after the first one is complete return fetch('/core/provinces_and_countries'); From 073ab84d8c9ccb4752f6f6c9174b30632b41e9e0 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 16:03:01 +0100 Subject: [PATCH 20/31] load shapes for one year as well --- .../apps/core/templates/core/world_map.html | 29 +++++++++++++++-- seshat/apps/core/urls.py | 1 + seshat/apps/core/views.py | 32 +++++++++++++++++-- 3 files changed, 57 insertions(+), 5 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index ea8ef181c..98a16d063 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -271,10 +271,10 @@

Base Map

// Load all polity shapes and modern province/country shapes in background window.addEventListener('load', function () { - fetch('/core/world_map_all/') + fetch('/core/world_map_one_year/') .then(response => response.json()) .then(data => { - data.shapes // Add the rest of the shapes to shapesData + data.shapes // Add the shapes from the url year to shapesData .filter(shape => !shapesData.some(existingShape => existingShape.id === shape.id.toString())) .forEach(shape => { shape.weight = polityBorderWeight; @@ -290,12 +290,35 @@

Base Map

// Call plotPolities() after shapesData is updated plotPolities(); - allPolitiesLoaded = true; + // Update the date slide to use the earliest and latest years + document.getElementById('dateSlide').min = data.earliest_year; + document.getElementById('dateSlide').max = data.latest_year; + }) + .then(() => fetch('/core/world_map_all/')) + .then(response => response.json()) + .then(data => { + data.shapes // Add the rest of the shapes to shapesData + .filter(shape => !shapesData.some(existingShape => existingShape.id === shape.id.toString())) + .forEach(shape => { + shape.weight = polityBorderWeight; + shapesData.push(shape); + }); + + // Update seshat_id_page_id from the JSON response + seshat_id_page_id = data.seshat_id_page_id; + + // Update allCapitalsInfo from the JSON response + allCapitalsInfo = data.all_capitals_info; + + // Call plotPolities() after shapesData is updated + plotPolities(); // Update the date slide to use the earliest and latest years document.getElementById('dateSlide').min = data.earliest_year; document.getElementById('dateSlide').max = data.latest_year; + allPolitiesLoaded = true; + // Hide the loading indicator after the fetch request is done document.getElementById('loadingIndicator').style.display = 'none'; diff --git a/seshat/apps/core/urls.py b/seshat/apps/core/urls.py index 6285732ba..e958b526c 100644 --- a/seshat/apps/core/urls.py +++ b/seshat/apps/core/urls.py @@ -165,5 +165,6 @@ # Map urls urlpatterns += [path('core/world_map/', views.map_view_initial, name='world_map'),] +urlpatterns += [path('core/world_map_one_year/', views.map_view_one_year, name='world_map_one_year'),] urlpatterns += [path('core/world_map_all/', views.map_view_all, name='world_map_all'),] urlpatterns += [path('core/provinces_and_countries', views.provinces_and_countries_view, name='provinces_and_countries'),] \ No newline at end of file diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index dee3c86e3..67e1d6c60 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -2965,7 +2965,7 @@ def assign_categorical_variables_to_shapes(shapes, variables): def map_view_initial(request): """ This view is used to display a map with polities plotted on it. - The inital view just loads the polities for the initial_displayed_year. + The inital view just loads the world_map_initial_polity. """ # Check if 'year' parameter is different from the world_map_initial_displayed_year or not present then redirect @@ -2975,7 +2975,6 @@ def map_view_initial(request): else: return redirect('{}?year={}'.format(request.path, world_map_initial_displayed_year)) - # content = get_polity_shape_content(displayed_year=displayed_year) content = get_polity_shape_content(seshat_id=world_map_initial_polity) # Add in the present/absent variables to view for the shapes @@ -3004,6 +3003,35 @@ def map_view_initial(request): content ) +def map_view_one_year(request): + """ + This view is used to display a map with polities plotted on it. + The view loads all polities present in the year in the url. + """ + year = request.GET.get('year', world_map_initial_displayed_year) + content = get_polity_shape_content(displayed_year=year) + + # Add in the present/absent variables to view for the shapes + content['shapes'], content['variables'] = assign_variables_to_shapes(content['shapes'], app_map) + + # Add in the categorical variables to view for the shapes + content['shapes'], content['variables'] = assign_categorical_variables_to_shapes(content['shapes'], content['variables']) + + # Load the capital cities for polities that have them + caps = get_all_polity_capitals() + content['all_capitals_info'] = caps + + # Add categorical variable choices to content for dropdown selection + content['categorical_variables'] = categorical_variables + + # TODO: Temporary restriction on the latest year for the map view + content['latest_year'] = 2014 + + # Set the polity to highlight + content['world_map_initial_polity'] = world_map_initial_polity + + return JsonResponse(content) + def map_view_all(request): """ This view is used to display a map with polities plotted on it. From fcaa1bab75e45ec206fbc4973d629e204aba4782 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 16:05:33 +0100 Subject: [PATCH 21/31] handle shape.id as int --- seshat/apps/core/templates/core/world_map.html | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 98a16d063..34cf1bc9c 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -256,6 +256,9 @@

Base Map

shape.weight = polityBorderWeight; } + // Convert shape.id to int + shape.id = parseInt(shape.id); + }); // Load seshat_id_page_id dictionary @@ -275,7 +278,7 @@

Base Map

.then(response => response.json()) .then(data => { data.shapes // Add the shapes from the url year to shapesData - .filter(shape => !shapesData.some(existingShape => existingShape.id === shape.id.toString())) + .filter(shape => !shapesData.some(existingShape => existingShape.id === shape.id)) .forEach(shape => { shape.weight = polityBorderWeight; shapesData.push(shape); @@ -298,7 +301,7 @@

Base Map

.then(response => response.json()) .then(data => { data.shapes // Add the rest of the shapes to shapesData - .filter(shape => !shapesData.some(existingShape => existingShape.id === shape.id.toString())) + .filter(shape => !shapesData.some(existingShape => existingShape.id === shape.id)) .forEach(shape => { shape.weight = polityBorderWeight; shapesData.push(shape); From 42b0f794ddccef0853dc408fd18d3f719c92d5f5 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 16:12:04 +0100 Subject: [PATCH 22/31] dont update date slide for world_map_one_year --- seshat/apps/core/templates/core/world_map.html | 3 --- 1 file changed, 3 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index 34cf1bc9c..d6a3c7fb6 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -293,9 +293,6 @@

Base Map

// Call plotPolities() after shapesData is updated plotPolities(); - // Update the date slide to use the earliest and latest years - document.getElementById('dateSlide').min = data.earliest_year; - document.getElementById('dateSlide').max = data.latest_year; }) .then(() => fetch('/core/world_map_all/')) .then(response => response.json()) From b43b70b40f69795096dfe3c455a7027f73740978 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 16:26:47 +0100 Subject: [PATCH 23/31] enable adding to legend in advance of all polities loading --- seshat/apps/core/templates/core/world_map.html | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/seshat/apps/core/templates/core/world_map.html b/seshat/apps/core/templates/core/world_map.html index d6a3c7fb6..15b227dd7 100644 --- a/seshat/apps/core/templates/core/world_map.html +++ b/seshat/apps/core/templates/core/world_map.html @@ -270,8 +270,6 @@

Base Map

var provinceShapeData; var countryShapeData; - var allPolitiesLoaded = false; - // Load all polity shapes and modern province/country shapes in background window.addEventListener('load', function () { fetch('/core/world_map_one_year/') @@ -317,8 +315,6 @@

Base Map

document.getElementById('dateSlide').min = data.earliest_year; document.getElementById('dateSlide').max = data.latest_year; - allPolitiesLoaded = true; - // Hide the loading indicator after the fetch request is done document.getElementById('loadingIndicator').style.display = 'none'; @@ -697,7 +693,7 @@

Base Map

// Listen for the click event on the layer layer.on('click', function (e) { - if (allPolitiesLoaded && variable == 'polity'){ + if (variable == 'polity'){ if (shape.weight === 0) { // Increase the weight of the clicked layer newWeight = polityBorderWeightSelected; From 3ae638bccb33ed05646d27bb6d27f755ff0deea2 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Thu, 23 May 2024 16:39:29 +0100 Subject: [PATCH 24/31] pick a random polity --- seshat/apps/core/views.py | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index 67e1d6c60..d985ea0e7 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -1,5 +1,6 @@ import sys import importlib +import random from collections import defaultdict from seshat.utils.utils import adder, dic_of_all_vars, list_of_all_Polities, dic_of_all_vars_in_sections @@ -2958,9 +2959,23 @@ def assign_categorical_variables_to_shapes(shapes, variables): 'language': sorted([x[0] for x in POLITY_LANGUAGE_CHOICES]) } -# World map defalut settings -world_map_initial_displayed_year = 117 -world_map_initial_polity = 'it_roman_principate' +def random_polity(): + """ + Get a random polity for the world map initial view. + Use the VideoShapefile model to get the polity shapes. + Choose one that has a seshat_id. + Return the seshat_id and start year. + """ + max_id = VideoShapefile.objects.filter(seshat_id__isnull=False).aggregate(max_id=Max("id"))['max_id'] + while True: + pk = random.randint(1, max_id) + polity = VideoShapefile.objects.filter(seshat_id__isnull=False, id=pk).first() + if polity: + break + return polity.start_year, polity.seshat_id + +# World map default settings +world_map_initial_displayed_year, world_map_initial_polity = random_polity() def map_view_initial(request): """ From edbef6415a67f70b118589963d3ae3aa4de1d355 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Fri, 24 May 2024 11:18:30 +0100 Subject: [PATCH 25/31] random polity (with seshat id) as initial loaded works --- seshat/apps/core/views.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index d985ea0e7..843a7fecf 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -2971,13 +2971,12 @@ def random_polity(): pk = random.randint(1, max_id) polity = VideoShapefile.objects.filter(seshat_id__isnull=False, id=pk).first() if polity: - break + if polity.seshat_id: + break return polity.start_year, polity.seshat_id -# World map default settings -world_map_initial_displayed_year, world_map_initial_polity = random_polity() - def map_view_initial(request): + global world_map_initial_displayed_year, world_map_initial_polity """ This view is used to display a map with polities plotted on it. The inital view just loads the world_map_initial_polity. @@ -2988,6 +2987,9 @@ def map_view_initial(request): if request.GET['year'] != str(world_map_initial_displayed_year): return redirect('{}?year={}'.format(request.path, world_map_initial_displayed_year)) else: + # Select a random polity for the initial view + world_map_initial_displayed_year, world_map_initial_polity = random_polity() + print(world_map_initial_displayed_year, world_map_initial_polity) return redirect('{}?year={}'.format(request.path, world_map_initial_displayed_year)) content = get_polity_shape_content(seshat_id=world_map_initial_polity) From 492ae3ef32099ac5d16a4467e8e78059b934fa74 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Fri, 24 May 2024 11:26:07 +0100 Subject: [PATCH 26/31] keep defaults --- seshat/apps/core/views.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index 843a7fecf..5a6671ea6 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -2975,6 +2975,10 @@ def random_polity(): break return polity.start_year, polity.seshat_id +# World map defalut settings +world_map_initial_displayed_year = 117 +world_map_initial_polity = 'it_roman_principate' + def map_view_initial(request): global world_map_initial_displayed_year, world_map_initial_polity """ From 1e2ade60e493c796e19d7f660eaa8e4a7394f4a2 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Fri, 24 May 2024 11:46:10 +0100 Subject: [PATCH 27/31] add ids for test shapes --- seshat/apps/core/tests/tests.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/seshat/apps/core/tests/tests.py b/seshat/apps/core/tests/tests.py index 38112d568..111f889ac 100644 --- a/seshat/apps/core/tests/tests.py +++ b/seshat/apps/core/tests/tests.py @@ -43,6 +43,7 @@ def setUp(self): end_year=1100 ) self.video_shapefile = VideoShapefile.objects.create( + id=1, geom=self.square, simplified_geom=self.square, name="Test shape", @@ -56,6 +57,7 @@ def setUp(self): colour="#FFFFFF" ) VideoShapefile.objects.create( + id=2, geom=self.square, simplified_geom=self.square, name="Test shape 2", @@ -204,7 +206,8 @@ def test_get_polity_shape_content(self): 'polity_end_year': 2020, 'colour': "#FFFFFF", 'area': 100.0, - 'geom': self.geo_square + 'geom': self.geo_square, + 'id': 1 }, { 'seshat_id': 'Test seshat_id 2', @@ -216,7 +219,8 @@ def test_get_polity_shape_content(self): 'polity_end_year': 1000, 'colour': "#FFFFFF", 'area': 100.0, - 'geom': self.geo_square + 'geom': self.geo_square, + 'id': 2 } ], 'earliest_year': 0, @@ -248,7 +252,8 @@ def test_get_polity_shape_content_single_year(self): 'polity_end_year': 2020, 'colour': "#FFFFFF", 'area': 100.0, - 'geom': self.geo_square + 'geom': self.geo_square, + 'id': 1 } ], 'earliest_year': 0, # This is the earliest year in the database, not the earliest year of the polity @@ -279,7 +284,8 @@ def test_get_polity_shape_content_single_seshat_id(self): 'polity_end_year': 2020, 'colour': "#FFFFFF", 'area': 100.0, - 'geom': self.geo_square + 'geom': self.geo_square, + 'id': 1 } ], 'earliest_year': 2000, # This is the earliest year of the polity @@ -333,7 +339,8 @@ def test_polity_map(self): 'polity_end_year': 2020, 'colour': "#FFFFFF", 'area': 100.0, - 'geom': self.geo_square + 'geom': self.geo_square, + 'id': 1 } ], 'earliest_year': 2000, @@ -367,7 +374,8 @@ def test_polity_map_no_peak_year_set(self): 'polity_end_year': 1000, 'colour': "#FFFFFF", 'area': 100.0, - 'geom': self.geo_square + 'geom': self.geo_square, + 'id': 2 } ], 'earliest_year': 0, @@ -426,7 +434,8 @@ def test_assign_variables_to_shapes(self): 'polity_end_year': 1000, 'colour': "#FFFFFF", 'area': 100.0, - 'geom': self.geo_square + 'geom': self.geo_square, + 'id': 2 } ] app_map = { @@ -465,7 +474,8 @@ def test_assign_categorical_variables_to_shapes(self): 'polity_end_year': 1000, 'colour': "#FFFFFF", 'area': 100.0, - 'geom': self.geo_square + 'geom': self.geo_square, + 'id': 2 } ] result_shapes, result_variables = assign_categorical_variables_to_shapes(shapes, {}) From 2c30045681e39254c29eed1d30f86dd9afda9ad2 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Fri, 24 May 2024 11:48:50 +0100 Subject: [PATCH 28/31] remove pointless ordering of shapes --- seshat/apps/core/views.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index 5a6671ea6..af3d28b5c 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -2739,9 +2739,6 @@ def get_polity_shape_content(displayed_year="all", seshat_id="all"): displayed_year = earliest_year latest_year = max([shape['end_year'] for shape in shapes]) - # Order the shapes by start year - shapes = sorted(shapes, key=lambda x: x['start_year']) - content = { 'shapes': shapes, 'earliest_year': earliest_year, From 293c47eb28138c31b7027e0b1e118237f4e852d8 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Fri, 24 May 2024 12:03:34 +0100 Subject: [PATCH 29/31] refactor view funcs --- seshat/apps/core/views.py | 58 +++++++++++++++------------------------ 1 file changed, 22 insertions(+), 36 deletions(-) diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index af3d28b5c..2d672316d 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -2972,6 +2972,25 @@ def random_polity(): break return polity.start_year, polity.seshat_id +def common_map_view_content(content): + """ + Set of functions that update content and run in each map view function. + """ + # Add in the present/absent variables to view for the shapes + content['shapes'], content['variables'] = assign_variables_to_shapes(content['shapes'], app_map) + + # Add in the categorical variables to view for the shapes + content['shapes'], content['variables'] = assign_categorical_variables_to_shapes(content['shapes'], content['variables']) + + # Load the capital cities for polities that have them + caps = get_all_polity_capitals() + content['all_capitals_info'] = caps + + # Add categorical variable choices to content for dropdown selection + content['categorical_variables'] = categorical_variables + + return content + # World map defalut settings world_map_initial_displayed_year = 117 world_map_initial_polity = 'it_roman_principate' @@ -2995,18 +3014,7 @@ def map_view_initial(request): content = get_polity_shape_content(seshat_id=world_map_initial_polity) - # Add in the present/absent variables to view for the shapes - content['shapes'], content['variables'] = assign_variables_to_shapes(content['shapes'], app_map) - - # Add in the categorical variables to view for the shapes - content['shapes'], content['variables'] = assign_categorical_variables_to_shapes(content['shapes'], content['variables']) - - # Load the capital cities for polities that have them - caps = get_all_polity_capitals() - content['all_capitals_info'] = caps - - # Add categorical variable choices to content for dropdown selection - content['categorical_variables'] = categorical_variables + content = common_map_view_content(content) # TODO: Temporary restriction on the latest year for the map view if content['latest_year'] > 2014: @@ -3029,18 +3037,7 @@ def map_view_one_year(request): year = request.GET.get('year', world_map_initial_displayed_year) content = get_polity_shape_content(displayed_year=year) - # Add in the present/absent variables to view for the shapes - content['shapes'], content['variables'] = assign_variables_to_shapes(content['shapes'], app_map) - - # Add in the categorical variables to view for the shapes - content['shapes'], content['variables'] = assign_categorical_variables_to_shapes(content['shapes'], content['variables']) - - # Load the capital cities for polities that have them - caps = get_all_polity_capitals() - content['all_capitals_info'] = caps - - # Add categorical variable choices to content for dropdown selection - content['categorical_variables'] = categorical_variables + content = common_map_view_content(content) # TODO: Temporary restriction on the latest year for the map view content['latest_year'] = 2014 @@ -3057,18 +3054,7 @@ def map_view_all(request): """ content = get_polity_shape_content() - # Add in the present/absent variables to view for the shapes - content['shapes'], content['variables'] = assign_variables_to_shapes(content['shapes'], app_map) - - # Add in the categorical variables to view for the shapes - content['shapes'], content['variables'] = assign_categorical_variables_to_shapes(content['shapes'], content['variables']) - - # Load the capital cities for polities that have them - caps = get_all_polity_capitals() - content['all_capitals_info'] = caps - - # Add categorical variable choices to content for dropdown selection - content['categorical_variables'] = categorical_variables + content = common_map_view_content(content) # TODO: Temporary restriction on the latest year for the map view content['latest_year'] = 2014 From 8983dc769d408aa29cc053b08ab699bfb2972d6d Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Fri, 24 May 2024 12:04:01 +0100 Subject: [PATCH 30/31] simplify --- seshat/apps/core/views.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index 2d672316d..7479ecac2 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -2983,8 +2983,7 @@ def common_map_view_content(content): content['shapes'], content['variables'] = assign_categorical_variables_to_shapes(content['shapes'], content['variables']) # Load the capital cities for polities that have them - caps = get_all_polity_capitals() - content['all_capitals_info'] = caps + content['all_capitals_info'] = get_all_polity_capitals() # Add categorical variable choices to content for dropdown selection content['categorical_variables'] = categorical_variables From a92da32891fb360ddb4e3f6f035be67ae00f3f4b Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Fri, 24 May 2024 12:09:02 +0100 Subject: [PATCH 31/31] further refactor of map views --- seshat/apps/core/views.py | 30 ++++++++++-------------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/seshat/apps/core/views.py b/seshat/apps/core/views.py index 7479ecac2..f79d7ba10 100644 --- a/seshat/apps/core/views.py +++ b/seshat/apps/core/views.py @@ -2988,6 +2988,13 @@ def common_map_view_content(content): # Add categorical variable choices to content for dropdown selection content['categorical_variables'] = categorical_variables + # TODO: Temporary restriction on the latest year for the map view + if content['latest_year'] > 2014: + content['latest_year'] = 2014 + + # Set the initial polity to highlight + content['world_map_initial_polity'] = world_map_initial_polity + return content # World map defalut settings @@ -2998,7 +3005,8 @@ def map_view_initial(request): global world_map_initial_displayed_year, world_map_initial_polity """ This view is used to display a map with polities plotted on it. - The inital view just loads the world_map_initial_polity. + The inital view just loads a polity with a seshat_id picked at random + and sets the display year to that polity start year. """ # Check if 'year' parameter is different from the world_map_initial_displayed_year or not present then redirect @@ -3008,20 +3016,14 @@ def map_view_initial(request): else: # Select a random polity for the initial view world_map_initial_displayed_year, world_map_initial_polity = random_polity() - print(world_map_initial_displayed_year, world_map_initial_polity) return redirect('{}?year={}'.format(request.path, world_map_initial_displayed_year)) content = get_polity_shape_content(seshat_id=world_map_initial_polity) content = common_map_view_content(content) - # TODO: Temporary restriction on the latest year for the map view - if content['latest_year'] > 2014: - content['latest_year'] = 2014 - - # Set the initial displayed year and polity to highlight + # For the initial view, set the displayed year to the polity's start year content['display_year'] = world_map_initial_displayed_year - content['world_map_initial_polity'] = world_map_initial_polity return render(request, 'core/world_map.html', @@ -3037,12 +3039,6 @@ def map_view_one_year(request): content = get_polity_shape_content(displayed_year=year) content = common_map_view_content(content) - - # TODO: Temporary restriction on the latest year for the map view - content['latest_year'] = 2014 - - # Set the polity to highlight - content['world_map_initial_polity'] = world_map_initial_polity return JsonResponse(content) @@ -3054,12 +3050,6 @@ def map_view_all(request): content = get_polity_shape_content() content = common_map_view_content(content) - - # TODO: Temporary restriction on the latest year for the map view - content['latest_year'] = 2014 - - # Set the polity to highlight - content['world_map_initial_polity'] = world_map_initial_polity return JsonResponse(content)