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
6 changes: 3 additions & 3 deletions structures/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
from allianceauth.services.hooks import get_extension_logger
from app_utils.django import admin_boolean_icon_html

from . import app_settings, tasks
from .core.notification_types import NotificationType
from .models import (
from structures import app_settings, tasks
from structures.core.notification_types import NotificationType
from structures.models import (
FuelAlert,
FuelAlertConfig,
GeneratedNotification,
Expand Down
35 changes: 26 additions & 9 deletions structures/app_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@
from app_utils.app_settings import clean_setting

STRUCTURES_ADD_TIMERS = clean_setting("STRUCTURES_ADD_TIMERS", True)
"""Whether to automatically add timers for certain notifications on the timerboard
(will have no effect if aa-timerboard app is not installed).

Will create timers from anchoring, lost shield and lost armor notifications.
"""Whether to automatically add timers for supported notification types
to Alliance Auth's Structure Timers or Erik's Structure Timers
(apps have to be installed for this setting to work).

Supported notification types are:

- moon mining extraction canceled
- moon mining extraction started
- orbital reinforced
- skyhook lost shield
- sov structure reinforced
- structure lost armor
- structure lost shield
- tower reinforced

Moon mining notifications can be disabled with `STRUCTURES_MOON_EXTRACTION_TIMERS_ENABLED`.
"""

STRUCTURES_ADMIN_NOTIFICATIONS_ENABLED = clean_setting(
Expand Down Expand Up @@ -77,7 +89,10 @@
STRUCTURES_MOON_EXTRACTION_TIMERS_ENABLED = clean_setting(
"STRUCTURES_MOON_EXTRACTION_TIMERS_ENABLED", True
)
"""Whether to create / remove timers from moon extraction notifications."""
"""Whether to include moon mining extraction notifications when adding timers.

Requires the "add timers" feature to be enabled with `STRUCTURES_ADD_TIMERS`
"""

STRUCTURES_NOTIFICATION_MAX_RETRIES = clean_setting(
"STRUCTURES_NOTIFICATION_MAX_RETRIES", 3
Expand All @@ -89,14 +104,14 @@
STRUCTURES_NOTIFICATION_SET_AVATAR = clean_setting(
"STRUCTURES_NOTIFICATION_SET_AVATAR", True
)
"""Wether structures sets the name and avatar icon of a webhook.
"""Whether structures sets the name and avatar icon of a webhook.
When ``False`` the webhook will use it's own values as set on the platform.
"""

STRUCTURES_NOTIFICATION_SHOW_MOON_ORE = clean_setting(
"STRUCTURES_NOTIFICATION_SHOW_MOON_ORE", True
)
"""Wether ore details are shown on moon timers."""
"""Whether ore details are shown on moon timers."""


STRUCTURES_NOTIFICATION_SYNC_GRACE_MINUTES = clean_setting(
Expand Down Expand Up @@ -131,7 +146,9 @@
STRUCTURES_SHOW_FUEL_EXPIRES_RELATIVE = clean_setting(
"STRUCTURES_SHOW_FUEL_EXPIRES_RELATIVE", True
)
"""Whether fuel expires in structures browser is shown as absolute value."""
"""Whether fuel expiration in the structures browser is shown as a relative value
(e.g., time remaining) instead of an absolute date.
"""

STRUCTURES_SHOW_JUMP_GATES = clean_setting("STRUCTURES_SHOW_JUMP_GATES", True)
"""Whether to show the jump gates tab."""
Expand Down Expand Up @@ -175,7 +192,7 @@
"STRUCTURES_NOTIFICATION_TURNAROUND_LONG", 50
)

# Turnaround duration with more than x seconds are regarded as outliers
# Turnaround durations of more than x seconds are regarded as outliers
# and will be ignored when calculating the averages
STRUCTURES_NOTIFICATION_TURNAROUND_MAX_VALID = clean_setting(
"STRUCTURES_NOTIFICATION_TURNAROUND_MAX_VALID", 3600
Expand Down
4 changes: 2 additions & 2 deletions structures/apps.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from django.apps import AppConfig

from . import __version__
from structures import __version__


class StructuresConfig(AppConfig):
Expand All @@ -9,4 +9,4 @@ class StructuresConfig(AppConfig):
verbose_name = f"Structures v{__version__}"

def ready(self) -> None:
from . import checks # noqa: F401 pylint: disable=unused-import
from structures import checks # noqa: F401 pylint: disable=unused-import
2 changes: 1 addition & 1 deletion structures/auth_hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from allianceauth import hooks
from allianceauth.services.hooks import MenuItemHook, UrlHook

from . import __title__, urls
from structures import __title__, urls


class StructuresMenuItem(MenuItemHook):
Expand Down
2 changes: 1 addition & 1 deletion structures/core/notification_embeds/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Generating notification embeds for Structures."""

from .main import NotificationBaseEmbed
from structures.core.notification_embeds.main import NotificationBaseEmbed

__all__ = ["NotificationBaseEmbed"]
9 changes: 4 additions & 5 deletions structures/core/notification_embeds/billing_embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,14 @@
from app_utils.helpers import humanize_number

from structures.constants import EveTypeId
from structures.helpers import get_or_create_eve_entity, get_or_create_eve_type
from structures.models import Notification, Webhook

from .helpers import (
from structures.core.notification_embeds.helpers import (
gen_eve_entity_link,
gen_solar_system_text,
target_datetime_formatted,
)
from .main import NotificationBaseEmbed
from structures.core.notification_embeds.main import NotificationBaseEmbed
from structures.helpers import get_or_create_eve_entity, get_or_create_eve_type
from structures.models import Notification, Webhook


class BillType(models.IntegerChoices):
Expand Down
9 changes: 4 additions & 5 deletions structures/core/notification_embeds/corporate_embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@

from django.utils.translation import gettext as _

from structures.helpers import get_or_create_eve_entity
from structures.models import Notification, Webhook

from .helpers import (
from structures.core.notification_embeds.helpers import (
gen_corporation_link,
gen_eve_entity_link,
gen_eve_entity_link_from_id,
)
from .main import NotificationBaseEmbed
from structures.core.notification_embeds.main import NotificationBaseEmbed
from structures.helpers import get_or_create_eve_entity
from structures.models import Notification, Webhook


class NotificationCorpCharEmbed(NotificationBaseEmbed):
Expand Down
25 changes: 14 additions & 11 deletions structures/core/notification_embeds/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,15 @@
from app_utils.urls import reverse_absolute, static_file_absolute_url

from structures import __title__
from structures.core.notification_embeds.helpers import (
gen_alliance_link,
gen_corporation_link,
target_datetime_formatted,
)
from structures.core.notification_types import NotificationType
from structures.helpers import get_or_create_eve_entity, is_absolute_url
from structures.models.notifications import Notification, NotificationBase, Webhook

from .helpers import gen_alliance_link, gen_corporation_link, target_datetime_formatted

logger = get_extension_logger(__name__)


Expand Down Expand Up @@ -183,13 +186,13 @@ def generate_embed(self) -> dhooks_lite.Embed:
def create(notif: "NotificationBase") -> "NotificationBaseEmbed":
"""Creates a new instance of the respective subclass for given Notification."""

from .billing_embeds import (
from structures.core.notification_embeds.billing_embeds import (
NotificationBillingBillOutOfMoneyMsg,
NotificationBillingIHubBillAboutToExpire,
NotificationBillingIHubDestroyedByBillFailure,
NotificationCorpAllBillMsg,
)
from .corporate_embeds import (
from structures.core.notification_embeds.corporate_embeds import (
NotificationCharAppAcceptMsg,
NotificationCharAppRejectMsg,
NotificationCharAppWithdrawMsg,
Expand All @@ -201,25 +204,25 @@ def create(notif: "NotificationBase") -> "NotificationBaseEmbed":
NotificationCorpGoalCompleted,
NotificationCorpGoalCreated,
)
from .moonmining_embeds import (
from structures.core.notification_embeds.moonmining_embeds import (
NotificationMoonminningAutomaticFracture,
NotificationMoonminningExtractionCanceled,
NotificationMoonminningExtractionFinished,
NotificationMoonminningExtractionStarted,
NotificationMoonminningLaserFired,
)
from .orbital_embeds import (
from structures.core.notification_embeds.orbital_embeds import (
NotificationOrbitalAttacked,
NotificationOrbitalReinforced,
)
from .skyhook_embeds import (
from structures.core.notification_embeds.skyhook_embeds import (
NotificationSkyhookDeployed,
NotificationSkyhookDestroyed,
NotificationSkyhookLostShield,
NotificationSkyhookOnline,
NotificationSkyhookUnderAttack,
)
from .sov_embeds import (
from structures.core.notification_embeds.sov_embeds import (
NotificationSovAllAnchoringMsg,
NotificationSovAllClaimAcquiredMsg,
NotificationSovAllClaimLostMsg,
Expand All @@ -228,7 +231,7 @@ def create(notif: "NotificationBase") -> "NotificationBaseEmbed":
NotificationSovStructureDestroyed,
NotificationSovStructureReinforced,
)
from .structures_embeds import (
from structures.core.notification_embeds.structures_embeds import (
NotificationStructureAnchoring,
NotificationStructureDestroyed,
NotificationStructureFuelAlert,
Expand All @@ -247,13 +250,13 @@ def create(notif: "NotificationBase") -> "NotificationBaseEmbed":
NotificationStructureWentHighPower,
NotificationStructureWentLowPower,
)
from .tower_embeds import (
from structures.core.notification_embeds.tower_embeds import (
NotificationTowerAlertMsg,
NotificationTowerRefueledExtra,
NotificationTowerReinforcedExtra,
NotificationTowerResourceAlertMsg,
)
from .war_embeds import (
from structures.core.notification_embeds.war_embeds import (
NotificationAcceptedAlly,
NotificationAllWarCorpJoinedAllianceMsg,
NotificationAllWarSurrenderMsg,
Expand Down
9 changes: 4 additions & 5 deletions structures/core/notification_embeds/moonmining_embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,14 @@
from app_utils.datetime import ldap_time_2_datetime

from structures.app_settings import STRUCTURES_NOTIFICATION_SHOW_MOON_ORE
from structures.helpers import get_or_create_eve_entity, get_or_create_eve_type
from structures.models import Notification, Webhook

from .helpers import (
from structures.core.notification_embeds.helpers import (
gen_corporation_link,
gen_solar_system_text,
target_datetime_formatted,
)
from .main import NotificationBaseEmbed
from structures.core.notification_embeds.main import NotificationBaseEmbed
from structures.helpers import get_or_create_eve_entity, get_or_create_eve_type
from structures.models import Notification, Webhook


class NotificationMoonminingEmbed(NotificationBaseEmbed):
Expand Down
9 changes: 4 additions & 5 deletions structures/core/notification_embeds/orbital_embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
from app_utils.datetime import ldap_time_2_datetime

from structures.constants import EveTypeId
from structures.helpers import get_or_create_eve_type
from structures.models import Notification, Webhook

from .helpers import (
from structures.core.notification_embeds.helpers import (
gen_corporation_link,
gen_solar_system_text,
target_datetime_formatted,
)
from .main import NotificationBaseEmbed
from structures.core.notification_embeds.main import NotificationBaseEmbed
from structures.helpers import get_or_create_eve_type
from structures.models import Notification, Webhook


class NotificationOrbitalEmbed(NotificationBaseEmbed):
Expand Down
7 changes: 3 additions & 4 deletions structures/core/notification_embeds/skyhook_embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@

from app_utils.datetime import ldap_time_2_datetime

from structures.models import Notification, Webhook

from .helpers import (
from structures.core.notification_embeds.helpers import (
gen_corporation_link,
gen_solar_system_text,
target_datetime_formatted,
)
from .main import NotificationBaseEmbed
from structures.core.notification_embeds.main import NotificationBaseEmbed
from structures.models import Notification, Webhook


class NotificationSkyhookEmbed(NotificationBaseEmbed):
Expand Down
17 changes: 8 additions & 9 deletions structures/core/notification_embeds/sov_embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,20 @@

from structures.constants import EveTypeId
from structures.core import sovereignty
from structures.helpers import (
get_or_create_esi_obj,
get_or_create_eve_entity,
get_or_create_eve_type,
)
from structures.models import Notification, Webhook

from .helpers import (
from structures.core.notification_embeds.helpers import (
gen_alliance_link,
gen_corporation_link,
gen_eve_entity_link,
gen_solar_system_text,
target_datetime_formatted,
)
from .main import NotificationBaseEmbed
from structures.core.notification_embeds.main import NotificationBaseEmbed
from structures.helpers import (
get_or_create_esi_obj,
get_or_create_eve_entity,
get_or_create_eve_type,
)
from structures.models import Notification, Webhook


class NotificationSovEmbed(NotificationBaseEmbed):
Expand Down
9 changes: 4 additions & 5 deletions structures/core/notification_embeds/structures_embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,15 @@

from app_utils.datetime import ldap_time_2_datetime, ldap_timedelta_2_timedelta

from structures.helpers import get_or_create_eve_entity, get_or_create_eve_type
from structures.models import Notification, Structure, Webhook

from .helpers import (
from structures.core.notification_embeds.helpers import (
gen_corporation_link,
gen_solar_system_text,
target_datetime_formatted,
timeuntil,
)
from .main import NotificationBaseEmbed
from structures.core.notification_embeds.main import NotificationBaseEmbed
from structures.helpers import get_or_create_eve_entity, get_or_create_eve_type
from structures.models import Notification, Structure, Webhook


class NotificationStructureEmbed(NotificationBaseEmbed):
Expand Down
7 changes: 3 additions & 4 deletions structures/core/notification_embeds/tower_embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
from django.utils.translation import gettext as _

from structures.core import starbases
from structures.models import GeneratedNotification, Notification, Structure, Webhook

from .helpers import (
from structures.core.notification_embeds.helpers import (
gen_corporation_link,
gen_solar_system_text,
target_datetime_formatted,
timeuntil,
)
from .main import NotificationBaseEmbed
from structures.core.notification_embeds.main import NotificationBaseEmbed
from structures.models import GeneratedNotification, Notification, Structure, Webhook


class NotificationTowerEmbed(NotificationBaseEmbed):
Expand Down
8 changes: 5 additions & 3 deletions structures/core/notification_embeds/war_embeds.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,14 @@
from app_utils.datetime import ldap_time_2_datetime
from app_utils.helpers import humanize_number

from structures.core.notification_embeds.helpers import (
gen_eve_entity_link,
target_datetime_formatted,
)
from structures.core.notification_embeds.main import NotificationBaseEmbed
from structures.helpers import get_or_create_eve_entity
from structures.models import Notification, Webhook

from .helpers import gen_eve_entity_link, target_datetime_formatted
from .main import NotificationBaseEmbed


class NotificationAcceptedAlly(NotificationBaseEmbed):
def __init__(self, notification: Notification) -> None:
Expand Down
Loading
Loading