allianceauth-auth-stats 0.0.1a2__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.
- allianceauth-auth-stats-0.0.1a2/LICENCE +7 -0
- allianceauth-auth-stats-0.0.1a2/MANIFEST.in +7 -0
- allianceauth-auth-stats-0.0.1a2/PKG-INFO +83 -0
- allianceauth-auth-stats-0.0.1a2/README.md +60 -0
- allianceauth-auth-stats-0.0.1a2/allianceauth_auth_stats.egg-info/PKG-INFO +83 -0
- allianceauth-auth-stats-0.0.1a2/allianceauth_auth_stats.egg-info/SOURCES.txt +47 -0
- allianceauth-auth-stats-0.0.1a2/allianceauth_auth_stats.egg-info/dependency_links.txt +1 -0
- allianceauth-auth-stats-0.0.1a2/allianceauth_auth_stats.egg-info/requires.txt +2 -0
- allianceauth-auth-stats-0.0.1a2/allianceauth_auth_stats.egg-info/top_level.txt +2 -0
- allianceauth-auth-stats-0.0.1a2/authstats/__init__.py +2 -0
- allianceauth-auth-stats-0.0.1a2/authstats/admin.py +24 -0
- allianceauth-auth-stats-0.0.1a2/authstats/api.py +141 -0
- allianceauth-auth-stats-0.0.1a2/authstats/app_settings.py +3 -0
- allianceauth-auth-stats-0.0.1a2/authstats/apps.py +13 -0
- allianceauth-auth-stats-0.0.1a2/authstats/auth_hooks.py +40 -0
- allianceauth-auth-stats-0.0.1a2/authstats/management/commands/__init.py +0 -0
- allianceauth-auth-stats-0.0.1a2/authstats/management/commands/reports_refresh_all_reports.py +17 -0
- allianceauth-auth-stats-0.0.1a2/authstats/management/commands/reports_run_report.py +21 -0
- allianceauth-auth-stats-0.0.1a2/authstats/management/commands/reports_sync_filters.py +19 -0
- allianceauth-auth-stats-0.0.1a2/authstats/managers.py +7 -0
- allianceauth-auth-stats-0.0.1a2/authstats/migrations/0001_initial.py +103 -0
- allianceauth-auth-stats-0.0.1a2/authstats/migrations/0002_reportdatathrough_checkbox_only.py +18 -0
- allianceauth-auth-stats-0.0.1a2/authstats/migrations/0003_authreportsconfiguration_states_to_include.py +19 -0
- allianceauth-auth-stats-0.0.1a2/authstats/migrations/0004_alter_authreportsconfiguration_options.py +18 -0
- allianceauth-auth-stats-0.0.1a2/authstats/migrations/0005_alter_authreportsconfiguration_options_and_more.py +53 -0
- allianceauth-auth-stats-0.0.1a2/authstats/migrations/0006_report_show_character_image.py +18 -0
- allianceauth-auth-stats-0.0.1a2/authstats/migrations/0007_reportdatathrough_allow_sort.py +19 -0
- allianceauth-auth-stats-0.0.1a2/authstats/migrations/0008_alter_reportdatathrough_long_descriptions.py +19 -0
- allianceauth-auth-stats-0.0.1a2/authstats/migrations/__init__.py +0 -0
- allianceauth-auth-stats-0.0.1a2/authstats/models.py +248 -0
- allianceauth-auth-stats-0.0.1a2/authstats/providers.py +3 -0
- allianceauth-auth-stats-0.0.1a2/authstats/schema.py +63 -0
- allianceauth-auth-stats-0.0.1a2/authstats/signals.py +58 -0
- allianceauth-auth-stats-0.0.1a2/authstats/tasks.py +105 -0
- allianceauth-auth-stats-0.0.1a2/authstats/templates/__init__.py +0 -0
- allianceauth-auth-stats-0.0.1a2/authstats/templates/authstats/react_base.html +203 -0
- allianceauth-auth-stats-0.0.1a2/authstats/templatetags/__init__.py +0 -0
- allianceauth-auth-stats-0.0.1a2/authstats/tests/__init__.py +124 -0
- allianceauth-auth-stats-0.0.1a2/authstats/tests/test_access.py +79 -0
- allianceauth-auth-stats-0.0.1a2/authstats/urls.py +13 -0
- allianceauth-auth-stats-0.0.1a2/authstats/validators.py +12 -0
- allianceauth-auth-stats-0.0.1a2/authstats/views.py +48 -0
- allianceauth-auth-stats-0.0.1a2/setup.cfg +4 -0
- allianceauth-auth-stats-0.0.1a2/setup.py +39 -0
- allianceauth-auth-stats-0.0.1a2/tests/__init__.py +3 -0
- allianceauth-auth-stats-0.0.1a2/tests/celery.py +21 -0
- allianceauth-auth-stats-0.0.1a2/tests/test_settings.py +51 -0
- allianceauth-auth-stats-0.0.1a2/tests/urls.py +13 -0
- allianceauth-auth-stats-0.0.1a2/tests/views.py +5 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2023 Aaron Kable
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: allianceauth-auth-stats
|
|
3
|
+
Version: 0.0.1a2
|
|
4
|
+
Summary: Alliance Auth Plugin
|
|
5
|
+
Home-page: https://github.com/pvyParts/allianceauth-corp-tools
|
|
6
|
+
Author: AaronKable
|
|
7
|
+
Author-email: aaronkable@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Platform: UNKNOWN
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Environment :: Web Environment
|
|
12
|
+
Classifier: Framework :: Django
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
17
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
18
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENCE
|
|
21
|
+
|
|
22
|
+
# Auth Reports
|
|
23
|
+
|
|
24
|
+
### Auth Data in report form, in Auth, fully configurable
|
|
25
|
+
|
|
26
|
+
AKA Corp Stats 3.0
|
|
27
|
+
|
|
28
|
+
- Configurable Report Framework for corporate level aggregation of data
|
|
29
|
+
- each "field" is basically a smart filter from sec groups ( can use them too ) or a "field only" filter
|
|
30
|
+
- pass/fail stats collated over time?
|
|
31
|
+
|
|
32
|
+
## What it needs:
|
|
33
|
+
|
|
34
|
+
- require corporate member tokens to build the corp groups to see people not known to auth, to make a report for that too.
|
|
35
|
+
|
|
36
|
+
## Min Release Req's:
|
|
37
|
+
|
|
38
|
+
- [ ] a basic report that does what corpstats 2.0 does now
|
|
39
|
+
- alts to mains
|
|
40
|
+
- join dates
|
|
41
|
+
- last login
|
|
42
|
+
- [ ] permissions that give access to all reports at a `corp/alli/state/holding corps` level
|
|
43
|
+
- [ ] overview screen with passing/failing per corp per "report" ( maybe have this as optional aka "show_on_global_overview_report" )
|
|
44
|
+
|
|
45
|
+
## Nice to haves
|
|
46
|
+
|
|
47
|
+
- state level report that shows all members of a state
|
|
48
|
+
- csv/json/other export
|
|
49
|
+
- more things...
|
|
50
|
+
|
|
51
|
+
## Filters/stats provided by this app
|
|
52
|
+
|
|
53
|
+
- show all alts to a main
|
|
54
|
+
- anything else that makes sense?
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
1.
|
|
59
|
+
2.
|
|
60
|
+
|
|
61
|
+
## Permissions
|
|
62
|
+
|
|
63
|
+
There are some basic access perms
|
|
64
|
+
|
|
65
|
+
All permissions are filtered by main character, if a person has neutral alts loaded they will also be visible to someone who can see their main.
|
|
66
|
+
|
|
67
|
+
| Perm | Admin Site | Perm | Description |
|
|
68
|
+
| ---- | ---------- | ---- | ----------- |
|
|
69
|
+
| 1 | 2 | 3 | 4 |
|
|
70
|
+
|
|
71
|
+
Note: Configure the "Holding Corps" in the `Auth Reports Configuration` Admin Model. via the auth admin interface.
|
|
72
|
+
|
|
73
|
+
## Settings
|
|
74
|
+
|
|
75
|
+
| Setting | Default | Description |
|
|
76
|
+
| -------------------- | -------------- | ------------------------------- |
|
|
77
|
+
| `AUTHSTATS_APP_NAME` | "Auth Reports" | Name on the menu for Auth Stats |
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
|
|
81
|
+
Make sure you have signed the [License Agreement](https://developers.eveonline.com/resource/license-agreement) by logging in at https://developers.eveonline.com before submitting any pull requests. All bug fixes or features must not include extra superfluous formatting changes.
|
|
82
|
+
|
|
83
|
+
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Auth Reports
|
|
2
|
+
|
|
3
|
+
### Auth Data in report form, in Auth, fully configurable
|
|
4
|
+
|
|
5
|
+
AKA Corp Stats 3.0
|
|
6
|
+
|
|
7
|
+
- Configurable Report Framework for corporate level aggregation of data
|
|
8
|
+
- each "field" is basically a smart filter from sec groups ( can use them too ) or a "field only" filter
|
|
9
|
+
- pass/fail stats collated over time?
|
|
10
|
+
|
|
11
|
+
## What it needs:
|
|
12
|
+
|
|
13
|
+
- require corporate member tokens to build the corp groups to see people not known to auth, to make a report for that too.
|
|
14
|
+
|
|
15
|
+
## Min Release Req's:
|
|
16
|
+
|
|
17
|
+
- [ ] a basic report that does what corpstats 2.0 does now
|
|
18
|
+
- alts to mains
|
|
19
|
+
- join dates
|
|
20
|
+
- last login
|
|
21
|
+
- [ ] permissions that give access to all reports at a `corp/alli/state/holding corps` level
|
|
22
|
+
- [ ] overview screen with passing/failing per corp per "report" ( maybe have this as optional aka "show_on_global_overview_report" )
|
|
23
|
+
|
|
24
|
+
## Nice to haves
|
|
25
|
+
|
|
26
|
+
- state level report that shows all members of a state
|
|
27
|
+
- csv/json/other export
|
|
28
|
+
- more things...
|
|
29
|
+
|
|
30
|
+
## Filters/stats provided by this app
|
|
31
|
+
|
|
32
|
+
- show all alts to a main
|
|
33
|
+
- anything else that makes sense?
|
|
34
|
+
|
|
35
|
+
## Installation
|
|
36
|
+
|
|
37
|
+
1.
|
|
38
|
+
2.
|
|
39
|
+
|
|
40
|
+
## Permissions
|
|
41
|
+
|
|
42
|
+
There are some basic access perms
|
|
43
|
+
|
|
44
|
+
All permissions are filtered by main character, if a person has neutral alts loaded they will also be visible to someone who can see their main.
|
|
45
|
+
|
|
46
|
+
| Perm | Admin Site | Perm | Description |
|
|
47
|
+
| ---- | ---------- | ---- | ----------- |
|
|
48
|
+
| 1 | 2 | 3 | 4 |
|
|
49
|
+
|
|
50
|
+
Note: Configure the "Holding Corps" in the `Auth Reports Configuration` Admin Model. via the auth admin interface.
|
|
51
|
+
|
|
52
|
+
## Settings
|
|
53
|
+
|
|
54
|
+
| Setting | Default | Description |
|
|
55
|
+
| -------------------- | -------------- | ------------------------------- |
|
|
56
|
+
| `AUTHSTATS_APP_NAME` | "Auth Reports" | Name on the menu for Auth Stats |
|
|
57
|
+
|
|
58
|
+
## Contributing
|
|
59
|
+
|
|
60
|
+
Make sure you have signed the [License Agreement](https://developers.eveonline.com/resource/license-agreement) by logging in at https://developers.eveonline.com before submitting any pull requests. All bug fixes or features must not include extra superfluous formatting changes.
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: allianceauth-auth-stats
|
|
3
|
+
Version: 0.0.1a2
|
|
4
|
+
Summary: Alliance Auth Plugin
|
|
5
|
+
Home-page: https://github.com/pvyParts/allianceauth-corp-tools
|
|
6
|
+
Author: AaronKable
|
|
7
|
+
Author-email: aaronkable@gmail.com
|
|
8
|
+
License: MIT
|
|
9
|
+
Platform: UNKNOWN
|
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
|
11
|
+
Classifier: Environment :: Web Environment
|
|
12
|
+
Classifier: Framework :: Django
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: License :: OSI Approved :: GNU General Public License v3 (GPLv3)
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.6
|
|
17
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
18
|
+
Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
License-File: LICENCE
|
|
21
|
+
|
|
22
|
+
# Auth Reports
|
|
23
|
+
|
|
24
|
+
### Auth Data in report form, in Auth, fully configurable
|
|
25
|
+
|
|
26
|
+
AKA Corp Stats 3.0
|
|
27
|
+
|
|
28
|
+
- Configurable Report Framework for corporate level aggregation of data
|
|
29
|
+
- each "field" is basically a smart filter from sec groups ( can use them too ) or a "field only" filter
|
|
30
|
+
- pass/fail stats collated over time?
|
|
31
|
+
|
|
32
|
+
## What it needs:
|
|
33
|
+
|
|
34
|
+
- require corporate member tokens to build the corp groups to see people not known to auth, to make a report for that too.
|
|
35
|
+
|
|
36
|
+
## Min Release Req's:
|
|
37
|
+
|
|
38
|
+
- [ ] a basic report that does what corpstats 2.0 does now
|
|
39
|
+
- alts to mains
|
|
40
|
+
- join dates
|
|
41
|
+
- last login
|
|
42
|
+
- [ ] permissions that give access to all reports at a `corp/alli/state/holding corps` level
|
|
43
|
+
- [ ] overview screen with passing/failing per corp per "report" ( maybe have this as optional aka "show_on_global_overview_report" )
|
|
44
|
+
|
|
45
|
+
## Nice to haves
|
|
46
|
+
|
|
47
|
+
- state level report that shows all members of a state
|
|
48
|
+
- csv/json/other export
|
|
49
|
+
- more things...
|
|
50
|
+
|
|
51
|
+
## Filters/stats provided by this app
|
|
52
|
+
|
|
53
|
+
- show all alts to a main
|
|
54
|
+
- anything else that makes sense?
|
|
55
|
+
|
|
56
|
+
## Installation
|
|
57
|
+
|
|
58
|
+
1.
|
|
59
|
+
2.
|
|
60
|
+
|
|
61
|
+
## Permissions
|
|
62
|
+
|
|
63
|
+
There are some basic access perms
|
|
64
|
+
|
|
65
|
+
All permissions are filtered by main character, if a person has neutral alts loaded they will also be visible to someone who can see their main.
|
|
66
|
+
|
|
67
|
+
| Perm | Admin Site | Perm | Description |
|
|
68
|
+
| ---- | ---------- | ---- | ----------- |
|
|
69
|
+
| 1 | 2 | 3 | 4 |
|
|
70
|
+
|
|
71
|
+
Note: Configure the "Holding Corps" in the `Auth Reports Configuration` Admin Model. via the auth admin interface.
|
|
72
|
+
|
|
73
|
+
## Settings
|
|
74
|
+
|
|
75
|
+
| Setting | Default | Description |
|
|
76
|
+
| -------------------- | -------------- | ------------------------------- |
|
|
77
|
+
| `AUTHSTATS_APP_NAME` | "Auth Reports" | Name on the menu for Auth Stats |
|
|
78
|
+
|
|
79
|
+
## Contributing
|
|
80
|
+
|
|
81
|
+
Make sure you have signed the [License Agreement](https://developers.eveonline.com/resource/license-agreement) by logging in at https://developers.eveonline.com before submitting any pull requests. All bug fixes or features must not include extra superfluous formatting changes.
|
|
82
|
+
|
|
83
|
+
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
LICENCE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
setup.py
|
|
5
|
+
allianceauth_auth_stats.egg-info/PKG-INFO
|
|
6
|
+
allianceauth_auth_stats.egg-info/SOURCES.txt
|
|
7
|
+
allianceauth_auth_stats.egg-info/dependency_links.txt
|
|
8
|
+
allianceauth_auth_stats.egg-info/requires.txt
|
|
9
|
+
allianceauth_auth_stats.egg-info/top_level.txt
|
|
10
|
+
authstats/__init__.py
|
|
11
|
+
authstats/admin.py
|
|
12
|
+
authstats/api.py
|
|
13
|
+
authstats/app_settings.py
|
|
14
|
+
authstats/apps.py
|
|
15
|
+
authstats/auth_hooks.py
|
|
16
|
+
authstats/managers.py
|
|
17
|
+
authstats/models.py
|
|
18
|
+
authstats/providers.py
|
|
19
|
+
authstats/schema.py
|
|
20
|
+
authstats/signals.py
|
|
21
|
+
authstats/tasks.py
|
|
22
|
+
authstats/urls.py
|
|
23
|
+
authstats/validators.py
|
|
24
|
+
authstats/views.py
|
|
25
|
+
authstats/management/commands/__init.py
|
|
26
|
+
authstats/management/commands/reports_refresh_all_reports.py
|
|
27
|
+
authstats/management/commands/reports_run_report.py
|
|
28
|
+
authstats/management/commands/reports_sync_filters.py
|
|
29
|
+
authstats/migrations/0001_initial.py
|
|
30
|
+
authstats/migrations/0002_reportdatathrough_checkbox_only.py
|
|
31
|
+
authstats/migrations/0003_authreportsconfiguration_states_to_include.py
|
|
32
|
+
authstats/migrations/0004_alter_authreportsconfiguration_options.py
|
|
33
|
+
authstats/migrations/0005_alter_authreportsconfiguration_options_and_more.py
|
|
34
|
+
authstats/migrations/0006_report_show_character_image.py
|
|
35
|
+
authstats/migrations/0007_reportdatathrough_allow_sort.py
|
|
36
|
+
authstats/migrations/0008_alter_reportdatathrough_long_descriptions.py
|
|
37
|
+
authstats/migrations/__init__.py
|
|
38
|
+
authstats/templates/__init__.py
|
|
39
|
+
authstats/templates/authstats/react_base.html
|
|
40
|
+
authstats/templatetags/__init__.py
|
|
41
|
+
authstats/tests/__init__.py
|
|
42
|
+
authstats/tests/test_access.py
|
|
43
|
+
tests/__init__.py
|
|
44
|
+
tests/celery.py
|
|
45
|
+
tests/test_settings.py
|
|
46
|
+
tests/urls.py
|
|
47
|
+
tests/views.py
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
from django.contrib import admin
|
|
2
|
+
from django.utils.html import format_html
|
|
3
|
+
from solo.admin import SingletonModelAdmin
|
|
4
|
+
|
|
5
|
+
from .models import (AuthReportsConfiguration, Report, ReportDataSource,
|
|
6
|
+
ReportDataThrough, ReportFieldAlts)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ReportDataFieldThroughAdmin(admin.StackedInline):
|
|
10
|
+
model = ReportDataThrough
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
class ReportAdmin(admin.ModelAdmin):
|
|
14
|
+
inlines = [
|
|
15
|
+
ReportDataFieldThroughAdmin,
|
|
16
|
+
]
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
admin.site.register(Report, ReportAdmin)
|
|
20
|
+
|
|
21
|
+
admin.site.register(ReportDataSource)
|
|
22
|
+
admin.site.register(ReportFieldAlts)
|
|
23
|
+
|
|
24
|
+
admin.site.register(AuthReportsConfiguration, SingletonModelAdmin)
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import json
|
|
4
|
+
import logging
|
|
5
|
+
from datetime import timedelta
|
|
6
|
+
from typing import List
|
|
7
|
+
|
|
8
|
+
from allianceauth.eveonline.models import EveCharacter, EveCorporationInfo
|
|
9
|
+
from django.conf import settings
|
|
10
|
+
from django.contrib.auth.models import User
|
|
11
|
+
from django.db.models import QuerySet
|
|
12
|
+
from django.utils import timezone
|
|
13
|
+
from esi.errors import TokenExpiredError
|
|
14
|
+
from esi.models import Token
|
|
15
|
+
from ninja import Field, NinjaAPI, Schema
|
|
16
|
+
from ninja.pagination import LimitOffsetPagination, paginate
|
|
17
|
+
from ninja.security import django_auth
|
|
18
|
+
from ninja.types import DictStrAny
|
|
19
|
+
|
|
20
|
+
from authstats import schema
|
|
21
|
+
from authstats.tasks import run_report_for_corp
|
|
22
|
+
|
|
23
|
+
from . import providers
|
|
24
|
+
from .models import AuthReportsConfiguration, Report, ReportResults
|
|
25
|
+
|
|
26
|
+
logger = logging.getLogger(__name__)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class Paginator(LimitOffsetPagination):
|
|
30
|
+
class Input(Schema):
|
|
31
|
+
limit: int = Field(1000000, ge=1)
|
|
32
|
+
offset: int = Field(0, ge=0)
|
|
33
|
+
|
|
34
|
+
def paginate_queryset(
|
|
35
|
+
self,
|
|
36
|
+
queryset: QuerySet,
|
|
37
|
+
pagination: Input,
|
|
38
|
+
**params: DictStrAny,
|
|
39
|
+
) -> any:
|
|
40
|
+
offset = pagination.offset
|
|
41
|
+
limit: int = pagination.limit
|
|
42
|
+
return {
|
|
43
|
+
"items": queryset[offset: offset + limit],
|
|
44
|
+
"count": self._items_count(queryset),
|
|
45
|
+
} # noqa: E203
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
api = NinjaAPI(title="Auth Stats API", version="0.0.3",
|
|
49
|
+
urls_namespace='authstats:api', auth=django_auth, csrf=True) # ,
|
|
50
|
+
# openapi_url=settings.DEBUG and "/openapi.json" or "")
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
@api.get(
|
|
54
|
+
"/get_report/{report_id}/{corp_id}",
|
|
55
|
+
response={200: dict, 403: str},
|
|
56
|
+
tags=["Report"]
|
|
57
|
+
)
|
|
58
|
+
def get_report_for_corp(request, report_id: int, corp_id: int):
|
|
59
|
+
if not AuthReportsConfiguration.get_solo().visible_corps_for_user(request.user).filter(corporation_id=corp_id).exists():
|
|
60
|
+
return 403, f"Access Denied to get_report_for_corp {report_id}/{corp_id} for {request.user}"
|
|
61
|
+
try:
|
|
62
|
+
report = ReportResults.objects.get(
|
|
63
|
+
corporation__corporation_id=corp_id, report_id=report_id)
|
|
64
|
+
if report.report.restricted and not request.user.has_perms("authstats.restricted_reports"):
|
|
65
|
+
return 403, f"Access Denied to get_report_for_corp {report_id}/{corp_id} for {request.user}"
|
|
66
|
+
if report.last_update < timezone.now() - timedelta(hours=1):
|
|
67
|
+
run_report_for_corp.delay(corp_id, report_id)
|
|
68
|
+
return json.loads(report.results)
|
|
69
|
+
except ReportResults.DoesNotExist:
|
|
70
|
+
corp = EveCorporationInfo.objects.get(corporation_id=corp_id)
|
|
71
|
+
report = Report.objects.get(id=report_id)
|
|
72
|
+
# send task!
|
|
73
|
+
run_report_for_corp.delay(corp_id, report_id)
|
|
74
|
+
return {"report": {"name": f"{report.name}",
|
|
75
|
+
"corporation": corp.corporation_name},
|
|
76
|
+
"members": 0, "unknowns": 0}
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
@api.get(
|
|
80
|
+
"/get_corps",
|
|
81
|
+
response={200: List[schema.Corporation]},
|
|
82
|
+
tags=["Report"]
|
|
83
|
+
)
|
|
84
|
+
def get_corps(request):
|
|
85
|
+
return AuthReportsConfiguration.get_solo().visible_corps_for_user(request.user)
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
@api.get(
|
|
89
|
+
"/get_reports",
|
|
90
|
+
response={200: List[schema.Report], 403: str},
|
|
91
|
+
tags=["Report"]
|
|
92
|
+
)
|
|
93
|
+
def get_reports(request):
|
|
94
|
+
if not request.user.has_perm("authstats.basic_access"):
|
|
95
|
+
return 403, f"Access Denied to get_reports for {request.user}"
|
|
96
|
+
|
|
97
|
+
_reports = Report.objects.all()
|
|
98
|
+
if not request.user.has_perms("authstats.restricted_reports"):
|
|
99
|
+
_reports = _reports.filter(restricted=False)
|
|
100
|
+
return _reports
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
@api.get(
|
|
104
|
+
"/get_unknowns/{corp_id}",
|
|
105
|
+
response={200: dict, 403: str},
|
|
106
|
+
tags=["Report"]
|
|
107
|
+
)
|
|
108
|
+
def get_orphans_for_corp(request, corp_id: int):
|
|
109
|
+
if not AuthReportsConfiguration.get_solo().visible_corps_for_user(request.user).filter(corporation_id=corp_id).exists():
|
|
110
|
+
return 403, f"Access Denied to get_orphans_for_corp for {request.user}"
|
|
111
|
+
|
|
112
|
+
corp = EveCorporationInfo.objects.get(corporation_id=corp_id)
|
|
113
|
+
|
|
114
|
+
mains = User.objects.filter(
|
|
115
|
+
profile__main_character__corporation_id=corp_id)
|
|
116
|
+
|
|
117
|
+
known_character_ids = EveCharacter.objects.filter(
|
|
118
|
+
corporation_id=corp_id, character_ownership__isnull=False).values_list("character_id", flat=True)
|
|
119
|
+
names = []
|
|
120
|
+
try:
|
|
121
|
+
scopes = "esi-corporations.read_corporation_membership.v1"
|
|
122
|
+
token = Token.objects.filter(
|
|
123
|
+
character_id__in=EveCharacter.objects.filter(
|
|
124
|
+
corporation_id=corp_id).values('character_id')).require_scopes(scopes)
|
|
125
|
+
if not token.exists():
|
|
126
|
+
raise Exception("No Tokens")
|
|
127
|
+
unknown_member_list = set(providers.esi.client.Corporation.get_corporations_corporation_id_members(
|
|
128
|
+
corporation_id=corp_id, token=token.first().valid_access_token()).results())
|
|
129
|
+
for m in known_character_ids:
|
|
130
|
+
try:
|
|
131
|
+
unknown_member_list.remove(m)
|
|
132
|
+
except KeyError:
|
|
133
|
+
pass
|
|
134
|
+
names = providers.esi.client.Universe.post_universe_names(
|
|
135
|
+
ids=list(unknown_member_list)).results()
|
|
136
|
+
except Exception as e:
|
|
137
|
+
logger.exception(e)
|
|
138
|
+
|
|
139
|
+
return {"report": {"name": "Orphan Characters",
|
|
140
|
+
"corporation": corp.corporation_name},
|
|
141
|
+
"members": mains.count(), "data": names}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from allianceauth import hooks
|
|
2
|
+
from allianceauth.services.hooks import MenuItemHook, UrlHook
|
|
3
|
+
from django.utils.translation import gettext_lazy as _
|
|
4
|
+
|
|
5
|
+
from . import app_settings, models, urls
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class AuthStats(MenuItemHook):
|
|
9
|
+
def __init__(self):
|
|
10
|
+
|
|
11
|
+
MenuItemHook.__init__(self,
|
|
12
|
+
app_settings.AUTHSTATS_APP_NAME,
|
|
13
|
+
'fas fa-book-open fa-fw',
|
|
14
|
+
'authstats:base',
|
|
15
|
+
navactive=['authstats:base'])
|
|
16
|
+
|
|
17
|
+
def render(self, request):
|
|
18
|
+
if request.user.has_perm('authstats.basic_access'):
|
|
19
|
+
return MenuItemHook.render(self, request)
|
|
20
|
+
return ''
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
@hooks.register('menu_item_hook')
|
|
24
|
+
def register_menu():
|
|
25
|
+
return AuthStats()
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@hooks.register('url_hook')
|
|
29
|
+
def register_url():
|
|
30
|
+
return UrlHook(urls, 'authstats', r'^reports/')
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@hooks.register("secure_group_filters")
|
|
34
|
+
def filters():
|
|
35
|
+
return [models.ReportFieldAlts]
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@hooks.register('discord_cogs_hook')
|
|
39
|
+
def register_cogs():
|
|
40
|
+
return []
|
|
File without changes
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
from django.core.management.base import BaseCommand
|
|
4
|
+
|
|
5
|
+
from ...models import ReportResults
|
|
6
|
+
from ...tasks import run_report_for_corp
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class Command(BaseCommand):
|
|
10
|
+
help = 'refresh all a reports'
|
|
11
|
+
|
|
12
|
+
def handle(self, *args, **options):
|
|
13
|
+
for rep in ReportResults.objects.all():
|
|
14
|
+
self.stdout.write(
|
|
15
|
+
f"Refreshing Report: Corp:{rep.corporation} Report:{rep.report.name}")
|
|
16
|
+
run_report_for_corp.delay(
|
|
17
|
+
rep.corporation.corporation_id, rep.report_id)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import json
|
|
2
|
+
|
|
3
|
+
from django.contrib.contenttypes.models import ContentType
|
|
4
|
+
from django.core.management.base import BaseCommand
|
|
5
|
+
|
|
6
|
+
from ...models import Report
|
|
7
|
+
from ...signals import filters
|
|
8
|
+
from ...tasks import run_report_for_corp
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class Command(BaseCommand):
|
|
12
|
+
help = 'run a report'
|
|
13
|
+
|
|
14
|
+
def add_arguments(self, parser):
|
|
15
|
+
parser.add_argument('--report', type=int)
|
|
16
|
+
parser.add_argument('--corp_id', type=int)
|
|
17
|
+
|
|
18
|
+
def handle(self, *args, **options):
|
|
19
|
+
self.stdout.write(
|
|
20
|
+
f"Running a report for RID:{options['report']} CID:{options['corp_id']}")
|
|
21
|
+
return json.dumps(run_report_for_corp(options['corp_id'], options['report']), indent=4)
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
from django.contrib.contenttypes.models import ContentType
|
|
2
|
+
from django.core.management.base import BaseCommand
|
|
3
|
+
|
|
4
|
+
from ...models import ReportDataSource
|
|
5
|
+
from ...signals import filters
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
class Command(BaseCommand):
|
|
9
|
+
help = 'Syncing all the Models from Secure Group Filters'
|
|
10
|
+
|
|
11
|
+
def handle(self, *args, **options):
|
|
12
|
+
self.stdout.write("Syncing all the Models from Secure Group Filters")
|
|
13
|
+
for _filter in filters.get_hooks():
|
|
14
|
+
for filter in _filter.objects.all():
|
|
15
|
+
if not ReportDataSource.objects.filter(
|
|
16
|
+
content_type=ContentType.objects.get_for_model(
|
|
17
|
+
filter).id,
|
|
18
|
+
object_id=filter.id).exists():
|
|
19
|
+
ReportDataSource.objects.create(filter_object=filter)
|