Skip to content

Commit

Permalink
Merge pull request #9 from ppfeufer/development
Browse files Browse the repository at this point in the history
v0.3.4
  • Loading branch information
ppfeufer authored Aug 28, 2020
2 parents 5b8455a + cca4716 commit dd5b39d
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 52 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
/allianceauth_afat.egg-info/
/afat/__pycache__/
.idea/
.github/
2 changes: 1 addition & 1 deletion afat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
default_app_config = "afat.apps.AfatConfig"

__title__ = "Fleet Activity Tracking"
__version__ = "0.0.2"
__version__ = "0.3.4"
12 changes: 6 additions & 6 deletions afat/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def dead(self):
return self.exclude(deleted_at=None)


# Fat Link type (StratOp, ADM, HD etc)
# AFatLinkType Model (StratOp, ADM, HD etc)
class AFatLinkType(SoftDeletionModel):
id = models.AutoField(primary_key=True)
name = models.CharField(max_length=254)
Expand All @@ -75,7 +75,7 @@ def __str__(self):
return "{} - {}".format(self.id, self.name)


# FatLink Model
# AFatLink Model
class AFatLink(SoftDeletionModel):
afattime = models.DateTimeField(default=timezone.now)
fleet = models.CharField(max_length=254, null=True)
Expand All @@ -100,13 +100,13 @@ class Meta:
ordering = ("-afattime",)


# Clickable Link Duration Model
# ClickAFatDuration Model
class ClickAFatDuration(models.Model):
duration = models.PositiveIntegerField()
fleet = models.ForeignKey(AFatLink, on_delete=models.CASCADE)


# PAP/FAT Model
# AFat Model
class AFat(SoftDeletionModel):
character = models.ForeignKey(EveCharacter, on_delete=models.CASCADE)
afatlink = models.ForeignKey(AFatLink, on_delete=models.CASCADE)
Expand All @@ -121,7 +121,7 @@ def __str__(self):
return "{} - {}".format(self.afatlink, self.character)


# Log Model for Manual FAT creation
# ManualAFat Model
class ManualAFat(models.Model):
creator = models.ForeignKey(User, on_delete=models.SET(get_sentinel_user))
afatlink = models.ForeignKey(AFatLink, on_delete=models.CASCADE)
Expand All @@ -133,7 +133,7 @@ def __str__(self):
return "{} - {} ({})".format(self.afatlink, self.character, self.creator)


# Log Model for Deletion of Fats and FatLinks
# AFatDelLog Model
class AFatDelLog(models.Model):
# 0 for FatLink, 1 for Fat
deltype = models.BooleanField(default=0)
Expand Down
11 changes: 7 additions & 4 deletions afat/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ def get_or_create_char(name: str = None, id: int = None):
result = esi.client.Search.get_search(
categories=["character"], search=name, strict=True
).result()

if "character" not in result:
return None

id = result["character"][0]
qs = EveCharacter.objects.filter(character_id=id)
elif id:
Expand All @@ -53,12 +55,14 @@ def get_or_create_char(name: str = None, id: int = None):
# Make corp and alliance info objects for future sane
if character.alliance_id is not None:
test = EveAllianceInfo.objects.filter(alliance_id=character.alliance_id)

if len(test) == 0:
EveAllianceInfo.objects.create_alliance(character.alliance_id)
else:
test = EveCorporationInfo.objects.filter(
corporation_id=character.corporation_id
)

if len(test) == 0:
EveCorporationInfo.objects.create_corporation(character.corporation_id)

Expand Down Expand Up @@ -106,7 +110,7 @@ def process_line(line, type_, hash):
shiptype = line[2]

if character is not None:
afat = AFat(
AFat(
afatlink_id=link.pk,
character=character,
system=system,
Expand All @@ -116,7 +120,7 @@ def process_line(line, type_, hash):
character = get_or_create_char(name=line.strip(" "))

if character is not None:
afat = AFat(afatlink_id=link.pk, character=character).save()
AFat(afatlink_id=link.pk, character=character).save()


@shared_task
Expand All @@ -135,8 +139,7 @@ def process_character(char, hash):
sol_name = solar_system["name"]
ship_name = ship["name"]
character = get_or_create_char(id=char_id)
link = AFatLink.objects.get(hash=hash)
fat = AFat(
AFat(
afatlink_id=link.pk, character=character, system=sol_name, shiptype=ship_name
).save()

Expand Down
Loading

0 comments on commit dd5b39d

Please sign in to comment.