aa-intel-tool 2.5.2__py3-none-any.whl → 2.6.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.
Files changed (65) hide show
  1. aa_intel_tool/__init__.py +1 -1
  2. aa_intel_tool/app_settings.py +16 -1
  3. aa_intel_tool/constants.py +13 -5
  4. aa_intel_tool/helper/static_files.py +42 -0
  5. aa_intel_tool/locale/cs_CZ/LC_MESSAGES/django.po +20 -109
  6. aa_intel_tool/locale/de/LC_MESSAGES/django.po +82 -128
  7. aa_intel_tool/locale/django.pot +11 -84
  8. aa_intel_tool/locale/es/LC_MESSAGES/django.po +23 -107
  9. aa_intel_tool/locale/fr_FR/LC_MESSAGES/django.po +83 -127
  10. aa_intel_tool/locale/it_IT/LC_MESSAGES/django.po +18 -104
  11. aa_intel_tool/locale/ja/LC_MESSAGES/django.po +18 -104
  12. aa_intel_tool/locale/ko_KR/LC_MESSAGES/django.po +78 -116
  13. aa_intel_tool/locale/nl_NL/LC_MESSAGES/django.po +18 -104
  14. aa_intel_tool/locale/pl_PL/LC_MESSAGES/django.po +20 -109
  15. aa_intel_tool/locale/ru/LC_MESSAGES/django.po +83 -130
  16. aa_intel_tool/locale/sk/LC_MESSAGES/django.po +19 -106
  17. aa_intel_tool/locale/uk/LC_MESSAGES/django.mo +0 -0
  18. aa_intel_tool/locale/uk/LC_MESSAGES/django.po +72 -116
  19. aa_intel_tool/locale/zh_Hans/LC_MESSAGES/django.mo +0 -0
  20. aa_intel_tool/locale/zh_Hans/LC_MESSAGES/django.po +27 -111
  21. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan-highlight.js +1 -0
  22. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan-highlight.min.js +1 -1
  23. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan-highlight.min.js.map +1 -1
  24. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan.js +7 -7
  25. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan.min.js +1 -1
  26. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-chatscan.min.js.map +1 -1
  27. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan-highlight.js +1 -0
  28. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan-highlight.min.js +1 -1
  29. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan-highlight.min.js.map +1 -1
  30. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan.js +18 -18
  31. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan.min.js +1 -1
  32. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-dscan.min.js.map +1 -1
  33. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition-highlight.js +28 -2
  34. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition-highlight.min.js +1 -1
  35. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition-highlight.min.js.map +1 -1
  36. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition.js +41 -8
  37. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition.min.js +1 -1
  38. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-fleetcomposition.min.js.map +1 -1
  39. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-scan-result-common.js +5 -5
  40. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-scan-result-common.min.js +1 -1
  41. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool-scan-result-common.min.js.map +1 -1
  42. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool.js +66 -2
  43. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool.min.js +1 -1
  44. aa_intel_tool/static/aa_intel_tool/javascript/aa-intel-tool.min.js.map +1 -1
  45. aa_intel_tool/templates/aa_intel_tool/base.html +32 -0
  46. aa_intel_tool/templates/aa_intel_tool/bundles/aa-intel-tool-chatscan-highlight-js.html +3 -0
  47. aa_intel_tool/templates/aa_intel_tool/bundles/aa-intel-tool-chatscan-js.html +6 -3
  48. aa_intel_tool/templates/aa_intel_tool/bundles/aa-intel-tool-css.html +1 -1
  49. aa_intel_tool/templates/aa_intel_tool/bundles/aa-intel-tool-dscan-highlight-js.html +3 -0
  50. aa_intel_tool/templates/aa_intel_tool/bundles/aa-intel-tool-dscan-js.html +4 -3
  51. aa_intel_tool/templates/aa_intel_tool/bundles/aa-intel-tool-fleetcomp-js.html +6 -5
  52. aa_intel_tool/templates/aa_intel_tool/bundles/aa-intel-tool-fleetcomposition-highlight-js.html +3 -0
  53. aa_intel_tool/templates/aa_intel_tool/bundles/aa-intel-tool-js.html +1 -1
  54. aa_intel_tool/templates/aa_intel_tool/bundles/aa-intel-tool-scan-result-common-js.html +3 -0
  55. aa_intel_tool/templates/aa_intel_tool/views/scan/chatlist.html +3 -3
  56. aa_intel_tool/templates/aa_intel_tool/views/scan/dscan.html +3 -3
  57. aa_intel_tool/templates/aa_intel_tool/views/scan/fleetcomp.html +3 -3
  58. aa_intel_tool/templatetags/aa_intel_tool.py +71 -9
  59. aa_intel_tool/tests/test_app_settings.py +30 -2
  60. aa_intel_tool/tests/test_templatetags.py +78 -12
  61. {aa_intel_tool-2.5.2.dist-info → aa_intel_tool-2.6.1.dist-info}/METADATA +7 -6
  62. {aa_intel_tool-2.5.2.dist-info → aa_intel_tool-2.6.1.dist-info}/RECORD +64 -60
  63. {aa_intel_tool-2.5.2.dist-info → aa_intel_tool-2.6.1.dist-info}/WHEEL +1 -1
  64. aa_intel_tool/templates/aa_intel_tool/bundles/aa-intel-tool-js-l10n.html +0 -46
  65. {aa_intel_tool-2.5.2.dist-info → aa_intel_tool-2.6.1.dist-info}/licenses/LICENSE +0 -0
@@ -1,6 +1,7 @@
1
1
  {% extends "allianceauth/base-bs5.html" %}
2
2
 
3
3
  {% load i18n %}
4
+ {% load aa_i18n %}
4
5
 
5
6
  {% block page_title %}
6
7
  {% translate "Intel Parser" %}
@@ -17,6 +18,37 @@
17
18
  </div>
18
19
 
19
20
  <div class="aa-intel-tool-body">
21
+ {% get_datatables_language_static LANGUAGE_CODE as DT_LANG_PATH %}
22
+
23
+ {% translate "Permalink successfully copied" as copyToClipboardSuccess %}
24
+ {% translate "Something went wrong. Nothing copied. Maybe your browser does not support this function." as copyToClipboardError %}
25
+ {% translate "Unaffiliated / No Alliance" as scanDataEmpty %}
26
+ {% translate "NPC Corp" as scanDataNpcCorp %}
27
+
28
+ <script>
29
+ const aaIntelToolJsSettingsDefaults = {
30
+ language: {
31
+ django: '{{ LANGUAGE_CODE }}',
32
+ dataTables: {url: '{{ DT_LANG_PATH }}'}
33
+ },
34
+ url: {},
35
+ translation: {
36
+ copyToClipboard: {
37
+ permalink: {
38
+ text: {
39
+ success: '{{ copyToClipboardSuccess|escapejs }}',
40
+ error: '{{ copyToClipboardError|escapejs }}'
41
+ }
42
+ }
43
+ },
44
+ scanData: {
45
+ empty: '{{ scanDataEmpty|escapejs }}',
46
+ npcCorp: '{{ scanDataNpcCorp|escapejs }}',
47
+ }
48
+ }
49
+ }
50
+ </script>
51
+
20
52
  {% block aa_intel_tool_body %}{% endblock %}
21
53
  </div>
22
54
 
@@ -0,0 +1,3 @@
1
+ {% load aa_intel_tool %}
2
+
3
+ {% aa_intel_tool_static "javascript/aa-intel-tool-chatscan-highlight.min.js" %}
@@ -1,5 +1,8 @@
1
1
  {% load aa_intel_tool %}
2
2
 
3
- <script src="{% aa_intel_tool_static 'aa_intel_tool/javascript/aa-intel-tool-scan-result-common.min.js' %}"></script>
4
- <script src="{% aa_intel_tool_static 'aa_intel_tool/javascript/aa-intel-tool-chatscan-highlight.min.js' %}"></script>
5
- <script src="{% aa_intel_tool_static 'aa_intel_tool/javascript/aa-intel-tool-chatscan.min.js' %}"></script>
3
+ {% if not common_already_loaded %}
4
+ {% include "aa_intel_tool/bundles/aa-intel-tool-scan-result-common-js.html" %}
5
+ {% include "aa_intel_tool/bundles/aa-intel-tool-chatscan-highlight-js.html" %}
6
+ {% endif %}
7
+
8
+ {% aa_intel_tool_static "javascript/aa-intel-tool-chatscan.min.js" %}
@@ -1,3 +1,3 @@
1
1
  {% load aa_intel_tool %}
2
2
 
3
- <link rel="stylesheet" href="{% aa_intel_tool_static 'aa_intel_tool/css/aa-intel-tool.min.css' %}">
3
+ {% aa_intel_tool_static "css/aa-intel-tool.min.css" %}
@@ -0,0 +1,3 @@
1
+ {% load aa_intel_tool %}
2
+
3
+ {% aa_intel_tool_static "javascript/aa-intel-tool-dscan-highlight.min.js" %}
@@ -1,5 +1,6 @@
1
1
  {% load aa_intel_tool %}
2
2
 
3
- <script src="{% aa_intel_tool_static 'aa_intel_tool/javascript/aa-intel-tool-scan-result-common.min.js' %}"></script>
4
- <script src="{% aa_intel_tool_static 'aa_intel_tool/javascript/aa-intel-tool-dscan-highlight.min.js' %}"></script>
5
- <script src="{% aa_intel_tool_static 'aa_intel_tool/javascript/aa-intel-tool-dscan.min.js' %}"></script>
3
+ {% include "aa_intel_tool/bundles/aa-intel-tool-scan-result-common-js.html" %}
4
+ {% include "aa_intel_tool/bundles/aa-intel-tool-dscan-highlight-js.html" %}
5
+
6
+ {% aa_intel_tool_static "javascript/aa-intel-tool-dscan.min.js" %}
@@ -1,10 +1,11 @@
1
1
  {% load aa_intel_tool %}
2
2
 
3
- <script src="{% aa_intel_tool_static 'aa_intel_tool/javascript/aa-intel-tool-scan-result-common.min.js' %}"></script>
4
- <script src="{% aa_intel_tool_static 'aa_intel_tool/javascript/aa-intel-tool-fleetcomposition-highlight.min.js' %}"></script>
5
- <script src="{% aa_intel_tool_static 'aa_intel_tool/javascript/aa-intel-tool-fleetcomposition.min.js' %}"></script>
3
+ {% include "aa_intel_tool/bundles/aa-intel-tool-scan-result-common-js.html" %}
4
+ {% include "aa_intel_tool/bundles/aa-intel-tool-fleetcomposition-highlight-js.html" %}
5
+
6
+ {% aa_intel_tool_static "javascript/aa-intel-tool-fleetcomposition.min.js" %}
6
7
 
7
8
  {% if app_settings.INTELTOOL_ENABLE_MODULE_CHATSCAN %}
8
- <script src="{% aa_intel_tool_static 'aa_intel_tool/javascript/aa-intel-tool-chatscan-highlight.min.js' %}"></script>
9
- <script src="{% aa_intel_tool_static 'aa_intel_tool/javascript/aa-intel-tool-chatscan.min.js' %}"></script>
9
+ {% include "aa_intel_tool/bundles/aa-intel-tool-chatscan-highlight-js.html" with common_already_loaded=True %}
10
+ {% include "aa_intel_tool/bundles/aa-intel-tool-chatscan-js.html" with common_already_loaded=True %}
10
11
  {% endif %}
@@ -0,0 +1,3 @@
1
+ {% load aa_intel_tool %}
2
+
3
+ {% aa_intel_tool_static "javascript/aa-intel-tool-fleetcomposition-highlight.min.js" %}
@@ -1,3 +1,3 @@
1
1
  {% load aa_intel_tool %}
2
2
 
3
- <script src="{% aa_intel_tool_static 'aa_intel_tool/javascript/aa-intel-tool.min.js' %}"></script>
3
+ {% aa_intel_tool_static "javascript/aa-intel-tool.min.js" %}
@@ -0,0 +1,3 @@
1
+ {% load aa_intel_tool %}
2
+
3
+ {% aa_intel_tool_static "javascript/aa-intel-tool-scan-result-common.min.js" %}
@@ -28,8 +28,8 @@
28
28
 
29
29
  {% block extra_javascript %}
30
30
  <script>
31
- const aaIntelToolJsOptions = {
32
- ajax: {
31
+ const aaIntelToolJsSettingsOverride = {
32
+ url: {
33
33
  getPilotList: '{% url "aa_intel_tool:ajax_get_scan_data" scan_hash scan_data_section.PILOTLIST.value %}',
34
34
  getCorporationList: '{% url "aa_intel_tool:ajax_get_scan_data" scan_hash scan_data_section.CORPORATIONLIST.value %}',
35
35
  getAllianceList: '{% url "aa_intel_tool:ajax_get_scan_data" scan_hash scan_data_section.ALLIANCELIST.value %}'
@@ -39,6 +39,6 @@
39
39
 
40
40
  {% include "bundles/datatables-js-bs5.html" %}
41
41
  {% include "bundles/clipboard-js.html" %}
42
- {% include "aa_intel_tool/bundles/aa-intel-tool-js-l10n.html" %}
42
+ {% include "aa_intel_tool/bundles/aa-intel-tool-js.html" %}
43
43
  {% include "aa_intel_tool/bundles/aa-intel-tool-chatscan-js.html" %}
44
44
  {% endblock extra_javascript %}
@@ -26,8 +26,8 @@
26
26
 
27
27
  {% block extra_javascript %}
28
28
  <script>
29
- const aaIntelToolJsOptions = {
30
- ajax: {
29
+ const aaIntelToolJsSettingsOverride = {
30
+ url: {
31
31
  getShipClassesAll: '{% url "aa_intel_tool:ajax_get_scan_data" scan_hash scan_data_section.SHIPLIST.value %}',
32
32
  getShipClassesOngrid: '{% url "aa_intel_tool:ajax_get_scan_data" scan_hash scan_data_section.SHIPLIST_ON_GRID.value %}',
33
33
  getShipClassesOffgrid: '{% url "aa_intel_tool:ajax_get_scan_data" scan_hash scan_data_section.SHIPLIST_OFF_GRID.value %}',
@@ -41,6 +41,6 @@
41
41
 
42
42
  {% include "bundles/datatables-js-bs5.html" %}
43
43
  {% include "bundles/clipboard-js.html" %}
44
- {% include "aa_intel_tool/bundles/aa-intel-tool-js-l10n.html" %}
44
+ {% include "aa_intel_tool/bundles/aa-intel-tool-js.html" %}
45
45
  {% include "aa_intel_tool/bundles/aa-intel-tool-dscan-js.html" %}
46
46
  {% endblock extra_javascript %}
@@ -28,8 +28,8 @@
28
28
 
29
29
  {% block extra_javascript %}
30
30
  <script>
31
- const aaIntelToolJsOptions = {
32
- ajax: {
31
+ const aaIntelToolJsSettingsOverride = {
32
+ url: {
33
33
  getShipClasses: '{% url "aa_intel_tool:ajax_get_scan_data" scan_hash scan_data_section.SHIPLIST.value %}',
34
34
  getShipTypes: '{% url "aa_intel_tool:ajax_get_scan_data" scan_hash scan_data_section.SHIPTYPES.value %}',
35
35
  getFleetComposition: '{% url "aa_intel_tool:ajax_get_scan_data" scan_hash scan_data_section.FLEETCOMPOSITION.value %}',
@@ -42,6 +42,6 @@
42
42
 
43
43
  {% include "bundles/datatables-js-bs5.html" %}
44
44
  {% include "bundles/clipboard-js.html" %}
45
- {% include "aa_intel_tool/bundles/aa-intel-tool-js-l10n.html" %}
45
+ {% include "aa_intel_tool/bundles/aa-intel-tool-js.html" %}
46
46
  {% include "aa_intel_tool/bundles/aa-intel-tool-fleetcomp-js.html" %}
47
47
  {% endblock extra_javascript %}
@@ -2,25 +2,87 @@
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 Intel Tool
10
- from aa_intel_tool import __version__
20
+ from aa_intel_tool import __title__, __version__
21
+ from aa_intel_tool.app_settings import debug_enabled
22
+ from aa_intel_tool.constants import PACKAGE_NAME
23
+ from aa_intel_tool.helper.static_files import calculate_integrity_hash
24
+
25
+ logger = LoggerAddTag(my_logger=get_extension_logger(__name__), prefix=__title__)
11
26
 
12
27
 
13
28
  @register.simple_tag
14
- def aa_intel_tool_static(path: str) -> str:
29
+ def aa_intel_tool_static(
30
+ relative_file_path: str, script_type: str = None
31
+ ) -> str | None:
15
32
  """
16
33
  Versioned static URL
17
- :param path:
18
- :type path:
19
- :return:
20
- :rtype:
34
+
35
+ :param relative_file_path: The file path relative to the `{APP_NAME}/{PACKAGE_NAME}/static/{PACKAGE_NAME}` folder
36
+ :type relative_file_path: str
37
+ :param script_type: The script type
38
+ :type script_type: str
39
+ :return: Versioned static URL
40
+ :rtype: str
21
41
  """
22
42
 
23
- static_url = static(path)
24
- versioned_url = static_url + "?v=" + __version__
43
+ logger.debug(f"Getting versioned static URL for: {relative_file_path}")
44
+
45
+ file_type = os.path.splitext(relative_file_path)[1][1:]
46
+
47
+ logger.debug(f"File extension: {file_type}")
48
+
49
+ # Only support CSS and JS files
50
+ if file_type not in ["css", "js"]:
51
+ raise ValueError(f"Unsupported file type: {file_type}")
52
+
53
+ static_file_path = os.path.join(PACKAGE_NAME, relative_file_path)
54
+ static_url = static(static_file_path)
55
+
56
+ # Integrity hash calculation only for non-debug mode
57
+ sri_string = (
58
+ f' integrity="{calculate_integrity_hash(relative_file_path)}" crossorigin="anonymous"'
59
+ if not debug_enabled()
60
+ else ""
61
+ )
62
+
63
+ # Versioned URL for CSS and JS files
64
+ # Add version query parameter to break browser caches when changing the app version
65
+ # Do not add version query parameter for libs as they are already versioned through their file path
66
+ versioned_url = (
67
+ static_url
68
+ if relative_file_path.startswith("libs/")
69
+ else static_url + "?v=" + __version__
70
+ )
71
+
72
+ return_value = None
73
+
74
+ # Return the versioned URL with integrity hash for CSS
75
+ if file_type == "css":
76
+ return_value = mark_safe(
77
+ f'<link rel="stylesheet" href="{versioned_url}"{sri_string}>'
78
+ )
79
+
80
+ # Return the versioned URL with integrity hash for JS files
81
+ if file_type == "js":
82
+ js_type = f' type="{script_type}"' if script_type else ""
83
+
84
+ return_value = mark_safe(
85
+ f'<script{js_type} src="{versioned_url}"{sri_string}></script>'
86
+ )
25
87
 
26
- return versioned_url
88
+ return return_value
@@ -6,10 +6,11 @@ Test the app settings in local.py
6
6
  from unittest import mock
7
7
 
8
8
  # Django
9
- from django.test import TestCase
9
+ from django.conf import settings
10
+ from django.test import TestCase, override_settings
10
11
 
11
12
  # AA Intel Tool
12
- from aa_intel_tool.app_settings import AppSettings
13
+ from aa_intel_tool.app_settings import AppSettings, debug_enabled
13
14
 
14
15
  SETTINGS_PATH = "aa_intel_tool.app_settings"
15
16
 
@@ -46,6 +47,7 @@ class TestAppSettings(TestCase):
46
47
 
47
48
  self.assertEqual(first=retention_time, second=expected_retention_time)
48
49
 
50
+ @override_settings()
49
51
  def test_chatscan_max_pilots_default(self):
50
52
  """
51
53
  Test for the default INTELTOOL_CHATSCAN_MAX_PILOTS
@@ -54,9 +56,13 @@ class TestAppSettings(TestCase):
54
56
  :rtype:
55
57
  """
56
58
 
59
+ del settings.INTELTOOL_CHATSCAN_MAX_PILOTS
60
+
57
61
  max_pilots = AppSettings.INTELTOOL_CHATSCAN_MAX_PILOTS
58
62
  expected_max_pilots = 500
59
63
 
64
+ print("max_pilots:", max_pilots)
65
+
60
66
  self.assertEqual(first=max_pilots, second=expected_max_pilots)
61
67
 
62
68
  @mock.patch(SETTINGS_PATH + ".AppSettings.INTELTOOL_CHATSCAN_MAX_PILOTS", 1000)
@@ -99,3 +105,25 @@ class TestAppSettings(TestCase):
99
105
  expected_grid_size = 1000
100
106
 
101
107
  self.assertEqual(first=grid_size, second=expected_grid_size)
108
+
109
+ @override_settings(DEBUG=True)
110
+ def test_debug_enabled_with_debug_true(self) -> None:
111
+ """
112
+ Test debug_enabled with DEBUG = True
113
+
114
+ :return:
115
+ :rtype:
116
+ """
117
+
118
+ self.assertTrue(debug_enabled())
119
+
120
+ @override_settings(DEBUG=False)
121
+ def test_debug_enabled_with_debug_false(self) -> None:
122
+ """
123
+ Test debug_enabled with DEBUG = False
124
+
125
+ :return:
126
+ :rtype:
127
+ """
128
+
129
+ self.assertFalse(debug_enabled())
@@ -3,35 +3,101 @@ Tests for the template tags
3
3
  """
4
4
 
5
5
  # Django
6
- from django.test import TestCase
6
+ from django.template import Context, Template
7
+ from django.test import TestCase, override_settings
7
8
 
8
9
  # AA Intel Tool
9
10
  from aa_intel_tool import __version__
10
- from aa_intel_tool.tests.utils import render_template
11
+ from aa_intel_tool.constants import PACKAGE_NAME
12
+ from aa_intel_tool.helper.static_files import calculate_integrity_hash
11
13
 
12
14
 
13
- class TestForumVersionedStatic(TestCase):
15
+ class TestVersionedStatic(TestCase):
14
16
  """
15
17
  Tests for aa_intel_tool template tag
16
18
  """
17
19
 
20
+ @override_settings(DEBUG=False)
18
21
  def test_versioned_static(self):
19
22
  """
20
23
  Test should return static URL string with a version
21
24
  :return:
22
25
  """
23
26
 
24
- context = {"version": __version__}
27
+ context = Context(dict_={"version": __version__})
25
28
 
26
- rendered_template = render_template(
27
- string=(
29
+ template_to_render = Template(
30
+ template_string=(
28
31
  "{% load aa_intel_tool %}"
29
- "{% aa_intel_tool_static 'aa_intel_tool/css/aa-intel-tool.min.css' %}"
30
- ),
31
- context=context,
32
+ "{% aa_intel_tool_static 'css/aa-intel-tool.min.css' %}"
33
+ "{% aa_intel_tool_static 'javascript/aa-intel-tool.min.js' %}"
34
+ )
32
35
  )
33
36
 
34
- self.assertEqual(
35
- rendered_template,
36
- f'/static/aa_intel_tool/css/aa-intel-tool.min.css?v={context["version"]}',
37
+ rendered_template = template_to_render.render(context=context)
38
+
39
+ expected_static_css_src = (
40
+ f'/static/{PACKAGE_NAME}/css/aa-intel-tool.min.css?v={context["version"]}'
41
+ )
42
+ expected_static_css_src_integrity = calculate_integrity_hash(
43
+ "css/aa-intel-tool.min.css"
44
+ )
45
+ expected_static_js_src = f'/static/{PACKAGE_NAME}/javascript/aa-intel-tool.min.js?v={context["version"]}'
46
+ expected_static_js_src_integrity = calculate_integrity_hash(
47
+ "javascript/aa-intel-tool.min.js"
48
+ )
49
+
50
+ self.assertIn(member=expected_static_css_src, container=rendered_template)
51
+ self.assertIn(
52
+ member=expected_static_css_src_integrity, container=rendered_template
53
+ )
54
+ self.assertIn(member=expected_static_js_src, container=rendered_template)
55
+ self.assertIn(
56
+ member=expected_static_js_src_integrity, container=rendered_template
57
+ )
58
+
59
+ @override_settings(DEBUG=True)
60
+ def test_versioned_static_with_debug_enabled(self) -> None:
61
+ """
62
+ Test versioned static template tag with DEBUG enabled
63
+
64
+ :return:
65
+ :rtype:
66
+ """
67
+
68
+ context = Context({"version": __version__})
69
+ template_to_render = Template(
70
+ template_string=(
71
+ "{% load aa_intel_tool %}"
72
+ "{% aa_intel_tool_static 'css/aa-intel-tool.min.css' %}"
73
+ )
37
74
  )
75
+
76
+ rendered_template = template_to_render.render(context=context)
77
+
78
+ expected_static_css_src = (
79
+ f'/static/{PACKAGE_NAME}/css/aa-intel-tool.min.css?v={context["version"]}'
80
+ )
81
+
82
+ self.assertIn(member=expected_static_css_src, container=rendered_template)
83
+ self.assertNotIn(member="integrity=", container=rendered_template)
84
+
85
+ @override_settings(DEBUG=False)
86
+ def test_invalid_file_type(self) -> None:
87
+ """
88
+ Test should raise a ValueError for an invalid file type
89
+
90
+ :return:
91
+ :rtype:
92
+ """
93
+
94
+ context = Context({"version": __version__})
95
+ template_to_render = Template(
96
+ template_string=(
97
+ "{% load aa_intel_tool %}"
98
+ "{% aa_intel_tool_static 'invalid/invalid.txt' %}"
99
+ )
100
+ )
101
+
102
+ with self.assertRaises(ValueError):
103
+ template_to_render.render(context=context)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.3
1
+ Metadata-Version: 2.4
2
2
  Name: aa-intel-tool
3
- Version: 2.5.2
3
+ Version: 2.6.1
4
4
  Summary: A simple parser for D-Scans and more for Alliance Auth
5
5
  Project-URL: Changelog, https://github.com/ppfeufer/aa-intel-tool/blob/master/CHANGELOG.md
6
6
  Project-URL: Documentation, https://github.com/ppfeufer/aa-intel-tool/blob/master/README.md
@@ -683,6 +683,7 @@ License: GNU GENERAL PUBLIC LICENSE
683
683
  the library. If this is what you want to do, use the GNU Lesser General
684
684
  Public License instead of this License. But first, please read
685
685
  <https://www.gnu.org/licenses/why-not-lgpl.html>.
686
+ License-File: LICENSE
686
687
  Keywords: allianceauth,eveonline
687
688
  Classifier: Environment :: Web Environment
688
689
  Classifier: Framework :: Django
@@ -700,7 +701,7 @@ Classifier: Topic :: Internet :: WWW/HTTP
700
701
  Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
701
702
  Requires-Python: >=3.10
702
703
  Requires-Dist: allianceauth-app-utils>=1.19.1
703
- Requires-Dist: allianceauth<5,>=4.3.1
704
+ Requires-Dist: allianceauth<5,>=4.6
704
705
  Requires-Dist: django-eveuniverse>=1.3
705
706
  Provides-Extra: tests-allianceauth-latest
706
707
  Requires-Dist: coverage; extra == 'tests-allianceauth-latest'
@@ -985,9 +986,9 @@ Please make sure to read the [Contribution Guidelines].\
985
986
  [code of conduct]: https://github.com/ppfeufer/aa-intel-tool/blob/master/CODE_OF_CONDUCT.md
986
987
  [contribution guidelines]: https://github.com/ppfeufer/aa-intel-tool/blob/master/CONTRIBUTING.md "Contribution Guidelines"
987
988
  [eve universe]: https://gitlab.com/ErikKalkoken/django-eveuniverse "Eve Universe"
988
- [image: chat scan module]: https://raw.githubusercontent.com/ppfeufer/aa-intel-tool/master/docs/images/representation/chat-scan.jpg "Chat Scan Module"
989
- [image: d-scan module]: https://raw.githubusercontent.com/ppfeufer/aa-intel-tool/master/docs/images/representation/d-scan.jpg "D-Scan Module"
990
- [image: fleet composition module]: https://raw.githubusercontent.com/ppfeufer/aa-intel-tool/master/docs/images/representation/fleet-composition.jpg "Fleet Composition Module"
989
+ [image: chat scan module]: https://raw.githubusercontent.com/ppfeufer/aa-intel-tool/master/docs/images/presentation/chat-scan.jpg "Chat Scan Module"
990
+ [image: d-scan module]: https://raw.githubusercontent.com/ppfeufer/aa-intel-tool/master/docs/images/presentation/d-scan.jpg "D-Scan Module"
991
+ [image: fleet composition module]: https://raw.githubusercontent.com/ppfeufer/aa-intel-tool/master/docs/images/presentation/fleet-composition.jpg "Fleet Composition Module"
991
992
  [ppfeufer on ko-fi]: https://ko-fi.com/ppfeufer "Buy Me a Coffee!"
992
993
  [pre-commit.ci status]: https://results.pre-commit.ci/latest/github/ppfeufer/aa-intel-tool/master "pre-commit.ci"
993
994
  [support discord]: https://discord.gg/zmh52wnfvM "Alliance Auth Community Apps Support Discord"