aa-metenox 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.
- aa_metenox-0.1.0/LICENSE +21 -0
- aa_metenox-0.1.0/PKG-INFO +145 -0
- aa_metenox-0.1.0/README.md +116 -0
- aa_metenox-0.1.0/metenox/__init__.py +6 -0
- aa_metenox-0.1.0/metenox/admin.py +5 -0
- aa_metenox-0.1.0/metenox/api/fuzzwork.py +71 -0
- aa_metenox-0.1.0/metenox/app_settings.py +10 -0
- aa_metenox-0.1.0/metenox/apps.py +7 -0
- aa_metenox-0.1.0/metenox/auth_hooks.py +35 -0
- aa_metenox-0.1.0/metenox/esi.py +67 -0
- aa_metenox-0.1.0/metenox/management/commands/metenox_load_eve.py +34 -0
- aa_metenox-0.1.0/metenox/management/commands/metenox_update_all_owners.py +18 -0
- aa_metenox-0.1.0/metenox/management/commands/metenox_update_all_prices.py +15 -0
- aa_metenox-0.1.0/metenox/management/commands/metenox_update_moons_from_moonmining.py +16 -0
- aa_metenox-0.1.0/metenox/migrations/0001_initial.py +210 -0
- aa_metenox-0.1.0/metenox/migrations/0002_alter_moon_value.py +18 -0
- aa_metenox-0.1.0/metenox/migrations/__init__.py +0 -0
- aa_metenox-0.1.0/metenox/models.py +237 -0
- aa_metenox-0.1.0/metenox/moons.py +61 -0
- aa_metenox-0.1.0/metenox/tasks.py +184 -0
- aa_metenox-0.1.0/metenox/templates/metenox/base.html +30 -0
- aa_metenox-0.1.0/metenox/templates/metenox/corporations.html +20 -0
- aa_metenox-0.1.0/metenox/templates/metenox/index.html +119 -0
- aa_metenox-0.1.0/metenox/templates/metenox/partials/global_js.html +88 -0
- aa_metenox-0.1.0/metenox/templates/metenox/partials/menu.html +9 -0
- aa_metenox-0.1.0/metenox/templates/metenox/prices.html +26 -0
- aa_metenox-0.1.0/metenox/templatetags/__init__.py +0 -0
- aa_metenox-0.1.0/metenox/templatetags/metenox.py +45 -0
- aa_metenox-0.1.0/metenox/tests/__init__.py +0 -0
- aa_metenox-0.1.0/metenox/tests/test_moons.py +99 -0
- aa_metenox-0.1.0/metenox/tests/testdata/__init__.py +8 -0
- aa_metenox-0.1.0/metenox/tests/testdata/create_eveuniverse.py +136 -0
- aa_metenox-0.1.0/metenox/tests/testdata/eveuniverse.json +3582 -0
- aa_metenox-0.1.0/metenox/tests/testdata/load_eveuniverse.py +19 -0
- aa_metenox-0.1.0/metenox/urls.py +16 -0
- aa_metenox-0.1.0/metenox/views.py +294 -0
- aa_metenox-0.1.0/pyproject.toml +77 -0
aa_metenox-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2019 Erik Kalkoken
|
|
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,145 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: aa-metenox
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Metenox app config
|
|
5
|
+
Author-email: T'rahk Rokym <trahk.rokym@gmail.com>
|
|
6
|
+
Requires-Python: >=3.8
|
|
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: Topic :: Internet :: WWW/HTTP
|
|
19
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
20
|
+
Requires-Dist: allianceauth>=4
|
|
21
|
+
Requires-Dist: aa-moonmining>=1.11
|
|
22
|
+
Requires-Dist: allianceauth-app-utils>=1.25.0
|
|
23
|
+
Requires-Dist: django-datatables-view>=1.20.0
|
|
24
|
+
Project-URL: Changelog, https://gitlab.com/r0kym/aa-metenox/-/blob/main/CHANGELOG.md
|
|
25
|
+
Project-URL: Homepage, https://gitlab.com/r0kym/aa-metenox
|
|
26
|
+
Project-URL: Source, https://gitlab.com/r0kym/aa-metenox
|
|
27
|
+
Project-URL: Tracker, https://gitlab.com/r0kym/aa-metenox/-/issues
|
|
28
|
+
|
|
29
|
+
# Metenox
|
|
30
|
+
|
|
31
|
+
AA module for Metenox management.
|
|
32
|
+
|
|
33
|
+
## Feature roadmap:
|
|
34
|
+
- [x] Estimate the value of moons by importing the [aa-moonmining](https://gitlab.com/ErikKalkoken/aa-moonmining) database
|
|
35
|
+
- [ ] Displays the exact hourly pull of the moon
|
|
36
|
+
- [x] Import Metenoxes from a corp
|
|
37
|
+
- [ ] Estimate corp monthly revenue
|
|
38
|
+
- [ ] Notifications when low reagent/fuel
|
|
39
|
+
- [ ] Manager overview of corporations
|
|
40
|
+
- [ ] Taxation?
|
|
41
|
+
|
|
42
|
+
### What this app won't do:
|
|
43
|
+
- Estimate moon price for athanor.
|
|
44
|
+
Use [aa-moonmining](https://gitlab.com/ErikKalkoken/aa-moonmining)
|
|
45
|
+
- Ping when metenox are being reffed
|
|
46
|
+
Use [aa-structures](https://gitlab.com/ErikKalkoken/aa-structures)
|
|
47
|
+
|
|
48
|
+
This module aims to be specific for Metenox management.
|
|
49
|
+
|
|
50
|
+
## Installation
|
|
51
|
+
|
|
52
|
+
### Step 1 - Check prerequisites
|
|
53
|
+
|
|
54
|
+
1. Metenox 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)
|
|
55
|
+
|
|
56
|
+
2. Metenox requires the Alliance Auth module [aa-moonmining](https://gitlab.com/ErikKalkoken/aa-moonmining) to function.
|
|
57
|
+
The moon database and other utilities is imported from this module.
|
|
58
|
+
|
|
59
|
+
### Step 2 - Install app
|
|
60
|
+
|
|
61
|
+
Make sure you are in the virtual environment (venv) of your Alliance Auth installation. Then install the newest release from PyPI:
|
|
62
|
+
|
|
63
|
+
```bash
|
|
64
|
+
pip install aa-metenox
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Step 3 - Configure Auth settings
|
|
68
|
+
|
|
69
|
+
Configure your Auth settings (`local.py`) as follows:
|
|
70
|
+
|
|
71
|
+
- Add `'metenox'` to `INSTALLED_APPS`
|
|
72
|
+
- Add below lines to your settings file:
|
|
73
|
+
|
|
74
|
+
```python
|
|
75
|
+
CELERYBEAT_SCHEDULE['metenox_update_moon_prices'] = {
|
|
76
|
+
'task': 'metenox.tasks.update_moon_prices',
|
|
77
|
+
'schedule': crontab(hour='*/1'),
|
|
78
|
+
}
|
|
79
|
+
CELERYBEAT_SCHEDULE['metenox_update_moons_from_moonminin'] = {
|
|
80
|
+
'task': 'metenox.tasks.update_moons_from_moonmining',
|
|
81
|
+
'schedule': crontab(minutes='*/5'),
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
Optional: Alter the application settings.
|
|
86
|
+
The list can be found in [Settings](#settings)
|
|
87
|
+
|
|
88
|
+
### Step 4 - Finalize App installation
|
|
89
|
+
|
|
90
|
+
Run migrations & copy static files
|
|
91
|
+
|
|
92
|
+
```bash
|
|
93
|
+
python manage.py migrate
|
|
94
|
+
python manage.py collectstatic --noinput
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
Restart your supervisor services for Auth.
|
|
98
|
+
|
|
99
|
+
### Setp 5 - Load Goo from ESI
|
|
100
|
+
|
|
101
|
+
Run the following management command to load all moon goos from ESI.
|
|
102
|
+
This only has to be ran once.
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
python manage.py metenox_load_eve
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
Wait until the command is finished before continuing.
|
|
109
|
+
|
|
110
|
+
### Step 5 - Load data
|
|
111
|
+
|
|
112
|
+
First load the data from the moonmining module using
|
|
113
|
+
```bash
|
|
114
|
+
python manage.py metenox_update_moons_from_moonminin
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
Once it's done update their prices with
|
|
118
|
+
|
|
119
|
+
```bash
|
|
120
|
+
python manage.py metenox_update_all_prices
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Settings
|
|
124
|
+
|
|
125
|
+
List of settings that can be modified for the application.
|
|
126
|
+
You can alter them by adding them in your `local.py` file.
|
|
127
|
+
|
|
128
|
+
| Name | Descroption | Default |
|
|
129
|
+
|--------------------------------------|--------------------------------------------------------------------------------------------------|---------|
|
|
130
|
+
| 'METENOX_ADMIN_NOTIFICATIONS_ENABLE' | Whether admins will get notifications about important events like when someone adds a new owner. | True |
|
|
131
|
+
| | | |
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
## Dev notes
|
|
135
|
+
|
|
136
|
+
Load eveuniverse using
|
|
137
|
+
```shell
|
|
138
|
+
python manage.py eveuniverse_load_types --category_id_with_dogma 25 metenox
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Generate `eveuniverse.json`
|
|
142
|
+
```shell
|
|
143
|
+
python ../myauth/manage.py test metenox.tests.testdata.create_eveuniverse --keepdb -v 2
|
|
144
|
+
```
|
|
145
|
+
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# Metenox
|
|
2
|
+
|
|
3
|
+
AA module for Metenox management.
|
|
4
|
+
|
|
5
|
+
## Feature roadmap:
|
|
6
|
+
- [x] Estimate the value of moons by importing the [aa-moonmining](https://gitlab.com/ErikKalkoken/aa-moonmining) database
|
|
7
|
+
- [ ] Displays the exact hourly pull of the moon
|
|
8
|
+
- [x] Import Metenoxes from a corp
|
|
9
|
+
- [ ] Estimate corp monthly revenue
|
|
10
|
+
- [ ] Notifications when low reagent/fuel
|
|
11
|
+
- [ ] Manager overview of corporations
|
|
12
|
+
- [ ] Taxation?
|
|
13
|
+
|
|
14
|
+
### What this app won't do:
|
|
15
|
+
- Estimate moon price for athanor.
|
|
16
|
+
Use [aa-moonmining](https://gitlab.com/ErikKalkoken/aa-moonmining)
|
|
17
|
+
- Ping when metenox are being reffed
|
|
18
|
+
Use [aa-structures](https://gitlab.com/ErikKalkoken/aa-structures)
|
|
19
|
+
|
|
20
|
+
This module aims to be specific for Metenox management.
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
### Step 1 - Check prerequisites
|
|
25
|
+
|
|
26
|
+
1. Metenox 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)
|
|
27
|
+
|
|
28
|
+
2. Metenox requires the Alliance Auth module [aa-moonmining](https://gitlab.com/ErikKalkoken/aa-moonmining) to function.
|
|
29
|
+
The moon database and other utilities is imported from this module.
|
|
30
|
+
|
|
31
|
+
### Step 2 - Install app
|
|
32
|
+
|
|
33
|
+
Make sure you are in the virtual environment (venv) of your Alliance Auth installation. Then install the newest release from PyPI:
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install aa-metenox
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Step 3 - Configure Auth settings
|
|
40
|
+
|
|
41
|
+
Configure your Auth settings (`local.py`) as follows:
|
|
42
|
+
|
|
43
|
+
- Add `'metenox'` to `INSTALLED_APPS`
|
|
44
|
+
- Add below lines to your settings file:
|
|
45
|
+
|
|
46
|
+
```python
|
|
47
|
+
CELERYBEAT_SCHEDULE['metenox_update_moon_prices'] = {
|
|
48
|
+
'task': 'metenox.tasks.update_moon_prices',
|
|
49
|
+
'schedule': crontab(hour='*/1'),
|
|
50
|
+
}
|
|
51
|
+
CELERYBEAT_SCHEDULE['metenox_update_moons_from_moonminin'] = {
|
|
52
|
+
'task': 'metenox.tasks.update_moons_from_moonmining',
|
|
53
|
+
'schedule': crontab(minutes='*/5'),
|
|
54
|
+
}
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Optional: Alter the application settings.
|
|
58
|
+
The list can be found in [Settings](#settings)
|
|
59
|
+
|
|
60
|
+
### Step 4 - Finalize App installation
|
|
61
|
+
|
|
62
|
+
Run migrations & copy static files
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
python manage.py migrate
|
|
66
|
+
python manage.py collectstatic --noinput
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
Restart your supervisor services for Auth.
|
|
70
|
+
|
|
71
|
+
### Setp 5 - Load Goo from ESI
|
|
72
|
+
|
|
73
|
+
Run the following management command to load all moon goos from ESI.
|
|
74
|
+
This only has to be ran once.
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
python manage.py metenox_load_eve
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
Wait until the command is finished before continuing.
|
|
81
|
+
|
|
82
|
+
### Step 5 - Load data
|
|
83
|
+
|
|
84
|
+
First load the data from the moonmining module using
|
|
85
|
+
```bash
|
|
86
|
+
python manage.py metenox_update_moons_from_moonminin
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
Once it's done update their prices with
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
python manage.py metenox_update_all_prices
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## Settings
|
|
96
|
+
|
|
97
|
+
List of settings that can be modified for the application.
|
|
98
|
+
You can alter them by adding them in your `local.py` file.
|
|
99
|
+
|
|
100
|
+
| Name | Descroption | Default |
|
|
101
|
+
|--------------------------------------|--------------------------------------------------------------------------------------------------|---------|
|
|
102
|
+
| 'METENOX_ADMIN_NOTIFICATIONS_ENABLE' | Whether admins will get notifications about important events like when someone adds a new owner. | True |
|
|
103
|
+
| | | |
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
## Dev notes
|
|
107
|
+
|
|
108
|
+
Load eveuniverse using
|
|
109
|
+
```shell
|
|
110
|
+
python manage.py eveuniverse_load_types --category_id_with_dogma 25 metenox
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
Generate `eveuniverse.json`
|
|
114
|
+
```shell
|
|
115
|
+
python ../myauth/manage.py test metenox.tests.testdata.create_eveuniverse --keepdb -v 2
|
|
116
|
+
```
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"""Interactions with the fuzzwork market API"""
|
|
2
|
+
|
|
3
|
+
from enum import Enum
|
|
4
|
+
from typing import Dict, List
|
|
5
|
+
|
|
6
|
+
import requests
|
|
7
|
+
|
|
8
|
+
from eveuniverse.models import EveType
|
|
9
|
+
|
|
10
|
+
from allianceauth.services.hooks import get_extension_logger
|
|
11
|
+
|
|
12
|
+
FUZZWORK_URL = "https://market.fuzzwork.co.uk/aggregates/"
|
|
13
|
+
THE_FORGE_REGION_ID = 10000002
|
|
14
|
+
|
|
15
|
+
logger = get_extension_logger(__name__)
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
class BuySell(Enum):
|
|
19
|
+
"""Parameter to see if you want to fetch buy or sell orders"""
|
|
20
|
+
|
|
21
|
+
BUY = "buy"
|
|
22
|
+
SELL = "sell"
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
class PriceType(Enum):
|
|
26
|
+
"""Parameter to know what price aggregate you're looking for"""
|
|
27
|
+
|
|
28
|
+
WEIGHTED_AVERAGE = "weightedAverage"
|
|
29
|
+
MAX = "max"
|
|
30
|
+
MIN = "min"
|
|
31
|
+
MEDIAN = "median"
|
|
32
|
+
FIVE_PERCENT_WEIGHTED_AVERAGE = "percentile"
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
def get_types_prices(
|
|
36
|
+
eve_types: List[EveType], buy_sell: BuySell, price_type: PriceType
|
|
37
|
+
) -> Dict[int, float]:
|
|
38
|
+
"""
|
|
39
|
+
Retrieves the price of the given eve_types from the Fuzzwork API
|
|
40
|
+
The parameters allow to select the price type you want
|
|
41
|
+
"""
|
|
42
|
+
|
|
43
|
+
type_ids = [eve_type.id for eve_type in eve_types]
|
|
44
|
+
return get_type_ids_prices(type_ids, buy_sell, price_type)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
def get_type_ids_prices(
|
|
48
|
+
eve_types_ids: List[int],
|
|
49
|
+
buy_sell: BuySell = BuySell.BUY,
|
|
50
|
+
price_type: PriceType = PriceType.FIVE_PERCENT_WEIGHTED_AVERAGE,
|
|
51
|
+
) -> Dict[int, float]:
|
|
52
|
+
"""
|
|
53
|
+
Retrieves the price of the given eve_type_ids from the Fuzzwork API
|
|
54
|
+
The parameters allow to select the price type you want
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
if not eve_types_ids:
|
|
58
|
+
logger.warning("Received an empty list for fetching prices")
|
|
59
|
+
|
|
60
|
+
url = f"{FUZZWORK_URL}?region={THE_FORGE_REGION_ID}&types={','.join([str(eve_type_id) for eve_type_id in eve_types_ids])}"
|
|
61
|
+
|
|
62
|
+
logger.info("Trying to fetch data from %s" % url)
|
|
63
|
+
r = requests.get(url, timeout=5)
|
|
64
|
+
r.raise_for_status()
|
|
65
|
+
|
|
66
|
+
output_dic = {}
|
|
67
|
+
|
|
68
|
+
for type_id, market_info in r.json().items():
|
|
69
|
+
output_dic[type_id] = market_info[buy_sell.value][price_type.value]
|
|
70
|
+
|
|
71
|
+
return output_dic
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"""App settings."""
|
|
2
|
+
|
|
3
|
+
from app_utils.app_settings import clean_setting
|
|
4
|
+
|
|
5
|
+
METENOX_ADMIN_NOTIFICATIONS_ENABLED = clean_setting(
|
|
6
|
+
"METENOX_ADMIN_NOTIFICATION_ENABLED", True
|
|
7
|
+
)
|
|
8
|
+
"""Whether admins will get notifications about important events like
|
|
9
|
+
when someone adds a new owner.
|
|
10
|
+
"""
|
|
@@ -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 MetenoxMenuItem(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
|
+
_("metenox"),
|
|
17
|
+
"fas fa-oil-well fa-fw",
|
|
18
|
+
"metenox:index",
|
|
19
|
+
navactive=["metenox:"],
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
def render(self, request):
|
|
23
|
+
if request.user.has_perm("metenox.basic_access"):
|
|
24
|
+
return MenuItemHook.render(self, request)
|
|
25
|
+
return ""
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@hooks.register("menu_item_hook")
|
|
29
|
+
def register_menu():
|
|
30
|
+
return MetenoxMenuItem()
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@hooks.register("url_hook")
|
|
34
|
+
def register_urls():
|
|
35
|
+
return UrlHook(urls, "metenox", r"^metenox/")
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Modules containing all ESI interactions
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from typing import Optional
|
|
6
|
+
|
|
7
|
+
from esi.clients import EsiClientProvider
|
|
8
|
+
from esi.errors import TokenError
|
|
9
|
+
|
|
10
|
+
from metenox.models import HoldingCorporation
|
|
11
|
+
|
|
12
|
+
from . import __version__
|
|
13
|
+
|
|
14
|
+
METENOX_TYPE_ID = 81826
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
esi = EsiClientProvider(app_info_text=f"aa-metenox v{__version__}")
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def get_metenox_from_esi(
|
|
21
|
+
holding_corporation: HoldingCorporation,
|
|
22
|
+
) -> Optional[list[dict]]:
|
|
23
|
+
"""Returns all metenoxes associated with a given Owner"""
|
|
24
|
+
|
|
25
|
+
structures = get_structures_from_esi(holding_corporation)
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
[
|
|
29
|
+
structure
|
|
30
|
+
for structure in structures
|
|
31
|
+
if structure["type_id"] == METENOX_TYPE_ID
|
|
32
|
+
]
|
|
33
|
+
if structures
|
|
34
|
+
else None
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def get_structure_info_from_esi(
|
|
39
|
+
holding_corporation: HoldingCorporation, structure_id: int
|
|
40
|
+
) -> dict:
|
|
41
|
+
"""Returns the location information of a structure"""
|
|
42
|
+
|
|
43
|
+
for owner in holding_corporation.owners.all():
|
|
44
|
+
|
|
45
|
+
structure_info = esi.client.Universe.get_universe_structures_structure_id(
|
|
46
|
+
structure_id=structure_id,
|
|
47
|
+
token=owner.fetch_token().valid_access_token(),
|
|
48
|
+
).result()
|
|
49
|
+
|
|
50
|
+
return structure_info
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def get_structures_from_esi(
|
|
54
|
+
holding_corporation: HoldingCorporation,
|
|
55
|
+
) -> Optional[list[dict]]:
|
|
56
|
+
"""Returns all structures associated with a given owner"""
|
|
57
|
+
|
|
58
|
+
for owner in holding_corporation.owners.all():
|
|
59
|
+
try:
|
|
60
|
+
return esi.client.Corporation.get_corporations_corporation_id_structures(
|
|
61
|
+
corporation_id=owner.corporation.corporation.corporation_id,
|
|
62
|
+
token=owner.fetch_token().valid_access_token(),
|
|
63
|
+
).results()
|
|
64
|
+
except TokenError: # tries the next owner
|
|
65
|
+
continue
|
|
66
|
+
|
|
67
|
+
return None # No owner worked
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from django.core.management import BaseCommand
|
|
2
|
+
from eveuniverse.models import EveType
|
|
3
|
+
from eveuniverse.tasks import update_or_create_eve_object
|
|
4
|
+
|
|
5
|
+
from allianceauth.services.hooks import get_extension_logger
|
|
6
|
+
|
|
7
|
+
logger = get_extension_logger(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Command(BaseCommand):
|
|
11
|
+
help = "Preload static data from the ESI"
|
|
12
|
+
|
|
13
|
+
def handle(self, *args, **options):
|
|
14
|
+
self.stdout.write("Loading data from the ESI. It might take a while")
|
|
15
|
+
goo_types_count = EveType.objects.filter(eve_group_id=25).count()
|
|
16
|
+
self.stdout.write(f"Already {goo_types_count} in the database.")
|
|
17
|
+
self.stdout.write()
|
|
18
|
+
user_input = input("Do you want to proceed? (y/N)?")
|
|
19
|
+
|
|
20
|
+
if user_input.lower() == "y":
|
|
21
|
+
self.stdout.write("Starting to fetch moon goos")
|
|
22
|
+
update_or_create_eve_object.delay(
|
|
23
|
+
model_name="EveType",
|
|
24
|
+
id=25,
|
|
25
|
+
enabled_sections=[
|
|
26
|
+
EveType.Section.DOGMAS,
|
|
27
|
+
EveType.Section.TYPE_MATERIALS,
|
|
28
|
+
],
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
self.stdout.write("Done")
|
|
32
|
+
|
|
33
|
+
else:
|
|
34
|
+
self.stdout.write("Aborted")
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
from django.core.management.base import BaseCommand
|
|
2
|
+
|
|
3
|
+
from allianceauth.services.hooks import get_extension_logger
|
|
4
|
+
|
|
5
|
+
from metenox import tasks
|
|
6
|
+
from metenox.models import HoldingCorporation
|
|
7
|
+
|
|
8
|
+
logger = get_extension_logger(__name__)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Command(BaseCommand):
|
|
12
|
+
help = "Checks all metenox owners and update their Metenoxes"
|
|
13
|
+
|
|
14
|
+
def handle(self, *args, **options):
|
|
15
|
+
holding_corps = HoldingCorporation.objects.all()
|
|
16
|
+
logger.info(f"Starting update for {len(holding_corps)} owner(s)")
|
|
17
|
+
for holding in holding_corps:
|
|
18
|
+
tasks.update_holding.delay(holding.corporation.corporation_id)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
from django.core.management.base import BaseCommand
|
|
2
|
+
|
|
3
|
+
from allianceauth.services.hooks import get_extension_logger
|
|
4
|
+
|
|
5
|
+
from metenox import tasks
|
|
6
|
+
|
|
7
|
+
logger = get_extension_logger(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Command(BaseCommand):
|
|
11
|
+
help = "Fetches new moon goo prices and update metenox harvest values"
|
|
12
|
+
|
|
13
|
+
def handle(self, *args, **options):
|
|
14
|
+
logger.info("Command to update prices received")
|
|
15
|
+
tasks.update_moon_prices.delay()
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
from django.core.management.base import BaseCommand
|
|
2
|
+
|
|
3
|
+
from allianceauth.services.hooks import get_extension_logger
|
|
4
|
+
|
|
5
|
+
from metenox import tasks
|
|
6
|
+
|
|
7
|
+
logger = get_extension_logger(__name__)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class Command(BaseCommand):
|
|
11
|
+
help = (
|
|
12
|
+
"Fetches all moons from moonining application and adds them to this application"
|
|
13
|
+
)
|
|
14
|
+
|
|
15
|
+
def handle(self, *args, **options):
|
|
16
|
+
tasks.update_moons_from_moonmining.delay()
|