allianceauth-auth-stats 0.0.1__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 (56) hide show
  1. allianceauth_auth_stats-0.0.1/LICENSE +7 -0
  2. allianceauth_auth_stats-0.0.1/PKG-INFO +133 -0
  3. allianceauth_auth_stats-0.0.1/README.md +98 -0
  4. allianceauth_auth_stats-0.0.1/authstats/__init__.py +5 -0
  5. allianceauth_auth_stats-0.0.1/authstats/admin.py +26 -0
  6. allianceauth_auth_stats-0.0.1/authstats/api.py +143 -0
  7. allianceauth_auth_stats-0.0.1/authstats/app_settings.py +3 -0
  8. allianceauth_auth_stats-0.0.1/authstats/apps.py +13 -0
  9. allianceauth_auth_stats-0.0.1/authstats/auth_hooks.py +41 -0
  10. allianceauth_auth_stats-0.0.1/authstats/locale/en/LC_MESSAGES/django.po +39 -0
  11. allianceauth_auth_stats-0.0.1/authstats/management/commands/__init.py +0 -0
  12. allianceauth_auth_stats-0.0.1/authstats/management/commands/reports_bootstrap_report.py +30 -0
  13. allianceauth_auth_stats-0.0.1/authstats/management/commands/reports_refresh_all_reports.py +16 -0
  14. allianceauth_auth_stats-0.0.1/authstats/management/commands/reports_run_report.py +21 -0
  15. allianceauth_auth_stats-0.0.1/authstats/management/commands/reports_sync_filters.py +19 -0
  16. allianceauth_auth_stats-0.0.1/authstats/managers.py +8 -0
  17. allianceauth_auth_stats-0.0.1/authstats/migrations/0001_initial.py +103 -0
  18. allianceauth_auth_stats-0.0.1/authstats/migrations/0002_reportdatathrough_checkbox_only.py +18 -0
  19. allianceauth_auth_stats-0.0.1/authstats/migrations/0003_authreportsconfiguration_states_to_include.py +19 -0
  20. allianceauth_auth_stats-0.0.1/authstats/migrations/0004_alter_authreportsconfiguration_options.py +18 -0
  21. allianceauth_auth_stats-0.0.1/authstats/migrations/0005_alter_authreportsconfiguration_options_and_more.py +53 -0
  22. allianceauth_auth_stats-0.0.1/authstats/migrations/0006_report_show_character_image.py +18 -0
  23. allianceauth_auth_stats-0.0.1/authstats/migrations/0007_reportdatathrough_allow_sort.py +19 -0
  24. allianceauth_auth_stats-0.0.1/authstats/migrations/0008_alter_reportdatathrough_long_descriptions.py +19 -0
  25. allianceauth_auth_stats-0.0.1/authstats/migrations/__init__.py +0 -0
  26. allianceauth_auth_stats-0.0.1/authstats/models.py +253 -0
  27. allianceauth_auth_stats-0.0.1/authstats/providers.py +3 -0
  28. allianceauth_auth_stats-0.0.1/authstats/schema.py +62 -0
  29. allianceauth_auth_stats-0.0.1/authstats/signals.py +70 -0
  30. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs3/assets/@libs-3ucQeUj1.js +49 -0
  31. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs3/assets/@libs-3ucQeUj1.js.map +1 -0
  32. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs3/assets/@react-router-DHoxyQNO.js +29 -0
  33. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs3/assets/@react-router-DHoxyQNO.js.map +1 -0
  34. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs3/assets/index-CCQS2-LS.css +1 -0
  35. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs3/assets/index-D0eV-U1d.js +166 -0
  36. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs3/assets/index-D0eV-U1d.js.map +1 -0
  37. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs3/manifest.json +26 -0
  38. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs5/assets/@libs-Dul-zyXW.js +57 -0
  39. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs5/assets/@libs-Dul-zyXW.js.map +1 -0
  40. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs5/assets/@react-router-D8oLmiuy.js +29 -0
  41. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs5/assets/@react-router-D8oLmiuy.js.map +1 -0
  42. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs5/assets/index-D8okOcBX.js +154 -0
  43. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs5/assets/index-D8okOcBX.js.map +1 -0
  44. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs5/assets/index-h30D2GFt.css +1 -0
  45. allianceauth_auth_stats-0.0.1/authstats/static/authstats/bs5/manifest.json +26 -0
  46. allianceauth_auth_stats-0.0.1/authstats/tasks.py +109 -0
  47. allianceauth_auth_stats-0.0.1/authstats/templates/__init__.py +0 -0
  48. allianceauth_auth_stats-0.0.1/authstats/templates/authstats/react_base.html +202 -0
  49. allianceauth_auth_stats-0.0.1/authstats/templates/authstats/react_base_bs5.html +100 -0
  50. allianceauth_auth_stats-0.0.1/authstats/templatetags/__init__.py +0 -0
  51. allianceauth_auth_stats-0.0.1/authstats/tests/__init__.py +126 -0
  52. allianceauth_auth_stats-0.0.1/authstats/tests/test_access.py +79 -0
  53. allianceauth_auth_stats-0.0.1/authstats/urls.py +13 -0
  54. allianceauth_auth_stats-0.0.1/authstats/validators.py +12 -0
  55. allianceauth_auth_stats-0.0.1/authstats/views.py +56 -0
  56. allianceauth_auth_stats-0.0.1/pyproject.toml +76 -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,133 @@
1
+ Metadata-Version: 2.4
2
+ Name: allianceauth-auth-stats
3
+ Version: 0.0.1
4
+ Summary: Configurable Report Framework for corporate level aggregation of any data
5
+ Keywords: allianceauth,eveonline
6
+ Author-email: AaronKable <aaronkable@gmail.com>
7
+ Requires-Python: >=3.8
8
+ Description-Content-Type: text/markdown
9
+ Classifier: Environment :: Web Environment
10
+ Classifier: Framework :: Celery
11
+ Classifier: Framework :: Django
12
+ Classifier: Framework :: Django :: 4.0
13
+ Classifier: Framework :: Django :: 4.2
14
+ Classifier: Intended Audience :: Developers
15
+ Classifier: License :: OSI Approved :: MIT License
16
+ Classifier: Operating System :: OS Independent
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Programming Language :: Python :: 3 :: Only
19
+ Classifier: Programming Language :: Python :: 3.8
20
+ Classifier: Programming Language :: Python :: 3.9
21
+ Classifier: Programming Language :: Python :: 3.10
22
+ Classifier: Programming Language :: Python :: 3.11
23
+ Classifier: Programming Language :: Python :: 3.12
24
+ Classifier: Programming Language :: Python :: Implementation :: CPython
25
+ Classifier: Topic :: Internet :: WWW/HTTP
26
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
27
+ License-File: LICENSE
28
+ Requires-Dist: allianceauth<5,>=3
29
+ Requires-Dist: django-ninja>=1.0.1,<2
30
+ Requires-Dist: django-solo>=2.1
31
+ Project-URL: Homepage, https://github.com/Solar-Helix-Independent-Transport/allianceauth-auth-stats
32
+ Project-URL: Source, https://github.com/Solar-Helix-Independent-Transport/allianceauth-auth-stats
33
+ Project-URL: Tracker, https://github.com/Solar-Helix-Independent-Transport/allianceauth-auth-stats/issues
34
+
35
+ # Auth Reports
36
+
37
+ ### Auth Data in report form, in Auth, fully configurable
38
+
39
+ AKA Corp Stats 3.0
40
+
41
+ - Configurable Report Framework for corporate level aggregation of any data
42
+ - each "field" is a smart filter similar to secure groups ( can use secure groups filters too ) or a "field only" filter provided by any application in the alliance auth ecosystem.
43
+ - These filters MUST be the more "modern" kind with either a `process_field` or `audit_filter` methods. Legacy filters using only `process_filter` will not show any data. [Please see this link for more info](https://github.com/Solar-Helix-Independent-Transport/allianceauth-secure-groups/blob/main/THRID_PARTY.md)
44
+ - Data Exportable to CSV for external manipulation.
45
+
46
+ ## What it needs:
47
+
48
+ - require corporate member tokens to build the corp groups to see people not known to auth, to make a report for that too. these can be added with the plus button in the menubar
49
+
50
+ ## The General Road Map
51
+
52
+ if you want some features, please create an issue.
53
+
54
+ - state level report that shows all members of a state
55
+ - group reports for group leaders
56
+ - overview screen with passing/failing per corp per "report" ( maybe have this as optional aka "show_on_global_overview_report" )
57
+ - more things...
58
+
59
+ ## Filters/stats provided by this app
60
+
61
+ - show all alts for a main, with option to only show in corp alts
62
+
63
+ ## Other Apps with filters
64
+
65
+ - [Corptools](https://github.com/Solar-Helix-Independent-Transport/allianceauth-corp-tools?tab=readme-ov-file#corptools)
66
+ - [Member Audit Smart Filters](https://github.com/ppfeufer/aa-ma-securegroups)
67
+ - [Secure Groups](https://github.com/Solar-Helix-Independent-Transport/allianceauth-secure-groups)
68
+ - [Secret Santa](https://gitlab.com/tactical-supremacy/aa-secret-santa)
69
+ - [Discord Multiverse](https://github.com/Solar-Helix-Independent-Transport/allianceauth-discord-multiverse)
70
+ - [Invoices](https://github.com/Solar-Helix-Independent-Transport/allianceauth-invoice-manager)
71
+
72
+ ... more send a PR in with updates
73
+
74
+ ## Installation
75
+
76
+ ### Bare Metal
77
+
78
+ 1. `pip install -U allianceauth-auth-stats`
79
+ 1. add `'authstats',` to your local.py
80
+ 1. migrate `python manage.py migrate`
81
+ 1. collectstatic `python manage.py collectstatic --noinput`
82
+ 1. sync commands `python manage.py reports_sync_filters`
83
+ 1. create your first report `python manage.py reports_bootstrap_report`
84
+ 1. restart auth
85
+ 1. continue to the common section
86
+
87
+ ### Docker
88
+
89
+ 1. add `allianceauth-auth-stats==0.0.1` (update version number as required) to your requirements.txt file and rebuild your containers `docker compose build --no-cache`
90
+ 1. add `'authstats',` to your local.py
91
+ 1. recreate you docker stack `docker compose up -d`
92
+ 1. enter your auth container and run migrations and collect static and sync filters `docker compose exec alliancauth_gunicorn bash`
93
+
94
+ - `auth collectstatic`
95
+ - `auth migrate`
96
+ - `auth reports_sync_filters`
97
+ - `auth reports_bootstrap_report`
98
+
99
+ 1. continue to the common section
100
+
101
+ ### Common setup steps
102
+
103
+ 1. In the auth admin site edit `Auth Reports Configuration` to your liking.
104
+ 1. set your states to include in reports as a minimum.
105
+ 1. add permissions to the parties you wish to be able to use reports. permisions are defined below.
106
+
107
+ ## Screenshots
108
+
109
+ ![Imgur](https://i.imgur.com/FhCpfMC.png)
110
+
111
+ ![Imgur](https://i.imgur.com/MCV0zWX.png)
112
+
113
+ ## Permissions
114
+
115
+ There are some basic access perms
116
+
117
+ 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.
118
+
119
+ | Perm | Admin Site | Perm | Description |
120
+ | ------------------ | ---------- | ------------------------------------------- | -------------------------------------------------------------------- |
121
+ | basic_access | nill | Can access reports module | Shows the Auth Reports module in the menu and gives access to the UI |
122
+ | own_corp | nill | Can access own corporations reports. | |
123
+ | own_alliance | nill | Can access own alliances reports. | |
124
+ | own_state | nill | Can access own states reports. | |
125
+ | restricted_reports | nill | Can access restricted reports. | Allows access to any report with restricted enabled |
126
+ | holding_corps | nill | Can access configured holding corp reports. | Allows access to holding corporation reports |
127
+
128
+ Note: Configure the "Holding Corps" in the `Auth Reports Configuration` Admin Model. via the auth admin interface.
129
+
130
+ ## Contributing
131
+
132
+ 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.
133
+
@@ -0,0 +1,98 @@
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 any data
8
+ - each "field" is a smart filter similar to secure groups ( can use secure groups filters too ) or a "field only" filter provided by any application in the alliance auth ecosystem.
9
+ - These filters MUST be the more "modern" kind with either a `process_field` or `audit_filter` methods. Legacy filters using only `process_filter` will not show any data. [Please see this link for more info](https://github.com/Solar-Helix-Independent-Transport/allianceauth-secure-groups/blob/main/THRID_PARTY.md)
10
+ - Data Exportable to CSV for external manipulation.
11
+
12
+ ## What it needs:
13
+
14
+ - require corporate member tokens to build the corp groups to see people not known to auth, to make a report for that too. these can be added with the plus button in the menubar
15
+
16
+ ## The General Road Map
17
+
18
+ if you want some features, please create an issue.
19
+
20
+ - state level report that shows all members of a state
21
+ - group reports for group leaders
22
+ - overview screen with passing/failing per corp per "report" ( maybe have this as optional aka "show_on_global_overview_report" )
23
+ - more things...
24
+
25
+ ## Filters/stats provided by this app
26
+
27
+ - show all alts for a main, with option to only show in corp alts
28
+
29
+ ## Other Apps with filters
30
+
31
+ - [Corptools](https://github.com/Solar-Helix-Independent-Transport/allianceauth-corp-tools?tab=readme-ov-file#corptools)
32
+ - [Member Audit Smart Filters](https://github.com/ppfeufer/aa-ma-securegroups)
33
+ - [Secure Groups](https://github.com/Solar-Helix-Independent-Transport/allianceauth-secure-groups)
34
+ - [Secret Santa](https://gitlab.com/tactical-supremacy/aa-secret-santa)
35
+ - [Discord Multiverse](https://github.com/Solar-Helix-Independent-Transport/allianceauth-discord-multiverse)
36
+ - [Invoices](https://github.com/Solar-Helix-Independent-Transport/allianceauth-invoice-manager)
37
+
38
+ ... more send a PR in with updates
39
+
40
+ ## Installation
41
+
42
+ ### Bare Metal
43
+
44
+ 1. `pip install -U allianceauth-auth-stats`
45
+ 1. add `'authstats',` to your local.py
46
+ 1. migrate `python manage.py migrate`
47
+ 1. collectstatic `python manage.py collectstatic --noinput`
48
+ 1. sync commands `python manage.py reports_sync_filters`
49
+ 1. create your first report `python manage.py reports_bootstrap_report`
50
+ 1. restart auth
51
+ 1. continue to the common section
52
+
53
+ ### Docker
54
+
55
+ 1. add `allianceauth-auth-stats==0.0.1` (update version number as required) to your requirements.txt file and rebuild your containers `docker compose build --no-cache`
56
+ 1. add `'authstats',` to your local.py
57
+ 1. recreate you docker stack `docker compose up -d`
58
+ 1. enter your auth container and run migrations and collect static and sync filters `docker compose exec alliancauth_gunicorn bash`
59
+
60
+ - `auth collectstatic`
61
+ - `auth migrate`
62
+ - `auth reports_sync_filters`
63
+ - `auth reports_bootstrap_report`
64
+
65
+ 1. continue to the common section
66
+
67
+ ### Common setup steps
68
+
69
+ 1. In the auth admin site edit `Auth Reports Configuration` to your liking.
70
+ 1. set your states to include in reports as a minimum.
71
+ 1. add permissions to the parties you wish to be able to use reports. permisions are defined below.
72
+
73
+ ## Screenshots
74
+
75
+ ![Imgur](https://i.imgur.com/FhCpfMC.png)
76
+
77
+ ![Imgur](https://i.imgur.com/MCV0zWX.png)
78
+
79
+ ## Permissions
80
+
81
+ There are some basic access perms
82
+
83
+ 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.
84
+
85
+ | Perm | Admin Site | Perm | Description |
86
+ | ------------------ | ---------- | ------------------------------------------- | -------------------------------------------------------------------- |
87
+ | basic_access | nill | Can access reports module | Shows the Auth Reports module in the menu and gives access to the UI |
88
+ | own_corp | nill | Can access own corporations reports. | |
89
+ | own_alliance | nill | Can access own alliances reports. | |
90
+ | own_state | nill | Can access own states reports. | |
91
+ | restricted_reports | nill | Can access restricted reports. | Allows access to any report with restricted enabled |
92
+ | holding_corps | nill | Can access configured holding corp reports. | Allows access to holding corporation reports |
93
+
94
+ Note: Configure the "Holding Corps" in the `Auth Reports Configuration` Admin Model. via the auth admin interface.
95
+
96
+ ## Contributing
97
+
98
+ 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,5 @@
1
+ """
2
+ Configurable Report Framework for corporate level aggregation of any data
3
+ """
4
+ __version__ = "0.0.1"
5
+ __title__ = "AuthStats"
@@ -0,0 +1,26 @@
1
+ from solo.admin import SingletonModelAdmin
2
+
3
+ from django.contrib import admin
4
+ from django.utils.html import format_html
5
+
6
+ from .models import (
7
+ AuthReportsConfiguration, Report, ReportDataSource, ReportDataThrough,
8
+ ReportFieldAlts,
9
+ )
10
+
11
+
12
+ class ReportDataFieldThroughAdmin(admin.StackedInline):
13
+ model = ReportDataThrough
14
+
15
+
16
+ @admin.register(Report)
17
+ class ReportAdmin(admin.ModelAdmin):
18
+ inlines = [
19
+ ReportDataFieldThroughAdmin,
20
+ ]
21
+
22
+
23
+ admin.site.register(ReportDataSource)
24
+ admin.site.register(ReportFieldAlts)
25
+
26
+ admin.site.register(AuthReportsConfiguration, SingletonModelAdmin)
@@ -0,0 +1,143 @@
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 ninja import Field, NinjaAPI, Schema
9
+ from ninja.pagination import LimitOffsetPagination
10
+ from ninja.security import django_auth
11
+ from ninja.types import DictStrAny
12
+
13
+ from django.contrib.auth.models import User
14
+ from django.db.models import QuerySet
15
+ from django.utils import timezone
16
+
17
+ from allianceauth.eveonline.models import EveCharacter, EveCorporationInfo
18
+ from esi.models import Token
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
+ }
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_perm("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
+ "data": False,
77
+ "members": 0,
78
+ "unknowns": 0}
79
+
80
+
81
+ @api.get(
82
+ "/get_corps",
83
+ response={200: List[schema.Corporation]},
84
+ tags=["Report"]
85
+ )
86
+ def get_corps(request):
87
+ return AuthReportsConfiguration.get_solo().visible_corps_for_user(request.user)
88
+
89
+
90
+ @api.get(
91
+ "/get_reports",
92
+ response={200: List[schema.Report], 403: str},
93
+ tags=["Report"]
94
+ )
95
+ def get_reports(request):
96
+ if not request.user.has_perm("authstats.basic_access"):
97
+ return 403, f"Access Denied to get_reports for {request.user}"
98
+
99
+ _reports = Report.objects.all()
100
+ if not request.user.has_perm("authstats.restricted_reports"):
101
+ _reports = _reports.filter(restricted=False)
102
+ return _reports
103
+
104
+
105
+ @api.get(
106
+ "/get_unknowns/{corp_id}",
107
+ response={200: dict, 403: str},
108
+ tags=["Report"]
109
+ )
110
+ def get_orphans_for_corp(request, corp_id: int):
111
+ if not AuthReportsConfiguration.get_solo().visible_corps_for_user(request.user).filter(corporation_id=corp_id).exists():
112
+ return 403, f"Access Denied to get_orphans_for_corp for {request.user}"
113
+
114
+ corp = EveCorporationInfo.objects.get(corporation_id=corp_id)
115
+
116
+ mains = User.objects.filter(
117
+ profile__main_character__corporation_id=corp_id)
118
+
119
+ known_character_ids = EveCharacter.objects.filter(
120
+ corporation_id=corp_id, character_ownership__isnull=False).values_list("character_id", flat=True)
121
+ names = []
122
+ try:
123
+ scopes = "esi-corporations.read_corporation_membership.v1"
124
+ token = Token.objects.filter(
125
+ character_id__in=EveCharacter.objects.filter(
126
+ corporation_id=corp_id).values('character_id')).require_scopes(scopes)
127
+ if not token.exists():
128
+ raise Exception("No Tokens")
129
+ unknown_member_list = set(providers.esi.client.Corporation.get_corporations_corporation_id_members(
130
+ corporation_id=corp_id, token=token.first().valid_access_token()).results())
131
+ for m in known_character_ids:
132
+ try:
133
+ unknown_member_list.remove(m)
134
+ except KeyError:
135
+ pass
136
+ names = providers.esi.client.Universe.post_universe_names(
137
+ ids=list(unknown_member_list)).results()
138
+ except Exception as e:
139
+ logger.exception(e)
140
+
141
+ return {"report": {"name": "Orphan Characters",
142
+ "corporation": corp.corporation_name},
143
+ "members": mains.count(), "data": names}
@@ -0,0 +1,3 @@
1
+ from django.conf import settings
2
+
3
+ AUTHSTATS_APP_NAME = getattr(settings, "AUTHSTATS_APP_NAME", "Auth Reports")
@@ -0,0 +1,13 @@
1
+ from django.apps import AppConfig
2
+
3
+ from . import __version__
4
+
5
+
6
+ class AuthStatsConfig(AppConfig):
7
+ name = 'authstats'
8
+ label = 'authstats'
9
+
10
+ verbose_name = f"Auth Reports v{__version__}"
11
+
12
+ def ready(self):
13
+ import authstats.signals
@@ -0,0 +1,41 @@
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 app_settings, models, urls
7
+
8
+
9
+ class AuthStats(MenuItemHook):
10
+ def __init__(self):
11
+
12
+ MenuItemHook.__init__(self,
13
+ app_settings.AUTHSTATS_APP_NAME,
14
+ 'fas fa-book-open',
15
+ 'authstats:base',
16
+ navactive=['authstats:'])
17
+
18
+ def render(self, request):
19
+ if request.user.has_perm('authstats.basic_access'):
20
+ return MenuItemHook.render(self, request)
21
+ return ''
22
+
23
+
24
+ @hooks.register('menu_item_hook')
25
+ def register_menu():
26
+ return AuthStats()
27
+
28
+
29
+ @hooks.register('url_hook')
30
+ def register_url():
31
+ return UrlHook(urls, 'authstats', r'^reports/')
32
+
33
+
34
+ @hooks.register("secure_group_filters")
35
+ def filters():
36
+ return [models.ReportFieldAlts]
37
+
38
+
39
+ @hooks.register('discord_cogs_hook')
40
+ def register_cogs():
41
+ return []
@@ -0,0 +1,39 @@
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
+ #, fuzzy
7
+ msgid ""
8
+ msgstr ""
9
+ "Project-Id-Version: PACKAGE VERSION\n"
10
+ "Report-Msgid-Bugs-To: \n"
11
+ "POT-Creation-Date: 2024-08-30 13:30+1000\n"
12
+ "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
13
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
14
+ "Language-Team: LANGUAGE <LL@li.org>\n"
15
+ "Language: \n"
16
+ "MIME-Version: 1.0\n"
17
+ "Content-Type: text/plain; charset=UTF-8\n"
18
+ "Content-Transfer-Encoding: 8bit\n"
19
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
20
+
21
+ #: authstats/templates/authstats/react_base.html:176
22
+ msgid "Loading Page"
23
+ msgstr ""
24
+
25
+ #: authstats/templates/authstats/react_base.html:177
26
+ msgid "Please Wait"
27
+ msgstr ""
28
+
29
+ #: authstats/templates/authstats/react_base.html:195
30
+ msgid "Error Loading JavaScript"
31
+ msgstr ""
32
+
33
+ #: authstats/templates/authstats/react_base.html:196
34
+ msgid "Check Browser Console for Logs"
35
+ msgstr ""
36
+
37
+ #: authstats/validators.py:12
38
+ msgid "This is not valid JSON, please check it and try again."
39
+ msgstr ""
@@ -0,0 +1,30 @@
1
+ from django.core.management.base import BaseCommand
2
+
3
+ from ...models import (
4
+ Report, ReportDataSource, ReportDataThrough, ReportFieldAlts,
5
+ )
6
+
7
+
8
+ class Command(BaseCommand):
9
+ help = 'Create a Basic Report'
10
+
11
+ def handle(self, *args, **options):
12
+ self.stdout.write("Creating Basic Report")
13
+ alts_filed = ReportFieldAlts.objects.create(
14
+ name="Alts - Field",
15
+ description="Alts"
16
+ )
17
+ data_source = ReportDataSource.objects.all().last()
18
+ self.stdout.write(f"Adding `{data_source}` to report")
19
+ report = Report.objects.create(
20
+ name="Corporation Member Alts",
21
+ )
22
+ through_field = ReportDataThrough.objects.create(
23
+ report=report,
24
+ report_Data_source=data_source,
25
+ rank=5,
26
+ header="Alts",
27
+ long_descriptions="All known alts on this account.",
28
+ allow_sort=False
29
+ )
30
+ self.stdout.write(f"`Corporation Member Alts` report created.")
@@ -0,0 +1,16 @@
1
+
2
+ from django.core.management.base import BaseCommand
3
+
4
+ from ...models import ReportResults
5
+ from ...tasks import run_report_for_corp
6
+
7
+
8
+ class Command(BaseCommand):
9
+ help = 'refresh all a reports'
10
+
11
+ def handle(self, *args, **options):
12
+ for rep in ReportResults.objects.all():
13
+ self.stdout.write(
14
+ f"Refreshing Report: Corp:{rep.corporation} Report:{rep.report.name}")
15
+ run_report_for_corp.delay(
16
+ 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)
@@ -0,0 +1,8 @@
1
+ import logging
2
+
3
+ from django.core.exceptions import ObjectDoesNotExist
4
+ from django.db import models
5
+
6
+ from allianceauth.eveonline.models import EveCorporationInfo
7
+
8
+ logger = logging.getLogger(__name__)