mirror of
https://gitlab.com/allianceauth/allianceauth.git
synced 2025-07-09 20:40:17 +02:00
Merge branch 'ceo_id' into 'master'
Add CEO ID to Corp Eve Model See merge request allianceauth/allianceauth!1287
This commit is contained in:
commit
aeeb35bc60
@ -0,0 +1,18 @@
|
||||
# Generated by Django 3.1.1 on 2021-01-05 14:11
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('eveonline', '0012_index_additions'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='evecorporationinfo',
|
||||
name='ceo_id',
|
||||
field=models.PositiveIntegerField(blank=True, default=None, null=True),
|
||||
),
|
||||
]
|
17
allianceauth/eveonline/migrations/0014_auto_20210105_1413.py
Normal file
17
allianceauth/eveonline/migrations/0014_auto_20210105_1413.py
Normal file
@ -0,0 +1,17 @@
|
||||
# Generated by Django 3.1.1 on 2021-01-05 14:13
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('eveonline', '0013_evecorporationinfo_ceo_id'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddIndex(
|
||||
model_name='evecorporationinfo',
|
||||
index=models.Index(fields=['ceo_id'], name='eveonline_e_ceo_id_eea7b8_idx'),
|
||||
),
|
||||
]
|
@ -82,6 +82,7 @@ class EveCorporationInfo(models.Model):
|
||||
corporation_name = models.CharField(max_length=254, unique=True)
|
||||
corporation_ticker = models.CharField(max_length=254)
|
||||
member_count = models.IntegerField()
|
||||
ceo_id = models.PositiveIntegerField(blank=True, null=True, default=None)
|
||||
alliance = models.ForeignKey(
|
||||
EveAllianceInfo, blank=True, null=True, on_delete=models.SET_NULL
|
||||
)
|
||||
@ -89,10 +90,16 @@ class EveCorporationInfo(models.Model):
|
||||
objects = EveCorporationManager()
|
||||
provider = EveCorporationProviderManager()
|
||||
|
||||
class Meta:
|
||||
indexes = [
|
||||
models.Index(fields=['ceo_id',]),
|
||||
]
|
||||
|
||||
def update_corporation(self, corp: providers.Corporation = None):
|
||||
if corp is None:
|
||||
corp = self.provider.get_corporation(self.corporation_id)
|
||||
self.member_count = corp.members
|
||||
self.ceo_id = corp.ceo_id
|
||||
try:
|
||||
self.alliance = EveAllianceInfo.objects.get(alliance_id=corp.alliance_id)
|
||||
except EveAllianceInfo.DoesNotExist:
|
||||
|
Loading…
x
Reference in New Issue
Block a user