aa-fleetfinder 2.2.2__py3-none-any.whl → 2.3.1__py3-none-any.whl
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.
Potentially problematic release.
This version of aa-fleetfinder might be problematic. Click here for more details.
- {aa_fleetfinder-2.2.2.dist-info → aa_fleetfinder-2.3.1.dist-info}/METADATA +4 -3
- {aa_fleetfinder-2.2.2.dist-info → aa_fleetfinder-2.3.1.dist-info}/RECORD +31 -29
- {aa_fleetfinder-2.2.2.dist-info → aa_fleetfinder-2.3.1.dist-info}/WHEEL +1 -1
- fleetfinder/__init__.py +1 -1
- fleetfinder/constants.py +13 -6
- fleetfinder/helper/__init__.py +0 -0
- fleetfinder/helper/static_files.py +39 -0
- fleetfinder/locale/cs_CZ/LC_MESSAGES/django.po +24 -34
- fleetfinder/locale/de/LC_MESSAGES/django.po +26 -42
- fleetfinder/locale/django.pot +17 -17
- fleetfinder/locale/es/LC_MESSAGES/django.po +26 -40
- fleetfinder/locale/fr_FR/LC_MESSAGES/django.po +24 -35
- fleetfinder/locale/it_IT/LC_MESSAGES/django.mo +0 -0
- fleetfinder/locale/it_IT/LC_MESSAGES/django.po +25 -32
- fleetfinder/locale/ja/LC_MESSAGES/django.po +22 -29
- fleetfinder/locale/ko_KR/LC_MESSAGES/django.po +23 -32
- fleetfinder/locale/nl_NL/LC_MESSAGES/django.po +22 -29
- fleetfinder/locale/pl_PL/LC_MESSAGES/django.po +24 -34
- fleetfinder/locale/ru/LC_MESSAGES/django.po +26 -39
- fleetfinder/locale/sk/LC_MESSAGES/django.po +23 -31
- fleetfinder/locale/uk/LC_MESSAGES/django.po +25 -36
- fleetfinder/locale/zh_Hans/LC_MESSAGES/django.po +23 -32
- fleetfinder/templates/fleetfinder/bundles/css/fleetfinder-css.html +1 -1
- fleetfinder/templates/fleetfinder/bundles/css/slim-select-css.html +2 -2
- fleetfinder/templates/fleetfinder/bundles/js/slim-select-js.html +2 -2
- fleetfinder/templates/fleetfinder/dashboard.html +25 -17
- fleetfinder/templates/fleetfinder/fleet-details.html +40 -25
- fleetfinder/templatetags/fleetfinder.py +57 -9
- fleetfinder/tests/test_templatetags.py +12 -6
- fleetfinder/urls.py +8 -6
- {aa_fleetfinder-2.2.2.dist-info → aa_fleetfinder-2.3.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{% extends "fleetfinder/base.html" %}
|
|
2
2
|
|
|
3
|
+
{% load aa_i18n %}
|
|
3
4
|
{% load i18n %}
|
|
4
5
|
|
|
5
6
|
{% block page_title %}
|
|
@@ -17,16 +18,18 @@
|
|
|
17
18
|
</div>
|
|
18
19
|
|
|
19
20
|
<div class="card-body">
|
|
20
|
-
<
|
|
21
|
-
<
|
|
22
|
-
<
|
|
23
|
-
<
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
21
|
+
<div class="table-responsive">
|
|
22
|
+
<table class="table table-striped table-hover table-vertical-middle w-100" id="table_fleet_composition">
|
|
23
|
+
<thead>
|
|
24
|
+
<tr>
|
|
25
|
+
<th>{% translate "Ship class" %}</th>
|
|
26
|
+
<th>{% translate "Count" %}</th>
|
|
27
|
+
</tr>
|
|
28
|
+
</thead>
|
|
29
|
+
|
|
30
|
+
<tbody></tbody>
|
|
31
|
+
</table>
|
|
32
|
+
</div>
|
|
30
33
|
</div>
|
|
31
34
|
</div>
|
|
32
35
|
</div>
|
|
@@ -40,17 +43,19 @@
|
|
|
40
43
|
</div>
|
|
41
44
|
|
|
42
45
|
<div class="card-body">
|
|
43
|
-
<
|
|
44
|
-
<
|
|
45
|
-
<
|
|
46
|
-
<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
46
|
+
<div class="table-responsive">
|
|
47
|
+
<table class="table table-striped table-hover table-vertical-middle w-100" id="table_fleet_members">
|
|
48
|
+
<thead>
|
|
49
|
+
<tr>
|
|
50
|
+
<th>{% translate "Name" %}</th>
|
|
51
|
+
<th>{% translate "Ship class" %}</th>
|
|
52
|
+
<th>{% translate "System" %}</th>
|
|
53
|
+
</tr>
|
|
54
|
+
</thead>
|
|
55
|
+
|
|
56
|
+
<tbody></tbody>
|
|
57
|
+
</table>
|
|
58
|
+
</div>
|
|
54
59
|
</div>
|
|
55
60
|
</div>
|
|
56
61
|
</div>
|
|
@@ -65,6 +70,8 @@
|
|
|
65
70
|
{% block extra_javascript %}
|
|
66
71
|
{% include "bundles/datatables-js-bs5.html" %}
|
|
67
72
|
|
|
73
|
+
{% get_datatables_language_static LANGUAGE_CODE as DT_LANG_PATH %}
|
|
74
|
+
|
|
68
75
|
<script>
|
|
69
76
|
$(document).ready(() => {
|
|
70
77
|
const table_fleet_members = $('#table_fleet_members');
|
|
@@ -73,6 +80,9 @@
|
|
|
73
80
|
const populateDatatables = () => {
|
|
74
81
|
$.get('{% url "fleetfinder:ajax_fleet_details" fleet_id %}', (data) => {
|
|
75
82
|
table_fleet_members.DataTable({
|
|
83
|
+
language: {
|
|
84
|
+
url: '{{ DT_LANG_PATH }}'
|
|
85
|
+
},
|
|
76
86
|
destroy: true,
|
|
77
87
|
paging: false,
|
|
78
88
|
data: data.fleet_member,
|
|
@@ -84,6 +94,9 @@
|
|
|
84
94
|
});
|
|
85
95
|
|
|
86
96
|
tabe_fleet_composition.DataTable({
|
|
97
|
+
language: {
|
|
98
|
+
url: '{{ DT_LANG_PATH }}'
|
|
99
|
+
},
|
|
87
100
|
destroy: true,
|
|
88
101
|
paging: false,
|
|
89
102
|
data: data.fleet_composition,
|
|
@@ -98,14 +111,16 @@
|
|
|
98
111
|
|
|
99
112
|
table_fleet_members.DataTable({
|
|
100
113
|
language: {
|
|
101
|
-
|
|
102
|
-
}
|
|
114
|
+
url: '{{ DT_LANG_PATH }}'
|
|
115
|
+
},
|
|
116
|
+
paging: false,
|
|
103
117
|
});
|
|
104
118
|
|
|
105
119
|
tabe_fleet_composition.DataTable({
|
|
106
120
|
language: {
|
|
107
|
-
|
|
108
|
-
}
|
|
121
|
+
url: '{{ DT_LANG_PATH }}'
|
|
122
|
+
},
|
|
123
|
+
paging: false,
|
|
109
124
|
});
|
|
110
125
|
|
|
111
126
|
populateDatatables();
|
|
@@ -2,25 +2,73 @@
|
|
|
2
2
|
Versioned static URLs to break browser caches when changing the app version
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
+
# Standard Library
|
|
6
|
+
import os
|
|
7
|
+
|
|
5
8
|
# Django
|
|
6
9
|
from django.template.defaulttags import register
|
|
7
10
|
from django.templatetags.static import static
|
|
11
|
+
from django.utils.safestring import mark_safe
|
|
12
|
+
|
|
13
|
+
# Alliance Auth
|
|
14
|
+
from allianceauth.services.hooks import get_extension_logger
|
|
15
|
+
|
|
16
|
+
# Alliance Auth (External Libs)
|
|
17
|
+
from app_utils.logging import LoggerAddTag
|
|
8
18
|
|
|
9
19
|
# AA Fleet Finder
|
|
10
|
-
from fleetfinder import __version__
|
|
20
|
+
from fleetfinder import __title__, __version__
|
|
21
|
+
from fleetfinder.helper.static_files import calculate_integrity_hash
|
|
22
|
+
|
|
23
|
+
logger = LoggerAddTag(my_logger=get_extension_logger(__name__), prefix=__title__)
|
|
11
24
|
|
|
12
25
|
|
|
13
26
|
@register.simple_tag
|
|
14
|
-
def fleetfinder_static(
|
|
27
|
+
def fleetfinder_static(relative_file_path: str) -> str | None:
|
|
15
28
|
"""
|
|
16
29
|
Versioned static URL
|
|
17
|
-
|
|
18
|
-
:
|
|
19
|
-
:
|
|
20
|
-
:
|
|
30
|
+
|
|
31
|
+
:param relative_file_path: The file path relative to the `aa-fleetfinder/fleetfinder/static/fleetfinder` folder
|
|
32
|
+
:type relative_file_path: str
|
|
33
|
+
:return: Versioned static URL
|
|
34
|
+
:rtype: str
|
|
21
35
|
"""
|
|
22
36
|
|
|
23
|
-
|
|
24
|
-
|
|
37
|
+
logger.debug(f"Getting versioned static URL for: {relative_file_path}")
|
|
38
|
+
|
|
39
|
+
file_type = os.path.splitext(relative_file_path)[1][1:]
|
|
40
|
+
|
|
41
|
+
logger.debug(f"File extension: {file_type}")
|
|
42
|
+
|
|
43
|
+
# Only support CSS and JS files
|
|
44
|
+
if file_type not in ["css", "js"]:
|
|
45
|
+
raise ValueError(f"Unsupported file type: {file_type}")
|
|
46
|
+
|
|
47
|
+
integrity_hash = calculate_integrity_hash(relative_file_path)
|
|
48
|
+
static_file_path = os.path.join("fleetfinder", relative_file_path)
|
|
49
|
+
static_url = static(static_file_path)
|
|
50
|
+
|
|
51
|
+
# Versioned URL for CSS and JS files
|
|
52
|
+
# Add version query parameter to break browser caches when changing the app version
|
|
53
|
+
# Do not add version query parameter for libs as they are already versioned through their file path
|
|
54
|
+
versioned_url = (
|
|
55
|
+
static_url
|
|
56
|
+
if relative_file_path.startswith("libs/")
|
|
57
|
+
else static_url + "?v=" + __version__
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
# Return the versioned URL with integrity hash for CSS
|
|
61
|
+
if file_type == "css":
|
|
62
|
+
logger.debug(f"Integrity hash for {relative_file_path}: {integrity_hash}")
|
|
63
|
+
|
|
64
|
+
return mark_safe(
|
|
65
|
+
f'<link rel="stylesheet" href="{versioned_url}" integrity="{integrity_hash}" crossorigin="anonymous">'
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
# Return the versioned URL with integrity hash for JS files
|
|
69
|
+
if file_type == "js":
|
|
70
|
+
return mark_safe(
|
|
71
|
+
f'<script src="{versioned_url}" integrity="{integrity_hash}" crossorigin="anonymous"></script>'
|
|
72
|
+
)
|
|
25
73
|
|
|
26
|
-
return
|
|
74
|
+
return None
|
|
@@ -8,16 +8,17 @@ from django.test import TestCase
|
|
|
8
8
|
|
|
9
9
|
# AA Fleet Finder
|
|
10
10
|
from fleetfinder import __version__
|
|
11
|
+
from fleetfinder.helper.static_files import calculate_integrity_hash
|
|
11
12
|
|
|
12
13
|
|
|
13
14
|
class TestVersionedStatic(TestCase):
|
|
14
15
|
"""
|
|
15
|
-
Test the fleetfinder_static template tag
|
|
16
|
+
Test the `fleetfinder_static` template tag
|
|
16
17
|
"""
|
|
17
18
|
|
|
18
19
|
def test_versioned_static(self):
|
|
19
20
|
"""
|
|
20
|
-
Test should return
|
|
21
|
+
Test should return the versioned static
|
|
21
22
|
|
|
22
23
|
:return:
|
|
23
24
|
:rtype:
|
|
@@ -27,13 +28,18 @@ class TestVersionedStatic(TestCase):
|
|
|
27
28
|
template_to_render = Template(
|
|
28
29
|
template_string=(
|
|
29
30
|
"{% load fleetfinder %}"
|
|
30
|
-
"{% fleetfinder_static '
|
|
31
|
+
"{% fleetfinder_static 'css/fleetfinder.min.css' %}"
|
|
31
32
|
)
|
|
32
33
|
)
|
|
33
34
|
|
|
34
35
|
rendered_template = template_to_render.render(context)
|
|
35
36
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
haystack=rendered_template,
|
|
37
|
+
expected_static_src = (
|
|
38
|
+
f'/static/fleetfinder/css/fleetfinder.min.css?v={context["version"]}'
|
|
39
39
|
)
|
|
40
|
+
expected_static_src_integrity = calculate_integrity_hash(
|
|
41
|
+
"css/fleetfinder.min.css"
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
self.assertIn(member=expected_static_src, container=rendered_template)
|
|
45
|
+
self.assertIn(member=expected_static_src_integrity, container=rendered_template)
|
fleetfinder/urls.py
CHANGED
|
@@ -12,13 +12,15 @@ app_name: str = "fleetfinder"
|
|
|
12
12
|
|
|
13
13
|
urlpatterns = [
|
|
14
14
|
path(route="", view=views.dashboard, name="dashboard"),
|
|
15
|
-
path(route="create/", view=views.create_fleet, name="create_fleet"),
|
|
16
|
-
path(route="save/", view=views.save_fleet, name="save_fleet"),
|
|
17
|
-
path(route="
|
|
15
|
+
path(route="fleet/create/", view=views.create_fleet, name="create_fleet"),
|
|
16
|
+
path(route="fleet/save/", view=views.save_fleet, name="save_fleet"),
|
|
17
|
+
path(route="fleet/<int:fleet_id>/join/", view=views.join_fleet, name="join_fleet"),
|
|
18
18
|
path(
|
|
19
|
-
route="
|
|
19
|
+
route="fleet/<int:fleet_id>/details/",
|
|
20
|
+
view=views.fleet_details,
|
|
21
|
+
name="fleet_details",
|
|
20
22
|
),
|
|
21
|
-
path(route="
|
|
23
|
+
path(route="fleet/<int:fleet_id>/edit/", view=views.edit_fleet, name="edit_fleet"),
|
|
22
24
|
# Ajax calls
|
|
23
25
|
path(
|
|
24
26
|
route="ajax/",
|
|
@@ -28,7 +30,7 @@ urlpatterns = [
|
|
|
28
30
|
route="dashboard/", view=views.ajax_dashboard, name="ajax_dashboard"
|
|
29
31
|
),
|
|
30
32
|
path(
|
|
31
|
-
route="
|
|
33
|
+
route="fleet/<int:fleet_id>/details/",
|
|
32
34
|
view=views.ajax_fleet_details,
|
|
33
35
|
name="ajax_fleet_details",
|
|
34
36
|
),
|
|
File without changes
|