aa-corphandouts 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (34) hide show
  1. aa_corphandouts-0.1.0/LICENSE +21 -0
  2. aa_corphandouts-0.1.0/PKG-INFO +108 -0
  3. aa_corphandouts-0.1.0/README.md +78 -0
  4. aa_corphandouts-0.1.0/corphandouts/__init__.py +6 -0
  5. aa_corphandouts-0.1.0/corphandouts/admin.py +37 -0
  6. aa_corphandouts-0.1.0/corphandouts/app_settings.py +5 -0
  7. aa_corphandouts-0.1.0/corphandouts/apps.py +7 -0
  8. aa_corphandouts-0.1.0/corphandouts/auth_hooks.py +35 -0
  9. aa_corphandouts-0.1.0/corphandouts/corptools.py +49 -0
  10. aa_corphandouts-0.1.0/corphandouts/esi.py +32 -0
  11. aa_corphandouts-0.1.0/corphandouts/locale/en/LC_MESSAGES/django.po +113 -0
  12. aa_corphandouts-0.1.0/corphandouts/management/commands/testing.py +9 -0
  13. aa_corphandouts-0.1.0/corphandouts/migrations/0001_initial.py +200 -0
  14. aa_corphandouts-0.1.0/corphandouts/migrations/__init__.py +0 -0
  15. aa_corphandouts-0.1.0/corphandouts/models.py +141 -0
  16. aa_corphandouts-0.1.0/corphandouts/tasks.py +172 -0
  17. aa_corphandouts-0.1.0/corphandouts/templates/corphandouts/base.html +29 -0
  18. aa_corphandouts-0.1.0/corphandouts/templates/corphandouts/doctrine.html +75 -0
  19. aa_corphandouts-0.1.0/corphandouts/templates/corphandouts/index.html +75 -0
  20. aa_corphandouts-0.1.0/corphandouts/templates/corphandouts/modals/base.html +9 -0
  21. aa_corphandouts-0.1.0/corphandouts/templates/corphandouts/modals/content_base.html +29 -0
  22. aa_corphandouts-0.1.0/corphandouts/templates/corphandouts/modals/fit_corrections.html +2 -0
  23. aa_corphandouts-0.1.0/corphandouts/templates/corphandouts/modals/generic_modal_page.html +11 -0
  24. aa_corphandouts-0.1.0/corphandouts/templates/corphandouts/modals/loader_body.html +7 -0
  25. aa_corphandouts-0.1.0/corphandouts/templates/corphandouts/partials/fit_corrections.html +57 -0
  26. aa_corphandouts-0.1.0/corphandouts/templates/corphandouts/partials/handle_modals.html +20 -0
  27. aa_corphandouts-0.1.0/corphandouts/templates/corphandouts/partials/nav_collapse_left.html +6 -0
  28. aa_corphandouts-0.1.0/corphandouts/templatetags/__init__.py +0 -0
  29. aa_corphandouts-0.1.0/corphandouts/templatetags/corphandouts.py +11 -0
  30. aa_corphandouts-0.1.0/corphandouts/tests/__init__.py +0 -0
  31. aa_corphandouts-0.1.0/corphandouts/tests/test_tasks.py +11 -0
  32. aa_corphandouts-0.1.0/corphandouts/urls.py +14 -0
  33. aa_corphandouts-0.1.0/corphandouts/views.py +91 -0
  34. aa_corphandouts-0.1.0/pyproject.toml +78 -0
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 T'rahk Rokym
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,108 @@
1
+ Metadata-Version: 2.4
2
+ Name: aa-corphandouts
3
+ Version: 0.1.0
4
+ Summary: Example plugin app for Alliance Auth.
5
+ Author-email: John Doe <john.doe@example.com>, T'rahk Rokym <trahk.rokym@gmail.com>
6
+ Requires-Python: >=3.10
7
+ Description-Content-Type: text/markdown
8
+ Classifier: Environment :: Web Environment
9
+ Classifier: Framework :: Django
10
+ Classifier: Framework :: Django :: 4.0
11
+ Classifier: Framework :: Django :: 4.2
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python
16
+ Classifier: Programming Language :: Python :: 3.10
17
+ Classifier: Programming Language :: Python :: 3.11
18
+ Classifier: Programming Language :: Python :: 3.12
19
+ Classifier: Topic :: Internet :: WWW/HTTP
20
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
21
+ License-File: LICENSE
22
+ Requires-Dist: allianceauth>=4
23
+ Requires-Dist: fittings>=2.1
24
+ Requires-Dist: allianceauth-corptools>=2.9
25
+ Project-URL: Changelog, https://gitlab.com/r0kym/aa-corphandouts/-/blob/master/CHANGELOG.md
26
+ Project-URL: Homepage, https://gitlab.com/r0kym/aa-corphandouts/
27
+ Project-URL: Source, https://gitlab.com/r0kym/aa-corphandouts/
28
+ Project-URL: Tracker, https://gitlab.com/r0kym/aa-corphandouts/-/issues
29
+
30
+ # Corporation Handouts
31
+
32
+ *This module is under development. Use at your own risks.*
33
+
34
+ AA module for managing corporation handouts and especially to keep tracks of their fits/ammo to know if they should be fixed.
35
+
36
+ [![release](https://img.shields.io/pypi/v/aa-corphandouts?label=release)](https://pypi.org/project/aa-corphandouts/)
37
+ [![python](https://img.shields.io/pypi/pyversions/aa-corphandouts)](https://pypi.org/project/aa-corphandouts/)
38
+ [![django](https://img.shields.io/pypi/djversions/aa-corphandouts?label=django)](https://pypi.org/project/aa-corphandouts/)
39
+ [![license](https://img.shields.io/badge/license-MIT-green)](https://gitlab.com/r0kym/aa-corphandouts/-/blob/master/LICENSE)
40
+
41
+ ## Features:
42
+
43
+ ### Screenshots
44
+
45
+ ## Installation
46
+
47
+ ### Step 1 - Check prerequisites
48
+
49
+ 1. Corporation handouts is a plugin for Alliance Auth. If you don't have Alliance Auth running already, please install it first before proceeding. (see the official [AA installation guide](https://allianceauth.readthedocs.io/en/latest/installation/auth/allianceauth/) for details)
50
+ 2. The app requires you to have two other applications installed to work properly:
51
+ 1. [fittings](https://gitlab.com/colcrunch/fittings) installed.
52
+ 2. [allianceauth-corp-tools](https://github.com/Solar-Helix-Independent-Transport/allianceauth-corp-tools/tree/master)
53
+
54
+ Make sure to have both properly installed before continuing
55
+
56
+ ### Step 2 - Install app
57
+
58
+ Make sure you are in the virtual environment (venv) of your Alliance Auth installation. Then install the newest release from PyPI:
59
+
60
+ ```bash
61
+ pip install aa-corphandouts
62
+ ```
63
+
64
+ ### Step 3 - Configure Auth settings
65
+
66
+ Configure your Auth settings (`local.py`) as follows:
67
+
68
+ - Add `'corphandouts'` to `INSTALLED_APPS`
69
+ - Add below lines to your settings file:
70
+
71
+ ```python
72
+ ```
73
+
74
+ ### Step 4 - Finalize App installation
75
+
76
+ Run migrations & copy static files
77
+
78
+ ```bash
79
+ python manage.py migrate
80
+ python manage.py collectstatic --noinput
81
+ ```
82
+
83
+ Restart your supervisor services for Auth.
84
+
85
+ ## Permissions
86
+
87
+ Permissions overview.
88
+
89
+ | Name | Description |
90
+ |-----------------------|----------------------------------------------------------------------------------------------------------|
91
+
92
+ ## Settings
93
+
94
+ List of settings that can be modified for the application.
95
+ You can alter them by adding them in your `local.py` file.
96
+
97
+ | Name | Description | Default |
98
+ |---------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|---------|
99
+
100
+
101
+
102
+ ## Commands
103
+
104
+ The following commands can be used when running the module:
105
+
106
+ | Name | Description |
107
+ |----------------------------------------|-------------------------------------------------------------------------------|
108
+
@@ -0,0 +1,78 @@
1
+ # Corporation Handouts
2
+
3
+ *This module is under development. Use at your own risks.*
4
+
5
+ AA module for managing corporation handouts and especially to keep tracks of their fits/ammo to know if they should be fixed.
6
+
7
+ [![release](https://img.shields.io/pypi/v/aa-corphandouts?label=release)](https://pypi.org/project/aa-corphandouts/)
8
+ [![python](https://img.shields.io/pypi/pyversions/aa-corphandouts)](https://pypi.org/project/aa-corphandouts/)
9
+ [![django](https://img.shields.io/pypi/djversions/aa-corphandouts?label=django)](https://pypi.org/project/aa-corphandouts/)
10
+ [![license](https://img.shields.io/badge/license-MIT-green)](https://gitlab.com/r0kym/aa-corphandouts/-/blob/master/LICENSE)
11
+
12
+ ## Features:
13
+
14
+ ### Screenshots
15
+
16
+ ## Installation
17
+
18
+ ### Step 1 - Check prerequisites
19
+
20
+ 1. Corporation handouts is a plugin for Alliance Auth. If you don't have Alliance Auth running already, please install it first before proceeding. (see the official [AA installation guide](https://allianceauth.readthedocs.io/en/latest/installation/auth/allianceauth/) for details)
21
+ 2. The app requires you to have two other applications installed to work properly:
22
+ 1. [fittings](https://gitlab.com/colcrunch/fittings) installed.
23
+ 2. [allianceauth-corp-tools](https://github.com/Solar-Helix-Independent-Transport/allianceauth-corp-tools/tree/master)
24
+
25
+ Make sure to have both properly installed before continuing
26
+
27
+ ### Step 2 - Install app
28
+
29
+ Make sure you are in the virtual environment (venv) of your Alliance Auth installation. Then install the newest release from PyPI:
30
+
31
+ ```bash
32
+ pip install aa-corphandouts
33
+ ```
34
+
35
+ ### Step 3 - Configure Auth settings
36
+
37
+ Configure your Auth settings (`local.py`) as follows:
38
+
39
+ - Add `'corphandouts'` to `INSTALLED_APPS`
40
+ - Add below lines to your settings file:
41
+
42
+ ```python
43
+ ```
44
+
45
+ ### Step 4 - Finalize App installation
46
+
47
+ Run migrations & copy static files
48
+
49
+ ```bash
50
+ python manage.py migrate
51
+ python manage.py collectstatic --noinput
52
+ ```
53
+
54
+ Restart your supervisor services for Auth.
55
+
56
+ ## Permissions
57
+
58
+ Permissions overview.
59
+
60
+ | Name | Description |
61
+ |-----------------------|----------------------------------------------------------------------------------------------------------|
62
+
63
+ ## Settings
64
+
65
+ List of settings that can be modified for the application.
66
+ You can alter them by adding them in your `local.py` file.
67
+
68
+ | Name | Description | Default |
69
+ |---------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------|---------|
70
+
71
+
72
+
73
+ ## Commands
74
+
75
+ The following commands can be used when running the module:
76
+
77
+ | Name | Description |
78
+ |----------------------------------------|-------------------------------------------------------------------------------|
@@ -0,0 +1,6 @@
1
+ """Example plugin app for Alliance Auth."""
2
+
3
+ # pylint: disable = invalid-name
4
+ default_app_config = "corphandouts.apps.CorpHandoutsConfig"
5
+
6
+ __version__ = "0.1.0"
@@ -0,0 +1,37 @@
1
+ """Admin site."""
2
+
3
+ from corptools.models import CorpAsset, EveLocation
4
+
5
+ from django import forms
6
+ from django.contrib import admin
7
+
8
+ from corphandouts.models import DoctrineReport, FittingReport
9
+
10
+
11
+ class DoctrineReportForm(forms.ModelForm):
12
+ class Meta:
13
+ model = DoctrineReport
14
+ fields = "__all__"
15
+
16
+ def __init__(self, *args, **kwargs):
17
+ super().__init__(*args, **kwargs)
18
+ asset_locations_names_queryset = (
19
+ CorpAsset.objects.filter(location_name__isnull=False)
20
+ .values_list("location_name")
21
+ .distinct()
22
+ )
23
+ asset_locations_queryset = EveLocation.objects.filter(
24
+ location_id__in=asset_locations_names_queryset, managed=False
25
+ ).order_by("location_name")
26
+ # TODO filter out metenoxes
27
+ self.fields["location"].queryset = asset_locations_queryset
28
+
29
+
30
+ class FitInline(admin.TabularInline):
31
+ model = FittingReport
32
+
33
+
34
+ @admin.register(DoctrineReport)
35
+ class DoctrineReportAdmin(admin.ModelAdmin):
36
+ form = DoctrineReportForm
37
+ inlines = (FitInline,)
@@ -0,0 +1,5 @@
1
+ """App settings."""
2
+
3
+ from django.conf import settings
4
+
5
+ EXAMPLE_SETTING_ONE = getattr(settings, "EXAMPLE_SETTING_ONE", None)
@@ -0,0 +1,7 @@
1
+ from django.apps import AppConfig
2
+
3
+
4
+ class CorpHandoutsCongif(AppConfig):
5
+ name = "corphandouts"
6
+ label = "corphandouts"
7
+ verbose_name = "corphandouts"
@@ -0,0 +1,35 @@
1
+ from django.utils.translation import gettext_lazy as _
2
+
3
+ from allianceauth import hooks
4
+ from allianceauth.services.hooks import MenuItemHook, UrlHook
5
+
6
+ from . import urls
7
+
8
+
9
+ class CorporationHandoutMenuItem(MenuItemHook):
10
+ """This class ensures only authorized users will see the menu entry"""
11
+
12
+ def __init__(self):
13
+ # setup menu entry for sidebar
14
+ MenuItemHook.__init__(
15
+ self,
16
+ _("Corporation handouts"),
17
+ "fas fa-cube fa-fw",
18
+ "corphandouts:index",
19
+ navactive=["corphandouts:"],
20
+ )
21
+
22
+ def render(self, request):
23
+ if request.user.has_perm("corphandouts.basic_access"):
24
+ return MenuItemHook.render(self, request)
25
+ return ""
26
+
27
+
28
+ @hooks.register("menu_item_hook")
29
+ def register_menu():
30
+ return CorporationHandoutMenuItem()
31
+
32
+
33
+ @hooks.register("url_hook")
34
+ def register_urls():
35
+ return UrlHook(urls, "corphandouts", r"^corphandouts/")
@@ -0,0 +1,49 @@
1
+ from corptools.models import CorpAsset, CorporationAudit, EveLocation
2
+
3
+ from django.db.models import Q, QuerySet
4
+
5
+ from allianceauth.services.hooks import get_extension_logger
6
+
7
+ logger = get_extension_logger(__name__)
8
+
9
+
10
+ def get_assets_corporation_division(
11
+ corporation: CorporationAudit, location: EveLocation, hangar_division: int
12
+ ) -> QuerySet[CorpAsset]:
13
+ """Returns a queryset of corporation assets in the specified hangar and location"""
14
+
15
+ corp_assets = CorpAsset.objects.filter(corporation=corporation)
16
+ asset_locations = corp_assets.filter(location_name_id=location.location_id)
17
+ corp_assets = corp_assets.filter(
18
+ Q(location_name_id=location.location_id)
19
+ | Q(location_id__in=asset_locations.values_list("item_id"))
20
+ | Q(location_id=location.location_id)
21
+ )
22
+
23
+ return corp_assets.filter(location_flag=f"CorpSAG{hangar_division}")
24
+
25
+
26
+ def get_ship_fit(ship_item_id: int) -> QuerySet[CorpAsset]:
27
+ """Returns all known items linked to this ship id"""
28
+
29
+ return CorpAsset.objects.filter(location_id=ship_item_id)
30
+
31
+
32
+ def update_corp_item_names_bulk(item_name_ids: list[dict]):
33
+ """
34
+ Bulk update item names from a list of:
35
+ [
36
+ {
37
+ "item_id": int,
38
+ "name": str,
39
+ };
40
+ ]
41
+ """
42
+ logger.debug(item_name_ids)
43
+ corp_assets = []
44
+ for item in item_name_ids:
45
+ corp_asset = CorpAsset.objects.get(item_id=item["item_id"])
46
+ corp_asset.name = item["name"]
47
+ corp_assets.append(corp_asset)
48
+ logger.debug(corp_assets)
49
+ CorpAsset.objects.bulk_update(corp_assets, ["name"])
@@ -0,0 +1,32 @@
1
+ """ESI interactions"""
2
+
3
+ from corptools.task_helpers.corp_helpers import get_corp_token
4
+
5
+ from esi.clients import EsiClientProvider
6
+
7
+ from allianceauth.services.hooks import get_extension_logger
8
+
9
+ from . import __version__
10
+
11
+ logger = get_extension_logger(__name__)
12
+ esi = EsiClientProvider(app_info_text=f"aa-corp-handouts v{__version__}")
13
+
14
+
15
+ def get_corporation_asset_names(
16
+ corporation_id: int, item_ids: list[int]
17
+ ) -> list[[int, int]]:
18
+ """
19
+ Return names for a set of item ids, which you can get from corporation assets endpoint.
20
+ """
21
+ logger.info("Updating names for corp id %d", corporation_id)
22
+ logger.debug(item_ids)
23
+
24
+ req_scopes = ["esi-assets.read_corporation_assets.v1"]
25
+ req_roles = ["Director"]
26
+ token = get_corp_token(corporation_id, req_scopes, req_roles)
27
+
28
+ return esi.client.Assets.post_corporations_corporation_id_assets_names(
29
+ corporation_id=corporation_id,
30
+ item_ids=item_ids,
31
+ token=token.valid_access_token(),
32
+ ).result()
@@ -0,0 +1,113 @@
1
+ # SOME DESCRIPTIVE TITLE.
2
+ # Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER
3
+ # This file is distributed under the same license as the PACKAGE package.
4
+ # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5
+ #
6
+ #: corphandouts/templates/corphandouts/doctrine.html:11
7
+ #, fuzzy
8
+ msgid ""
9
+ msgstr ""
10
+ "Project-Id-Version: PACKAGE VERSION\n"
11
+ "Report-Msgid-Bugs-To: \n"
12
+ "POT-Creation-Date: 2025-04-04 20:21+0200\n"
13
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
14
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
15
+ "Language-Team: LANGUAGE <LL@li.org>\n"
16
+ "Language: \n"
17
+ "MIME-Version: 1.0\n"
18
+ "Content-Type: text/plain; charset=UTF-8\n"
19
+ "Content-Transfer-Encoding: 8bit\n"
20
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
21
+
22
+ #: corphandouts/auth_hooks.py:16
23
+ #: corphandouts/templates/corphandouts/base.html:5
24
+ msgid "Corporation handouts"
25
+ msgstr ""
26
+
27
+ #: corphandouts/models.py:27
28
+ msgid "Doctrine name"
29
+ msgstr ""
30
+
31
+ #: corphandouts/models.py:31
32
+ msgid "Corporation to get the assets from"
33
+ msgstr ""
34
+
35
+ #: corphandouts/models.py:36
36
+ msgid "Where the doctrine should be located"
37
+ msgstr ""
38
+
39
+ #: corphandouts/models.py:74
40
+ msgid "Amount of fits expected in the corp hangar. Set to 0 to ignore this fit"
41
+ msgstr ""
42
+
43
+ #: corphandouts/models.py:82
44
+ msgid "Optional regex to get ships from"
45
+ msgstr ""
46
+
47
+ #: corphandouts/models.py:122
48
+ msgid "Cargo"
49
+ msgstr ""
50
+
51
+ #: corphandouts/models.py:124
52
+ msgid "Fitting"
53
+ msgstr ""
54
+
55
+ #: corphandouts/models.py:126
56
+ msgid "Unknown"
57
+ msgstr ""
58
+
59
+ #: corphandouts/models.py:136
60
+ msgid "Amount to remove/add to the fit to match the template"
61
+ msgstr ""
62
+
63
+ #: corphandouts/templates/corphandouts/doctrine.html:12
64
+ #: corphandouts/templates/corphandouts/doctrine.html:62
65
+ msgid "Ship Type"
66
+ msgstr ""
67
+
68
+ #: corphandouts/templates/corphandouts/doctrine.html:13
69
+ #: corphandouts/templates/corphandouts/partials/fit_corrections.html:6
70
+ msgid "Ship name"
71
+ msgstr ""
72
+
73
+ #: corphandouts/templates/corphandouts/doctrine.html:14
74
+ #: corphandouts/templates/corphandouts/index.html:17
75
+ msgid "Errors"
76
+ msgstr ""
77
+
78
+ #: corphandouts/templates/corphandouts/index.html:13
79
+ msgid "Name"
80
+ msgstr ""
81
+
82
+ #: corphandouts/templates/corphandouts/index.html:15
83
+ msgid "Corporation<br>Division"
84
+ msgstr ""
85
+
86
+ #: corphandouts/templates/corphandouts/index.html:18
87
+ msgid "Ships"
88
+ msgstr ""
89
+
90
+ #: corphandouts/templates/corphandouts/modals/content_base.html:26
91
+ msgid "Close"
92
+ msgstr ""
93
+
94
+ #: corphandouts/templates/corphandouts/partials/fit_corrections.html:16
95
+ msgid "Ship type"
96
+ msgstr ""
97
+
98
+ #: corphandouts/templates/corphandouts/partials/fit_corrections.html:26
99
+ msgid "Type name"
100
+ msgstr ""
101
+
102
+ #: corphandouts/templates/corphandouts/partials/fit_corrections.html:27
103
+ msgid "Amount to change"
104
+ msgstr ""
105
+
106
+ #: corphandouts/templates/corphandouts/partials/fit_corrections.html:28
107
+ #: corphandouts/templates/corphandouts/partials/fit_corrections.html:50
108
+ msgid "Location"
109
+ msgstr ""
110
+
111
+ #: corphandouts/templates/corphandouts/partials/nav_collapse_left.html:5
112
+ msgid "View all handout reports"
113
+ msgstr ""
@@ -0,0 +1,9 @@
1
+ from django.core.management.base import BaseCommand
2
+
3
+ from corphandouts.tasks import update_doctrine_report
4
+
5
+
6
+ class Command(BaseCommand):
7
+
8
+ def handle(self, *args, **options):
9
+ update_doctrine_report(1)