aa-fleetfinder 2.2.1__py3-none-any.whl → 2.3.0__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.

Files changed (33) hide show
  1. {aa_fleetfinder-2.2.1.dist-info → aa_fleetfinder-2.3.0.dist-info}/METADATA +5 -4
  2. {aa_fleetfinder-2.2.1.dist-info → aa_fleetfinder-2.3.0.dist-info}/RECORD +33 -31
  3. {aa_fleetfinder-2.2.1.dist-info → aa_fleetfinder-2.3.0.dist-info}/WHEEL +1 -1
  4. fleetfinder/__init__.py +1 -1
  5. fleetfinder/constants.py +13 -6
  6. fleetfinder/helper/__init__.py +0 -0
  7. fleetfinder/helper/static_files.py +39 -0
  8. fleetfinder/locale/cs_CZ/LC_MESSAGES/django.po +26 -36
  9. fleetfinder/locale/de/LC_MESSAGES/django.po +28 -44
  10. fleetfinder/locale/django.pot +19 -19
  11. fleetfinder/locale/es/LC_MESSAGES/django.mo +0 -0
  12. fleetfinder/locale/es/LC_MESSAGES/django.po +31 -45
  13. fleetfinder/locale/fr_FR/LC_MESSAGES/django.mo +0 -0
  14. fleetfinder/locale/fr_FR/LC_MESSAGES/django.po +33 -43
  15. fleetfinder/locale/it_IT/LC_MESSAGES/django.mo +0 -0
  16. fleetfinder/locale/it_IT/LC_MESSAGES/django.po +29 -35
  17. fleetfinder/locale/ja/LC_MESSAGES/django.po +24 -31
  18. fleetfinder/locale/ko_KR/LC_MESSAGES/django.po +25 -34
  19. fleetfinder/locale/nl_NL/LC_MESSAGES/django.po +24 -31
  20. fleetfinder/locale/pl_PL/LC_MESSAGES/django.po +26 -36
  21. fleetfinder/locale/ru/LC_MESSAGES/django.po +28 -41
  22. fleetfinder/locale/sk/LC_MESSAGES/django.po +25 -33
  23. fleetfinder/locale/uk/LC_MESSAGES/django.po +27 -38
  24. fleetfinder/locale/zh_Hans/LC_MESSAGES/django.po +25 -34
  25. fleetfinder/templates/fleetfinder/bundles/css/fleetfinder-css.html +1 -1
  26. fleetfinder/templates/fleetfinder/bundles/css/slim-select-css.html +2 -2
  27. fleetfinder/templates/fleetfinder/bundles/js/slim-select-js.html +2 -2
  28. fleetfinder/templates/fleetfinder/dashboard.html +25 -17
  29. fleetfinder/templates/fleetfinder/fleet-details.html +40 -25
  30. fleetfinder/templatetags/fleetfinder.py +57 -9
  31. fleetfinder/tests/test_templatetags.py +12 -6
  32. fleetfinder/urls.py +8 -6
  33. {aa_fleetfinder-2.2.1.dist-info → aa_fleetfinder-2.3.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,3 +1,3 @@
1
- {% load static %}
1
+ {% load fleetfinder %}
2
2
 
3
- <link rel="stylesheet" href="{% static 'fleetfinder/libs/slim-select/2.6.0/css/slimselect.min.css' %}">
3
+ {% fleetfinder_static "libs/slim-select/2.6.0/css/slimselect.min.css" %}
@@ -1,3 +1,3 @@
1
- {% load static %}
1
+ {% load fleetfinder %}
2
2
 
3
- <script src="{% static 'fleetfinder/libs/slim-select/2.6.0/js/slimselect.min.js' %}"></script>
3
+ {% fleetfinder_static "libs/slim-select/2.6.0/js/slimselect.min.js" %}
@@ -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 aa_fleetfinder_body %}
@@ -11,23 +12,25 @@
11
12
  </div>
12
13
 
13
14
  <div class="card-body">
14
- <table class="table table-striped table-hover table-vertical-middle" id="table_available-fleets" style="width: 100%;">
15
- <thead>
16
- <tr>
17
- <th>{% translate "Fleet commander" %}</th>
18
- <th>{% translate "Fleet name" %}</th>
19
- <th>{% translate "Created at" %}</th>
20
- <th>{% translate "Join" %}</th>
21
-
22
- {% if perms.fleetfinder.manage_fleets %}
23
- <th>{% translate "Details" %}</th>
24
- <th>{% translate "Edit" %}</th>
25
- {% endif %}
26
- </tr>
27
- </thead>
28
-
29
- <tbody></tbody>
30
- </table>
15
+ <div class="table-responsive">
16
+ <table class="table table-striped table-hover table-vertical-middle" id="table_available-fleets" style="width: 100%;">
17
+ <thead>
18
+ <tr>
19
+ <th>{% translate "Fleet commander" %}</th>
20
+ <th>{% translate "Fleet name" %}</th>
21
+ <th>{% translate "Created at" %}</th>
22
+ <th>{% translate "Join" %}</th>
23
+
24
+ {% if perms.fleetfinder.manage_fleets %}
25
+ <th>{% translate "Details" %}</th>
26
+ <th>{% translate "Edit" %}</th>
27
+ {% endif %}
28
+ </tr>
29
+ </thead>
30
+
31
+ <tbody></tbody>
32
+ </table>
33
+ </div>
31
34
  </div>
32
35
  </div>
33
36
  {% endblock %}
@@ -41,12 +44,17 @@
41
44
  {% include "bundles/datatables-js-bs5.html" %}
42
45
  {% include "bundles/moment-js.html" with locale=True %}
43
46
 
47
+ {% get_datatables_language_static LANGUAGE_CODE as DT_LANG_PATH %}
48
+
44
49
  <script>
45
50
  $(document).ready(() => {
46
51
  const DATETIME_FORMAT = 'YYYY-MM-DD, HH:mm';
47
52
  const table_fleet_overview = $('#table_available-fleets');
48
53
 
49
54
  const fleetfinderFleetsTable = table_fleet_overview.DataTable({
55
+ language: {
56
+ url: '{{ DT_LANG_PATH }}'
57
+ },
50
58
  ajax: {
51
59
  url: "{% url 'fleetfinder:ajax_dashboard' %}",
52
60
  dataSrc: '',
@@ -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
- <table class="table table-striped table-hover table-vertical-middle" id="table_fleet_composition" style="width: 100%;">
21
- <thead>
22
- <tr>
23
- <th>{% translate "Ship class" %}</th>
24
- <th>{% translate "Count" %}</th>
25
- </tr>
26
- </thead>
27
-
28
- <tbody></tbody>
29
- </table>
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
- <table class="table table-striped table-hover table-vertical-middle" id="table_fleet_members" style="width: 100%;">
44
- <thead>
45
- <tr>
46
- <th>{% translate "Name" %}</th>
47
- <th>{% translate "Ship class" %}</th>
48
- <th>{% translate "System" %}</th>
49
- </tr>
50
- </thead>
51
-
52
- <tbody></tbody>
53
- </table>
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
- emptyTable: 'No data / loading ...'
102
- }
114
+ url: '{{ DT_LANG_PATH }}'
115
+ },
116
+ paging: false,
103
117
  });
104
118
 
105
119
  tabe_fleet_composition.DataTable({
106
120
  language: {
107
- emptyTable: 'No data / loading ...'
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(path: str) -> str:
27
+ def fleetfinder_static(relative_file_path: str) -> str | None:
15
28
  """
16
29
  Versioned static URL
17
- :param path:
18
- :type path:
19
- :return:
20
- :rtype:
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
- static_url = static(path)
24
- versioned_url = static_url + "?v=" + __version__
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 versioned_url
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 a versioned static
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 'fleetfinder/css/fleetfinder.min.css' %}"
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
- self.assertInHTML(
37
- needle=f'/static/fleetfinder/css/fleetfinder.min.css?v={context["version"]}',
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="join/<int:fleet_id>/", view=views.join_fleet, name="join_fleet"),
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="details/<int:fleet_id>/", view=views.fleet_details, name="fleet_details"
19
+ route="fleet/<int:fleet_id>/details/",
20
+ view=views.fleet_details,
21
+ name="fleet_details",
20
22
  ),
21
- path(route="edit/<int:fleet_id>/", view=views.edit_fleet, name="edit_fleet"),
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="details/<int:fleet_id>/",
33
+ route="fleet/<int:fleet_id>/details/",
32
34
  view=views.ajax_fleet_details,
33
35
  name="ajax_fleet_details",
34
36
  ),