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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
from django.core.management.base import BaseCommand
from django.db import connection
from django.apps import apps

from seshat.apps.core.models import Polity, ScpThroughCtn, Reference, Citation, Seshat_Expert, SeshatCommentPart, SeshatComment, SeshatPrivateComment


from seshat.apps.general.models import Polity_expert, Polity_original_name, Polity_alternative_name

from seshat.apps.crisisdb.models import Instability_event, Instability_type, Instability_ref

from seshat.apps.crisisdb.instability_events_dic_list import ultimate_dics_list

from django.db import transaction

EVENTS_DATA = [
{
'event': 'Revolt of Datames',
'year_from': -382,
'year_to': -362,
'llm_description': 'Datames, satrap of Cappadocia, rebelled against Artaxerxes II, seeking autonomy. He was assassinated in 362 BCE after a decade of resistance.',
'all_types': ['Assassination', 'Separatist Rebellion'],
'all_refs': ['Cornelius Nepos, <b>Lives of Eminent Commanders</b> 14 (Datames)',
'Diodorus Siculus, <b>Library of History</b> 15.91.'],
'is_real': True,
'polity': 'ir_achaemenid_emp',
'extent': 6,
'intensity': 6,
'class_cot': 'Okay, let\'s tackle this for Intensity.',
'sorokin': 'Extent 6 as the revolt was led by a satrap (provincial governor) in Cappadocia, indicating provincial-level involvement. Intensity 4 due to likely military engagements over a decade, though exact casualty figures are unspecified but consistent with regional rebellion scale.',
'general_cot': 'Okay, references are academic sources.'
}
]

class Command(BaseCommand):
help = "Populate the Instability_event model with sample data"

@transaction.atomic # Ensures atomic DB transactions
def handle(self, *args, **kwargs):
self.stdout.write(self.style.SUCCESS("Starting data import..."))

#for event_data in EVENTS_DATA:
for event_data in ultimate_dics_list:
# Create or get Instability_type records
instability_types = []
for type_name in event_data['all_types']:
if type_name in ['Execution (contextually framed as a consequence of rebellion)','Execution (linked to military failure/revolt)',]:
type_name= 'Execution'
inst_type, created = Instability_type.objects.get_or_create(name=type_name)
instability_types.append(inst_type)

# Create or get Instability_ref records
instability_refs = []
for ref_name in event_data['all_refs']:
inst_ref, created = Instability_ref.objects.get_or_create(name=ref_name, is_real=False)
instability_refs.append(inst_ref)

# Polity
try:
my_pol = Polity.objects.get(new_name=event_data['polity'])
my_pc = SeshatPrivateComment.objects.create()
except:
#print('Bad Pol')
continue
#print(my_pol)
# Create Instability_event
event = Instability_event.objects.create(
name=event_data['event'],
year_from=event_data['year_from'],
year_to=event_data['year_to'],
llm_description=event_data['llm_description'],
inst_extent=event_data['extent'],
inst_intensity=event_data['intensity'],
classification_cot=event_data['class_cot'],
sorokin_rationale=event_data['sorokin'],
general_cot=event_data['general_cot'],
real_event_check=event_data['is_real'],
polity_id=my_pol.id,
private_comment_id=my_pc.id,
)

# Add ManyToMany relations
event.inst_type.set(instability_types)
event.inst_llm_ref.set(instability_refs)

self.stdout.write(self.style.SUCCESS(f"Added event: {event.name}"))

self.stdout.write(self.style.SUCCESS("Data import completed successfully!"))
2 changes: 2 additions & 0 deletions seshat/apps/core/templates/core/description_snippet.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
{% elif obj.llm_description %}
<div class="row">
<div class="col-md-6">
<b>LLM Description: </b>
<br>
{{ obj.llm_description }}
<br>
<b>LLM References: </b>
Expand Down
49 changes: 31 additions & 18 deletions seshat/apps/core/templates/core/form_base_llm.html
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@

.bg-secondary-light {
background: #fffdf2;
color: lightcoral;
border: 1px solid lightcoral;
color: crimson;
border: 1px solid crimson;


}
Expand Down Expand Up @@ -435,28 +435,37 @@
{% if form.instance.year_from == None %}
{% elif form.instance.year_from == form.instance.year_to %}
{% if form.instance.year_from < 0 %}
<td colspan="1" style="text-align: right; border-width: 0;">{{ form.instance.year_from|abs|intcomma }} <small class="text-secondary">BCE</small> </td>
<span style="text-align: right; border-width: 0;">{{ form.instance.year_from|abs|intcomma }} <small class="text-secondary">BCE</small> </span>
{% else %}
<td colspan="1" style="text-align: right; border-width: 0;">{{ form.instance.year_from }} <small class="text-secondary">CE</small></td>
<span style="text-align: right; border-width: 0;">{{ form.instance.year_from }} <small class="text-secondary">CE</small></span>
{% endif %}
{% elif form.instance.year_to == None %}
{% if form.instance.year_from < 0 %}
<td colspan="1" style="text-align: right; border-width: 0;">{{ form.instance.year_from|abs }} <small class="text-secondary">BCE</small></td>
<span style="text-align: right; border-width: 0;">{{ form.instance.year_from|abs }} <small class="text-secondary">BCE</small></span>
{% else %}
<td colspan="1" style="text-align: right; border-width: 0;">{{ form.instance.year_from }} <small class="text-secondary">CE</small></td>
<span style="text-align: right; border-width: 0;">{{ form.instance.year_from }} <small class="text-secondary">CE</small></span>
{% endif %}
{% elif form.instance.year_to == None and form.instance.year_from == None %}
<td colspan="1" style="text-align: right; border-width: 0;"> <i class="fa-solid fa-minus"></i> </td>
<span style="text-align: right; border-width: 0;"> <i class="fa-solid fa-minus"></i> </span>
{% else %}
{% if form.instance.year_from < 0 and form.instance.year_to < 0 %}
<td colspan="1" style="text-align: right; border-width: 0;">{{ form.instance.year_from|abs }} <small class="text-secondary">BCE</small> <i class="fa-solid fa-arrow-right-long"></i> {{ form.instance.year_to|abs }}&nbsp;<small class="text-secondary">BCE</small></td>
<span style="text-align: right; border-width: 0;">{{ form.instance.year_from|abs }} <small class="text-secondary">BCE</small> <i class="fa-solid fa-arrow-right-long"></i> {{ form.instance.year_to|abs }}&nbsp;<small class="text-secondary">BCE</small></span>
{% elif form.instance.year_from < 0 and form.instance.year_to >= 0 %}
<td colspan="1" style="text-align: right; border-width: 0;">{{ form.instance.year_from|abs }} <small class="text-secondary">BCE</small> <i class="fa-solid fa-arrow-right-long"></i> {{ form.instance.year_to }}&nbsp;<small class="text-secondary">CE</small></td>
<span style="text-align: right; border-width: 0;">{{ form.instance.year_from|abs }} <small class="text-secondary">BCE</small> <i class="fa-solid fa-arrow-right-long"></i> {{ form.instance.year_to }}&nbsp;<small class="text-secondary">CE</small></span>
{% else %}
<td colspan="1" style="text-align: right; border-width: 0;">{{ form.instance.year_from }} <small class="text-secondary">CE</small> <i class="fa-solid fa-arrow-right-long"></i> {{ form.instance.year_to }}&nbsp;<small class="text-secondary">CE</small></td>
<span style="text-align: right; border-width: 0;">{{ form.instance.year_from }} <small class="text-secondary">CE</small> <i class="fa-solid fa-arrow-right-long"></i> {{ form.instance.year_to }}&nbsp;<small class="text-secondary">CE</small></span>
{% endif %}
{% endif %}


<!-- Types -->
<br>
<b>Types: </b>

{% autoescape off %}

{{ form.instance.get_instability_types }}
{% endautoescape %}

</div>
<div class="col-sm-5">
<b> Polity:</b>
Expand All @@ -465,7 +474,7 @@



<div class="col-sm-4 pb-3" style="display:none;">
<div class="col-sm-4" style="display:none;">
{{ extra_var|as_crispy_field }}
</div>

Expand All @@ -492,28 +501,32 @@
</div>


<div class="col-sm-6 pb-1">
<div class="col-sm-6 py-2 ">
<b class="highlighted-value-title-pred"> LLM Description:</b>


{{ form.instance.llm_description}}
<br>
<b class="highlighted-value-title-pred">LLM REFS: </b> <br>
<b class="highlighted-value-title-pred mt-2">LLM REFS: </b> <br>
{% autoescape off %}

{{ form.instance.get_instability_refs}}
<span class="text-secondary">
{{ form.instance.get_instability_refs}}
</span>
{% endautoescape %}
</div>

<div class="col-sm-6 pb-3">
<div class="row">
<div class="col-sm-6">
<b>Intensity:</b>
<b class="highlighted-value-title"> {{ form.instance.inst_intensity}}</b> <br> {{ form.instance.get_inst_intensity_display }}
<b class="highlighted-value-title"> {{ form.instance.inst_intensity}}</b> <br>
<span class="text-secondary">{{ form.instance.get_inst_intensity_display }} </span>

</div>
<div class="col-sm-6">
<b>Extent:</b>
<b class="highlighted-value-title"> {{ form.instance.inst_extent}}</b> <br> {{ form.instance.get_inst_extent_display }}
<b class="highlighted-value-title"> {{ form.instance.inst_extent}}</b> <br>
<span class="text-secondary">{{ form.instance.get_inst_extent_display }} </span>
</div>
<div class="col-sm-12 pt-2">
<b>Sorokin Rationale:</b>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,13 @@
<!-- Update Button -->
{% block update_button %}
{% if obj.description and obj.description != 'None' %}
<td colspan="1" style="text-align: center;">
<td colspan="1" style="text-align: center; border-width:0;">
<small>
<a href="{% url update_url obj.id %}"><i class="fa-solid fa-pen-to-square text-secondary"></i></a>
</small>
</td>
{% else %}
<td colspan="1" style="text-align: center;">
<td colspan="1" style="text-align: center; border-width:0;">
<small>
<a href="{% url update_url_new obj.id %}"><i class="fa-solid fa-pen-to-square text-danger"></i></a>
</small>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
{% extends "core/list_base_for_new_approach.html" %}
{% load crispy_forms_tags %}
{% load static %}
{% load humanize %}
{% load custom_filters %}
{% load mathfilters %}




{% block myheadings_list %}
<th class = "fw-bold" style="text-align: left; white-space: nowrap; border-left: 1px solid gray; border-right: 1px solid gray; " scope="col">
<span>
Event Name
</span>

</th>
<th style="text-align: left; white-space: nowrap; border-left: 1px solid gray; border-right: 1px solid gray; " scope="col">
<span>
Types
</span>
</th>
<th style="text-align: center; white-space: nowrap; border-left: 1px solid gray; border-right: 1px solid gray; " scope="col">
<span>
Intensity
</span>
</th>
<th style="text-align: center; white-space: nowrap; border-left: 1px solid gray; border-right: 1px solid gray; " scope="col">
<span>
Extent
</span>
</th>

<th style="text-align: left; white-space: nowrap; border-left: 1px solid gray; border-right: 1px solid gray; " scope="col">
<span>
Ra Checks
</span>
</th>
{% endblock myheadings_list %}

{% block extra_vars_list %}
<td style="text-align: left; z-index:890; border-width:0;" >
{% autoescape off %}
<span class="fw-bold highlighted-value-title">{{obj.name}}</span>
{% endautoescape %}



{% if obj.year_from == None %}

{% elif obj.year_from == obj.year_to %}
{% if obj.year_from < 0 %}
<small style="text-align: right; border-width: 0;">{{ obj.year_from|abs|intcomma }} <small class="text-secondary">BCE</small> </small>
{% else %}
<small style="text-align: right; border-width: 0;">{{ obj.year_from }} <small class="text-secondary">CE</small></small>
{% endif %}
{% elif obj.year_to == None %}
{% if obj.year_from < 0 %}
<small style="text-align: right; border-width: 0;">{{ obj.year_from|abs }} <small class="text-secondary">BCE</small></small>
{% else %}
<small style="text-align: right; border-width: 0;">{{ obj.year_from }} <small class="text-secondary">CE</small></small>
{% endif %}
{% elif obj.year_to == None and obj.year_from == None %}
<small style="text-align: right; border-width: 0;"> <i class="fa-solid fa-minus"></i> </small>
{% else %}
{% if obj.year_from < 0 and obj.year_to < 0 %}
<small style="text-align: right; border-width: 0;">{{ obj.year_from|abs }} <small class="text-secondary">BCE</small> <i class="fa-solid fa-arrow-right-long"></i> {{ obj.year_to|abs }}&nbsp;<small class="text-secondary">BCE</small></small>
{% elif obj.year_from < 0 and obj.year_to >= 0 %}
<small style="text-align: right; border-width: 0;">{{ obj.year_from|abs }} <small class="text-secondary">BCE</small> <i class="fa-solid fa-arrow-right-long"></i> {{ obj.year_to }}&nbsp;<small class="text-secondary">CE</small></small>
{% else %}
<small style="text-align: right; border-width: 0;">{{ obj.year_from }} <small class="text-secondary">CE</small> <i class="fa-solid fa-arrow-right-long"></i> {{ obj.year_to }}&nbsp;<small class="text-secondary">CE</small></small>
{% endif %}
{% endif %}





</td>

<td style="text-align: left; z-index:890; border-width:0;" >
{% autoescape off %}
<span >{{obj.get_instability_types}}</span>
{% endautoescape %}

</td>
<td class="fw-bold" style="text-align: center; z-index:890; border-width:0;" >
{% autoescape off %}
<span >{{obj.inst_intensity}}</span>
{% endautoescape %}

</td>
<td class="fw-bold" style="text-align: center; z-index:890; border-width:0;" >
{% autoescape off %}
<span >{{obj.inst_extent}}</span>
{% endautoescape %}

</td>
<td style="text-align: left; z-index:890; border-width:0;" >
{% autoescape off %}
<span >{{obj.get_instability_checks}}</span>
{% endautoescape %}

</td>
{% endblock extra_vars_list %}


<!-- Update Button -->
{% block update_button %}
{% if obj.description and obj.description != 'None' %}
<td colspan="1" style="text-align: center; border-width:0;">
<small>
<a href="{% url update_url obj.id %}"><i class="fa-solid fa-pen-to-square text-secondary"></i></a>
</small>
</td>
{% else %}
<td colspan="1" style="text-align: center; border-width:0;">
<small>
<a href="{% url update_url_new obj.id %}"><i class="fa-solid fa-pen-to-square text-danger"></i></a>
</small>
</td>
{% endif %}

{% endblock update_button %}
Loading
Loading