Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for naming system update, council and policy events #110

Merged
merged 16 commits into from
Nov 30, 2023
1 change: 0 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ jobs:
cd dist
powershell Compress-Archive stellarisdashboard-build/* ../stellarisdashboard-${{ matrix.os }}.zip
cd ..
ls
- name: package files
if: matrix.os != 'windows-latest'
run: |
Expand Down
37 changes: 16 additions & 21 deletions stellarisdashboard/dashboard_app/history_ledger.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,21 +105,21 @@ def query_args_info(self):
datamodel.Leader,
"leader",
dict(leader_id=self.leader_filter),
datamodel.Leader.leader_id.asc(),
datamodel.Leader.leader_id_in_game.asc(),
)
elif self.system_filter is not None:
return (
datamodel.System,
"system",
dict(system_id=self.system_filter),
datamodel.System.system_id.asc(),
datamodel.System.system_id_in_game.asc(),
)
elif self.planet_filter is not None:
return (
datamodel.Planet,
"planet",
dict(planet_id=self.planet_filter),
datamodel.Planet.planet_id.asc(),
datamodel.Planet.planet_id_in_game.asc(),
)
elif self.war_filter is not None:
return (
Expand All @@ -136,7 +136,7 @@ def query_args_info(self):
datamodel.Country,
"country",
filter_dict,
datamodel.Country.country_id.asc(),
datamodel.Country.country_id_in_game.asc(),
)

@property
Expand Down Expand Up @@ -235,7 +235,7 @@ def get_event_and_link_dicts(self):
event_query_kwargs,
key_obj_filter_dict,
key_object_order_column,
) = params = self.event_filter.query_args_info
) = self.event_filter.query_args_info

self._most_recent_date = utils.get_most_recent_date(self._session)
key_objects = (
Expand Down Expand Up @@ -330,7 +330,10 @@ def collect_event_dicts(self, event_list, key_object):
def get_war_list(self):
if not self.event_filter.is_empty_filter:
return []
return [key for key in self._formatted_urls if isinstance(key, datamodel.War)]
return sorted(
[key for key in self._formatted_urls if isinstance(key, datamodel.War)],
key=lambda w: w.start_date_days,
)

def _get_details(self, key) -> Dict[str, str]:
if isinstance(key, datamodel.Country):
Expand Down Expand Up @@ -474,14 +477,16 @@ def leader_details(self, leader_model: datamodel.Leader) -> Dict[str, str]:
"Gender": game_info.convert_id_to_name(leader_model.gender),
"Species": leader_model.species.rendered_name,
"Class": f"{game_info.convert_id_to_name(leader_model.leader_class)} in the {country_url}",
"Subclass": f"{game_info.lookup_key(leader_model.subclass)}" or "None",
"Traits": ", ".join(leader_model.rendered_traits),
"Born": datamodel.days_to_date(leader_model.date_born),
"Hired": datamodel.days_to_date(leader_model.date_hired),
"Last active": datamodel.days_to_date(
utils.get_most_recent_date(self._session)
if leader_model.is_active
else leader_model.last_date
),
"Status": "Active" if leader_model.is_active else "Dead or Dismissed",
"Status": "Active" if leader_model.is_active else "Dead or retired",
}
return details

Expand All @@ -494,23 +499,13 @@ def country_details(self, country_model: datamodel.Country) -> Dict[str, str]:
details.update(
{
"Personality": game_info.convert_id_to_name(gov.personality),
"Government Type": game_info.convert_id_to_name(
gov.gov_type, remove_prefix="gov"
),
"Authority": game_info.convert_id_to_name(
gov.authority, remove_prefix="auth"
),
"Government Type": game_info.lookup_key(gov.gov_type),
"Authority": game_info.lookup_key(gov.authority),
"Ethics": ", ".join(
[
game_info.convert_id_to_name(e, remove_prefix="ethic")
for e in sorted(gov.ethics)
]
[game_info.lookup_key(e) for e in sorted(gov.ethics)]
),
"Civics": ", ".join(
[
game_info.convert_id_to_name(c, remove_prefix="civic")
for c in sorted(gov.civics)
]
[game_info.lookup_key(c) for c in sorted(gov.civics)]
),
}
)
Expand Down
83 changes: 69 additions & 14 deletions stellarisdashboard/dashboard_app/templates/history_page.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<a href="#wars">War logs</a>
<ul>
{% for war in wars %}
<li class="toc-item">{{ links[war] | safe }}</li>
<li class="toc-item"> {{ war.start_date }}{% if war.end_date %} - {{ war.end_date }}{% endif %}: {{ links[war] | safe }}</li>
{% endfor %}
</ul>
{% endif %}
Expand Down Expand Up @@ -47,6 +47,7 @@ <h2 class="eventlist_header">{{title[object] | safe}}</h2>
<div style="text-align: center;"><div><span>
<a class="button vis_toggle" href={{"#country_{}".format(object.country_id)}} onclick="toggle_visibility('researched_technology');">Technologies</a>
<a class="button vis_toggle" href={{"#country_{}".format(object.country_id)}} onclick="toggle_visibility('edict');">Edicts</a>
<a class="button vis_toggle" href={{"#country_{}".format(object.country_id)}} onclick="toggle_visibility('policy');">Policies</a>
<a class="button vis_toggle" href={{"#country_{}".format(object.country_id)}} onclick="toggle_visibility('tradition');">Traditions</a>
<a class="button vis_toggle" href={{"#country_{}".format(object.country_id)}} onclick="toggle_visibility('colonization');">Colonizations</a>
<a class="button vis_toggle" href={{"#country_{}".format(object.country_id)}} onclick="toggle_visibility('army_combat');">Army Combat</a>
Expand All @@ -66,8 +67,7 @@ <h2 class="eventlist_header">{{title[object] | safe}}</h2>
<span class="dateblock">{% if event["is_active"] %}(A){% endif %} {{event["start_date"]}}{% if event["end_date"] != null %} - {{event["end_date"]}}{%endif%}:</span>
<span class="eventtext">
{{ event["leader"].leader_class.capitalize() }} {{ links[event["leader"]] | safe }} ruled the {{ links[event["country"]] | safe}}
{% if "planet" in event %} from the capital {{ links[event["planet"]] | safe }} in the {{ links[event["system"]] | safe }} system {% endif %}
with agenda "{{ event["leader"].agenda }}".
{% if "planet" in event %} from the capital {{ links[event["planet"]] | safe }} in the {{ links[event["system"]] | safe }} system {% endif %}.
</span>
</div>
</li>
Expand All @@ -79,7 +79,7 @@ <h2 class="eventlist_header">{{title[object] | safe}}</h2>
{% if "leader" in event %} Under ruler {{ links[event["leader"]] | safe}}, the
{% else %} The
{% endif %}
{{ links[event["country"]] | safe }} relocated their capital to the {{ event["planet"].planetclass }} planet {{ links[event["planet"]] | safe }}
{{ links[event["country"]] | safe }} relocated their capital to the {{ event["planet"].planetclass }} {{ links[event["planet"]] | safe }}
in the {{ links[event["system"]] | safe }} system.
</span>
</div>
Expand All @@ -90,7 +90,7 @@ <h2 class="eventlist_header">{{title[object] | safe}}</h2>
<span class="dateblock">{% if event["is_active"] %}(A){% endif %} {{event["start_date"]}}{% if event["end_date"] != null %} - {{event["end_date"]}}{%endif%}:</span>
<span class="eventtext">
The {{ links[event["country"]] | safe }} colonized the {{ event["planet"].planetclass }}
planet {{ links[event["planet"]] | safe }} in the {{ links[event["system"]] | safe }} system
{{ links[event["planet"]] | safe }} in the {{ links[event["system"]] | safe }} system
{% if "leader" in event%} under Governor {{ links[event["leader"]] | safe}}{% endif %}.
</span>
</div>
Expand Down Expand Up @@ -161,12 +161,32 @@ <h2 class="eventlist_header">{{title[object] | safe}}</h2>
</span>
</div>
</li>
{% elif event["event_type"] == "research_leader" %}
<li class="eventitem research_leader">
{% elif event["event_type"] == "councilor" %}
<li class="eventitem councilor">
<div class="eventdescription">
<span class="dateblock">{% if event["is_active"] %}(A){% endif %} {{event["start_date"]}}{% if event["end_date"] != null %} - {{event["end_date"]}}{%endif%}:</span>
<span class="eventtext">
Scientist {{ links[event["leader"]] | safe }} led the {{ links[event["country"]] | safe}}'s {{event["description"]}} research efforts.
{{ links[event["leader"]] | safe }} served as {{event["description"]}} on the council of the {{ links[event["country"]] | safe}}.
</span>
</div>
</li>
{% elif event["event_type"] == "agenda_preparation" %}
<li class="eventitem agenda">
<div class="eventdescription">
<span class="dateblock">{% if event["is_active"] %}(A){% endif %} {{event["start_date"]}}{% if event["end_date"] != null %} - {{event["end_date"]}}{%endif%}:</span>
<span class="eventtext">
{% if "leader" in event %}Under ruler {{ links[event["leader"]] | safe}}, the {% else %}The {% endif %}
{{ links[event["country"]] | safe}} prepared a new agenda "{{event["description"]}}".
</span>
</div>
</li>
{% elif event["event_type"] == "agenda_launch" %}
<li class="eventitem agenda">
<div class="eventdescription">
<span class="dateblock">{{event["start_date"]}}:</span>
<span class="eventtext">
{% if "leader" in event %}Under ruler {{ links[event["leader"]] | safe}}, the {% else %}The {% endif %}
{{ links[event["country"]] | safe}} launched the agenda "{{event["description"]}}".
</span>
</div>
</li>
Expand All @@ -175,10 +195,7 @@ <h2 class="eventlist_header">{{title[object] | safe}}</h2>
<div class="eventdescription">
<span class="dateblock">{% if event["is_active"] %}(A){% endif %} {{event["start_date"]}}{% if event["end_date"] != null %} - {{event["end_date"]}}{%endif%}:</span>
<span class="eventtext">
{% if "leader" in event %} Scientist {{ links[event["leader"]] | safe}}
{% else %} The {{ links[event["country"]] | safe}}
{% endif %}
researched the "{{event["description"]}}" technology.
The {{ links[event["country"]] | safe}} researched the "{{event["description"]}}" technology.
</span>
</div>
</li>
Expand All @@ -202,6 +219,26 @@ <h2 class="eventlist_header">{{title[object] | safe}}</h2>
</span>
</div>
</li>
{% elif event["event_type"] == "new_policy" %}
<li class="eventitem policy">
<div class="eventdescription">
<span class="dateblock">{{event["start_date"]}}:</span>
<span class="eventtext">
{% if "leader" in event %}Under ruler {{ links[event["leader"]] | safe}}, the {% else %}The {% endif %}
{{ links[event["country"]] | safe}} enacted a new policy on {{event["description"]}}.
</span>
</div>
</li>
{% elif event["event_type"] == "changed_policy" %}
<li class="eventitem policy">
<div class="eventdescription">
<span class="dateblock">{{event["start_date"]}}:</span>
<span class="eventtext">
{% if "leader" in event %}Under ruler {{ links[event["leader"]] | safe}}, the {% else %}The {% endif %}
{{ links[event["country"]] | safe}} changed their policy on {{event["description"]}}.
</span>
</div>
</li>
{% elif event["event_type"] == "ascension_perk" %}
<li class="eventitem ascension_perk">
<div class="eventdescription">
Expand Down Expand Up @@ -250,6 +287,24 @@ <h2 class="eventlist_header">{{title[object] | safe}}</h2>
</span>
</div>
</li>
{% elif event["event_type"] == "gained_trait" %}
<li class="eventitem gained_trait">
<div class="eventdescription">
<span class="dateblock">{{event["start_date"]}}:</span>
<span class="eventtext">
{{ event["leader"].leader_class.capitalize() }} {{ links[event["leader"]] | safe }} gained the "{{ event["description"] }}" trait.
</span>
</div>
</li>
{% elif event["event_type"] == "lost_trait" %}
<li class="eventitem lost_trait">
<div class="eventdescription">
<span class="dateblock">{{event["start_date"]}}:</span>
<span class="eventtext">
{{ event["leader"].leader_class.capitalize() }} {{ links[event["leader"]] | safe }} lost the "{{ event["description"] }}" trait.
</span>
</div>
</li>
{% elif event["event_type"] == "first_contact" %}
<li class="eventitem first_contact">
<div class="eventdescription">
Expand Down Expand Up @@ -574,7 +629,7 @@ <h2 class="eventlist_header">{{title[object] | safe}}</h2>
<span class="dateblock">{{event["start_date"]}}:</span>
<span class="eventtext">
The planet {{ links[event["planet"]] | safe }} in the {{ links[event["system"]] | safe }} system, owned by the
{{ links[event["country"]] | safe }} was destroyed. It is now a {{ event["planet"].planet_class }} planet.
{{ links[event["country"]] | safe }} was destroyed. It is now a {{ event["planet"].planetclass }}.
</span>
</div>
</li>
Expand All @@ -583,7 +638,7 @@ <h2 class="eventlist_header">{{title[object] | safe}}</h2>
<div class="eventdescription">
<span class="dateblock">{{event["start_date"]}}:</span>
<span class="eventtext">
{{ event["leader"].leader_class.capitalize() }} {{ links[event["leader"]] | safe }} died or was fired.
{{ event["leader"].leader_class.capitalize() }} {{ links[event["leader"]] | safe }} died or retired.
</span>
</div>
</li>
Expand Down
2 changes: 1 addition & 1 deletion stellarisdashboard/dashboard_app/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

logger = logging.getLogger(__name__)

VERSION = "v4.4"
VERSION = "v5.2"


def parse_version(version: str):
Expand Down
Loading
Loading