WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Commit f8b2166

Browse files
authored
Merge pull request #288 from Seshat-Global-History-Databank/instability_data
improved the looks and removed unnecessary print statements
2 parents 60eb907 + 3b917c8 commit f8b2166

File tree

15 files changed

+130
-159
lines changed

15 files changed

+130
-159
lines changed

seshat/apps/core/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from seshat.utils.utils import adder, dic_of_all_vars, list_of_all_Polities, dic_of_all_vars_in_sections
1+
from seshat.utils.utils import dic_of_all_vars, list_of_all_Polities, dic_of_all_vars_in_sections
22

33
from django import forms
44
from django.forms import formset_factory

seshat/apps/core/management/commands/check_api_internally.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ def handle(self, *args, **options):
4747
else:
4848
self.stdout.write(self.style.SUCCESS("\n✅ All endpoints are valid."))
4949

50-
print('####### PASSED ####')
51-
print(passed_dic)
52-
print('###################')
53-
print('####### Failed ####')
54-
print(failed_dic)
55-
print('###################')
50+
# print('####### PASSED ####')
51+
# print(passed_dic)
52+
# print('###################')
53+
# print('####### Failed ####')
54+
# print(failed_dic)
55+
# print('###################')

seshat/apps/core/templates/core/generic_templates/generic_list_all.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
{% endautoescape %}
5252
{% if var_section != 'Luxury Goods' %}
5353
{% include "core/partials/_all_tags_inline_obj.html" %}
54+
{% else %}
55+
{% include "core/partials/_all_tags_inline_obj_lux.html" %}
5456
{% endif %}
5557

5658

seshat/apps/core/templates/core/list_base_for_new_approach.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -639,9 +639,18 @@ <h6 class="fw-bold"><span class="fw-normal"><i class="fa-solid fa-caret-right"><
639639

640640
<thead>
641641
<tr class="sticky-top" style="background-color:#ffffff;height:40px; top: 95px; z-index:900;">
642-
<th scope="col" style="text-align: left; width:15%; " class="fw-light">
642+
643+
{% if var_name_display != 'Instability Event' %}
644+
645+
<th scope="col" style="text-align: left; width:25%; " class="fw-light">
643646
<a href="?{% query_transform request orderby='-polity__long_name' %}"><i class="fa-solid fa-arrow-up-z-a"></i>&nbsp;</a>Polity <a href="?{% query_transform request orderby='polity__long_name' %}"><i class="fa-solid fa-arrow-up-a-z"></i>&nbsp;</a>
644647
</th>
648+
{% else %}
649+
<th scope="col" style="text-align: left; width:15%; " class="fw-light">
650+
<a href="?{% query_transform request orderby='-polity__long_name' %}"><i class="fa-solid fa-arrow-up-z-a"></i>&nbsp;</a>Polity <a href="?{% query_transform request orderby='polity__long_name' %}"><i class="fa-solid fa-arrow-up-a-z"></i>&nbsp;</a>
651+
</th>
652+
{% endif %}
653+
645654
{% if user|in_group:"Chief Seshat External Experts" %}
646655
<th> </th> {% endif %}
647656
<!-- headings for extra vars -->
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<span style="display:inline">
2+
3+
{% if obj.is_disputed %}
4+
5+
<a type="button" class="fs-6 ms-1" data-bs-toggle="tooltip" data-bs-html="true" title="Scholarly Disagreement (Disputed)">
6+
<span class="badge" style="font-family: 'Roboto Mono', monospace; font-optical-sizing: auto; font-weight: 700; background:#f39b9b11; color:#c53636; border:1px solid #c5363688;"><i class="fa-regular fa-star-half-stroke"></i> Disputed</span>
7+
</a>
8+
9+
{% endif %}
10+
11+
<!-- Disputred tag (Disputed/or Not etc.) -->
12+
{% if obj.is_uncertain %}
13+
<a type="button" class="fs-6 ms-1 badge p-0 m-0" style="font-family: 'Roboto Mono', monospace; font-optical-sizing: auto; font-weight: 700; color:#c9b458; border:1px solid #c9b45888; background:#c9b45811;" data-bs-toggle="tooltip" data-bs-html="true" title="Uncertainty has been coded.">
14+
<span class="badge" style="color:#c9b458;"><i class="fa-regular fa-circle-question fa-sm"></i> Uncertain</span>
15+
</a>
16+
{% endif %}
17+
18+
<!-- Expert Checked Tag -->
19+
{% if obj.seshat_experts_list %}
20+
<a type="button" class="fs-6 ms-1" data-bs-toggle="tooltip" data-bs-html="true" title="Reviewed By: {{ obj.seshat_experts_list }}">
21+
<span class="badge" style="font-family: 'Roboto Mono', monospace; font-optical-sizing: auto; font-weight: 700; background:#c3ddf9; color:#12457b;"><i class="fas fa-check-circle p-0 m-0" style="color:#2978ce"></i> Expert</span>
22+
</a>
23+
{% endif %}
24+
25+
</span>
26+
27+

seshat/apps/core/views.py

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import numpy as np
55

66
from collections import defaultdict, OrderedDict
7-
from seshat.utils.utils import adder, dic_of_all_vars, list_of_all_Polities, dic_of_all_vars_in_sections
7+
from seshat.utils.utils import dic_of_all_vars, list_of_all_Polities, dic_of_all_vars_in_sections
88

99
from seshat.apps.crisisdb.models import Human_sacrifice
1010
from seshat.apps.stlm.models import Settlement_population
@@ -87,7 +87,7 @@
8787
import pprint
8888
import requests
8989
from requests.structures import CaseInsensitiveDict
90-
from seshat.utils.utils import adder, dic_of_all_vars, list_of_all_Polities, dic_of_all_vars_in_sections, dic_of_all_vars_with_varhier, get_all_data_for_a_polity, polity_detail_data_collector, get_all_general_data_for_a_polity, get_all_sc_data_for_a_polity, get_all_wf_data_for_a_polity,get_all_ec_data_for_a_polity, get_all_rt_data_for_a_polity, get_all_crisis_cases_data_for_a_polity, get_all_power_transitions_data_for_a_polity, get_all_instability_data_for_a_polity, give_polity_app_data
90+
from seshat.utils.utils import dic_of_all_vars, list_of_all_Polities, dic_of_all_vars_in_sections, dic_of_all_vars_with_varhier, get_all_data_for_a_polity, polity_detail_data_collector, get_all_general_data_for_a_polity, get_all_sc_data_for_a_polity, get_all_wf_data_for_a_polity,get_all_ec_data_for_a_polity, get_all_rt_data_for_a_polity, get_all_crisis_cases_data_for_a_polity, get_all_power_transitions_data_for_a_polity, get_all_instability_data_for_a_polity, give_polity_app_data
9191

9292

9393
from django.shortcuts import HttpResponse
@@ -2238,8 +2238,6 @@ def get_context_data(self, **kwargs):
22382238
all_ngas = Nga.objects.all()
22392239
all_pols = Polity.objects.all().order_by('start_year')
22402240
pol_count = len(all_pols)
2241-
#import time
2242-
#start_time = time.time()
22432241

22442242
all_polities_g_sc_wf = give_polity_app_data()
22452243

@@ -2294,8 +2292,6 @@ def get_context_data(self, **kwargs):
22942292
#a_polity.has_pt = None
22952293
a_polity.has_g_sc_wf = None
22962294

2297-
#end_time = time.time()
2298-
#print('elapsed_time ', end_time-start_time)
22992295

23002296
for a_world_region, all_its_sub_regions in all_world_regions.items():
23012297
for a_subregion in all_its_sub_regions:
@@ -2391,8 +2387,6 @@ def get_context_data(self, **kwargs):
23912387
dict: The context data of the view.
23922388
"""
23932389
context = super().get_context_data(**kwargs)
2394-
#import time
2395-
#start_time = time.time()
23962390
all_srs_unsorted = Seshat_region.objects.all()
23972391
#all_mrs_unsorted = Macro_region.objects.all()
23982392
all_mrs_unsorted = Macro_region.objects.exclude(name='World')
@@ -2457,9 +2451,6 @@ def get_context_data(self, **kwargs):
24572451
freq_dic['pol_count'] = pol_count
24582452
context["freq_data"] = freq_dic
24592453

2460-
#end_time = time.time()
2461-
#print('elapsed_time ', end_time-start_time)
2462-
24632454
return context
24642455

24652456
class PolityListView(SuccessMessageMixin, generic.ListView):
@@ -2495,10 +2486,7 @@ def get_context_data(self, **kwargs):
24952486
Returns:
24962487
dict: The context data of the view.
24972488
"""
2498-
start3 = time.time()
24992489
context = super().get_context_data(**kwargs)
2500-
#import time
2501-
#start_time = time.time()
25022490
all_srs_unsorted = Seshat_region.objects.all()
25032491
#all_mrs_unsorted = Macro_region.objects.all()
25042492
all_mrs_unsorted = Macro_region.objects.exclude(name='World')
@@ -2543,11 +2531,7 @@ def get_context_data(self, **kwargs):
25432531
all_pols = Polity.objects.all().order_by('start_year')
25442532
pol_count = len(all_pols)
25452533

2546-
end3 = time.time()
25472534

2548-
print(f"33333333333333333333333 took {end3 - start3:.2f} seconds to run")
2549-
start2 = time.time()
2550-
print('HIIIIIIIIIIIIIIIII')
25512535
ultimate_wregion_dic = {}
25522536
ultimate_wregion_dic_top = {}
25532537
for a_mr in all_mrs:
@@ -2563,19 +2547,11 @@ def get_context_data(self, **kwargs):
25632547
ultimate_wregion_dic_top[a_mr.name][a_sr.name] = [a_sr.subregions_list, 0]
25642548

25652549

2566-
print('---------------------------')
25672550
all_polities_g_sc_wf, freq_dic = give_polity_app_data(user_selected_tag)
25682551
#all_polities_g_sc_wf = give_polity_app_data()
25692552
#freq_dic = {}
25702553
freq_dic["d"] = 0
25712554

2572-
end2 = time.time()
2573-
2574-
print(f"cccccccccccccccccccccccc took {end2 - start2:.2f} seconds to run")
2575-
2576-
start = time.time()
2577-
2578-
# Pre-fetch related data to reduce DB hits
25792555

25802556
all_pols = all_pols.select_related(
25812557
'home_seshat_region__mac_region'
@@ -2608,7 +2584,6 @@ def get_context_data(self, **kwargs):
26082584
# a_polity.d_o_c = Polity_degree_of_centralization.objects.filter(polity_id=a_polity.id)
26092585
# a_polity.s_p_r = Polity_suprapolity_relations.objects.filter(polity_id=a_polity.id)
26102586

2611-
#start = time.time()
26122587

26132588
for a_polity in all_pols:
26142589
try:
@@ -2674,10 +2649,6 @@ def get_context_data(self, **kwargs):
26742649
# elif all_durations["intr"]:
26752650
# a_polity.color = "gmm"
26762651

2677-
#end = time.time()
2678-
2679-
#print(f"hoooooooooooooooy took {end - start:.2f} seconds to run")
2680-
26812652

26822653
context["ultimate_wregion_dic"] = ultimate_wregion_dic
26832654
context["ultimate_wregion_dic_top"] = ultimate_wregion_dic_top
@@ -2687,9 +2658,6 @@ def get_context_data(self, **kwargs):
26872658
freq_dic['pol_count'] = pol_count
26882659
context["freq_data"] = freq_dic
26892660

2690-
#end_time = time.time()
2691-
#print('elapsed_time ', end_time-start_time)
2692-
26932661
return context
26942662

26952663

@@ -3859,12 +3827,10 @@ def update_citations_from_inside_zotero_update():
38593827
Returns:
38603828
None
38613829
"""
3862-
from datetime import datetime
38633830
all_refs = Reference.objects.all()
38643831
for ref in all_refs:
38653832
a_citation = Citation.objects.get_or_create(ref=ref, page_from=None, page_to=None)
38663833
a_citation[0].save()
3867-
print("Halllooooo")
38683834
# Citation.objects.bulk_create(all_citations)
38693835
#return render (request, 'core/references/reference_list.html')
38703836

seshat/apps/crisisdb/templates/crisisdb/instability_analytics.html

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -727,38 +727,30 @@ <h6>
727727
<div id="myCustomLegendDP" class="chart-legend"></div>
728728
</div>
729729
</div>
730-
731-
732-
733-
734730
</div>
735-
736-
737-
738-
739731

740732
</div>
741733

742-
<div class="row">
743-
<div class="col-md-12 pt-5">
744-
<span class=" fs-4"> Comapring LLM Data with Researcher Approved Data:
745-
</span>
746-
<br>
747-
<span class="fs-6 text-secondary"> Only Researcher-Checked Rows Considered (Total: {{total_checked}})
748-
</span>
749-
</div>
750-
<div class="col-md-4 p-1 ">
751-
<canvas id="intensityComp" height="8" width="10"></canvas>
752-
</div>
734+
<div class="row pb-3">
735+
<div class="col-md-12 pt-5">
736+
<span class=" fs-4"> Comapring LLM Data with Researcher Approved Data:
737+
</span>
738+
<br>
739+
<span class="fs-6 text-secondary"> Only Researcher-Checked Rows Considered (Total: {{total_checked}})
740+
</span>
741+
</div>
742+
<div class="col-md-4 p-1 ">
743+
<canvas id="intensityComp" height="8" width="10"></canvas>
744+
</div>
753745

754-
<div class="col-md-4 p-1 ">
755-
<canvas id="extentComp" height="8" width="10"></canvas>
756-
</div>
757-
746+
<div class="col-md-4 p-1 ">
747+
<canvas id="extentComp" height="8" width="10"></canvas>
748+
</div>
749+
758750

759-
<div class="col-md-4 p-1 ">
760-
<canvas id="year_rangeComp" height="8" width="10"></canvas>
761-
</div>
751+
<div class="col-md-4 p-1 ">
752+
<canvas id="year_rangeComp" height="8" width="10"></canvas>
753+
</div>
762754
</div>
763755
</div>
764756

@@ -1180,10 +1172,10 @@ <h6>
11801172
},
11811173
anchor: function(context) {
11821174
// If value is tall enough, place inside (center); else outside (end)
1183-
return context.dataset.data[context.dataIndex] > 9 ? 'center' : 'end';
1175+
return context.dataset.data[context.dataIndex] > 20 ? 'center' : 'end';
11841176
},
11851177
align: function(context) {
1186-
return context.dataset.data[context.dataIndex] > 9 ? 'center' : 'top';
1178+
return context.dataset.data[context.dataIndex] > 20 ? 'center' : 'top';
11871179
}
11881180
},
11891181
tooltip: {
@@ -1570,7 +1562,7 @@ <h6>
15701562

15711563
},
15721564
datalabels: {
1573-
color: ['#003366', '#c61a09'], // 👈 Dark blue
1565+
color: ['#003366', '#8b0000'],
15741566
font: {
15751567
weight: 'bold',
15761568
size: 13
@@ -1580,10 +1572,10 @@ <h6>
15801572
},
15811573
anchor: function(context) {
15821574
// If value is tall enough, place inside (center); else outside (end)
1583-
return context.dataset.data[context.dataIndex] > 50 ? 'center' : 'end';
1575+
return context.dataset.data[context.dataIndex] > 40 ? 'center' : 'end';
15841576
},
15851577
align: function(context) {
1586-
return context.dataset.data[context.dataIndex] > 50 ? 'center' : 'top';
1578+
return context.dataset.data[context.dataIndex] > 40 ? 'center' : 'top';
15871579
}
15881580
},
15891581
},
@@ -1658,7 +1650,7 @@ <h6>
16581650

16591651
},
16601652
datalabels: {
1661-
color: ['#003366', '#c61a09'], // 👈 Dark blue
1653+
color: ['#003366', '#8b0000'],
16621654
font: {
16631655
weight: 'bold',
16641656
size: 13
@@ -1668,10 +1660,10 @@ <h6>
16681660
},
16691661
anchor: function(context) {
16701662
// If value is tall enough, place inside (center); else outside (end)
1671-
return context.dataset.data[context.dataIndex] > 50 ? 'center' : 'end';
1663+
return context.dataset.data[context.dataIndex] > 40 ? 'center' : 'end';
16721664
},
16731665
align: function(context) {
1674-
return context.dataset.data[context.dataIndex] > 50 ? 'center' : 'top';
1666+
return context.dataset.data[context.dataIndex] > 40 ? 'center' : 'top';
16751667
}
16761668
},
16771669
},
@@ -1746,7 +1738,7 @@ <h6>
17461738

17471739
},
17481740
datalabels: {
1749-
color: ['#003366', '#c61a09'], // 👈 Dark blue
1741+
color: ['#003366', '#8b0000'], // 👈 Dark blue
17501742
font: {
17511743
weight: 'bold',
17521744
size: 13
@@ -1756,10 +1748,10 @@ <h6>
17561748
},
17571749
anchor: function(context) {
17581750
// If value is tall enough, place inside (center); else outside (end)
1759-
return context.dataset.data[context.dataIndex] > 50 ? 'center' : 'end';
1751+
return context.dataset.data[context.dataIndex] > 40 ? 'center' : 'end';
17601752
},
17611753
align: function(context) {
1762-
return context.dataset.data[context.dataIndex] > 50 ? 'center' : 'top';
1754+
return context.dataset.data[context.dataIndex] > 40 ? 'center' : 'top';
17631755
}
17641756
},
17651757
},

0 commit comments

Comments
 (0)