aa-fleetfinder 2.3.2__py3-none-any.whl → 2.3.4__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 (29) hide show
  1. {aa_fleetfinder-2.3.2.dist-info → aa_fleetfinder-2.3.4.dist-info}/METADATA +12 -13
  2. {aa_fleetfinder-2.3.2.dist-info → aa_fleetfinder-2.3.4.dist-info}/RECORD +28 -27
  3. fleetfinder/__init__.py +1 -1
  4. fleetfinder/locale/cs_CZ/LC_MESSAGES/django.po +7 -11
  5. fleetfinder/locale/de/LC_MESSAGES/django.mo +0 -0
  6. fleetfinder/locale/de/LC_MESSAGES/django.po +13 -14
  7. fleetfinder/locale/django.pot +8 -12
  8. fleetfinder/locale/es/LC_MESSAGES/django.po +10 -11
  9. fleetfinder/locale/fr_FR/LC_MESSAGES/django.po +7 -11
  10. fleetfinder/locale/it_IT/LC_MESSAGES/django.po +7 -11
  11. fleetfinder/locale/ja/LC_MESSAGES/django.po +7 -11
  12. fleetfinder/locale/ko_KR/LC_MESSAGES/django.mo +0 -0
  13. fleetfinder/locale/ko_KR/LC_MESSAGES/django.po +15 -15
  14. fleetfinder/locale/nl_NL/LC_MESSAGES/django.po +7 -11
  15. fleetfinder/locale/pl_PL/LC_MESSAGES/django.po +10 -11
  16. fleetfinder/locale/ru/LC_MESSAGES/django.po +10 -11
  17. fleetfinder/locale/sk/LC_MESSAGES/django.po +7 -11
  18. fleetfinder/locale/uk/LC_MESSAGES/django.mo +0 -0
  19. fleetfinder/locale/uk/LC_MESSAGES/django.po +38 -56
  20. fleetfinder/locale/zh_Hans/LC_MESSAGES/django.po +10 -11
  21. fleetfinder/templates/fleetfinder/base.html +9 -4
  22. fleetfinder/templates/fleetfinder/partials/header/header-nav-left.html +9 -0
  23. fleetfinder/templates/fleetfinder/partials/header/header-nav-right.html +18 -0
  24. fleetfinder/templatetags/fleetfinder.py +16 -0
  25. fleetfinder/tests/test_templatetags.py +59 -0
  26. fleetfinder/views.py +0 -14
  27. fleetfinder/templates/fleetfinder/partials/header/header-navigation.html +0 -35
  28. {aa_fleetfinder-2.3.2.dist-info → aa_fleetfinder-2.3.4.dist-info}/WHEEL +0 -0
  29. {aa_fleetfinder-2.3.2.dist-info → aa_fleetfinder-2.3.4.dist-info}/licenses/LICENSE +0 -0
@@ -84,3 +84,19 @@ def fleetfinder_static(relative_file_path: str, script_type: str = None) -> str
84
84
  )
85
85
 
86
86
  return return_value
87
+
88
+
89
+ @register.filter
90
+ def get_item(dictionary: dict | None, key: str) -> str | None:
91
+ """
92
+ Little helper: get a key from a dictionary
93
+
94
+ :param dictionary:
95
+ :param key:
96
+ :return:
97
+ """
98
+
99
+ if dictionary is None:
100
+ return None
101
+
102
+ return dictionary.get(key, None)
@@ -10,6 +10,7 @@ from django.test import TestCase, override_settings
10
10
  from fleetfinder import __version__
11
11
  from fleetfinder.constants import PACKAGE_NAME
12
12
  from fleetfinder.helper.static_files import calculate_integrity_hash
13
+ from fleetfinder.templatetags.fleetfinder import get_item
13
14
 
14
15
 
15
16
  class TestVersionedStatic(TestCase):
@@ -93,3 +94,61 @@ class TestVersionedStatic(TestCase):
93
94
 
94
95
  with self.assertRaises(ValueError):
95
96
  template_to_render.render(context=context)
97
+
98
+
99
+ class TestGetItem(TestCase):
100
+ """
101
+ Test the `get_item` template tag
102
+ """
103
+
104
+ def test_returns_value_for_existing_key(self):
105
+ """
106
+ Test should return the value for an existing key
107
+
108
+ :return:
109
+ :rtype:
110
+ """
111
+
112
+ dictionary = {"key1": "value1", "key2": "value2"}
113
+ result = get_item(dictionary, "key1")
114
+
115
+ self.assertEqual(result, "value1")
116
+
117
+ def test_returns_none_for_non_existing_key(self):
118
+ """
119
+ Test should return None for a non-existing key
120
+
121
+ :return:
122
+ :rtype:
123
+ """
124
+
125
+ dictionary = {"key1": "value1", "key2": "value2"}
126
+ result = get_item(dictionary, "key3")
127
+
128
+ self.assertIsNone(result)
129
+
130
+ def test_returns_none_for_empty_dictionary(self):
131
+ """
132
+ Test should return None for an empty dictionary
133
+
134
+ :return:
135
+ :rtype:
136
+ """
137
+
138
+ dictionary = {}
139
+ result = get_item(dictionary, "key1")
140
+
141
+ self.assertIsNone(result)
142
+
143
+ def test_returns_none_for_none_dictionary(self):
144
+ """
145
+ Test should return None for a None dictionary
146
+
147
+ :return:
148
+ :rtype:
149
+ """
150
+
151
+ dictionary = None
152
+ result = get_item(dictionary, "key1")
153
+
154
+ self.assertIsNone(result)
fleetfinder/views.py CHANGED
@@ -11,7 +11,6 @@ from django.contrib.auth.decorators import login_required, permission_required
11
11
  from django.db.models import Q
12
12
  from django.http import JsonResponse
13
13
  from django.shortcuts import redirect, render
14
- from django.template.defaulttags import register
15
14
  from django.urls import reverse
16
15
  from django.utils.safestring import mark_safe
17
16
  from django.utils.translation import gettext_lazy as _
@@ -341,16 +340,3 @@ def ajax_fleet_details(
341
340
  data["fleet_composition"].append({"ship_type_name": ship, "number": number})
342
341
 
343
342
  return JsonResponse(data=data, safe=False)
344
-
345
-
346
- @register.filter
347
- def get_item(dictionary, key):
348
- """
349
- Little helper: get a key from a dictionary
350
-
351
- :param dictionary:
352
- :param key:
353
- :return:
354
- """
355
-
356
- return dictionary.get(key=key, default=None)
@@ -1,35 +0,0 @@
1
- {% load i18n %}
2
-
3
- <nav class="navbar navbar-expand-lg bg-primary navbar-dark mb-3 rounded">
4
- <div class="container-fluid">
5
- <a class="navbar-brand" href="{% url 'fleetfinder:dashboard' %}">
6
- {% translate "Available fleets" as navigation_item %}
7
- {{ navigation_item|title }}
8
- </a>
9
-
10
- <button
11
- class="navbar-toggler collapsed"
12
- type="button"
13
- data-bs-toggle="collapse"
14
- data-bs-target="#fleetfinder-header-navbar"
15
- aria-controls="fleetfinder-header-navbar"
16
- aria-expanded="false"
17
- aria-label="{% translate 'Toggle navigation' %}"
18
- >
19
- <span class="navbar-toggler-icon"></span>
20
- </button>
21
-
22
- <div class="collapse navbar-collapse" id="fleetfinder-header-navbar">
23
- <ul class="navbar-nav">
24
- {% if perms.fleetfinder.manage_fleets %}
25
- <li class="nav-item">
26
- <a class="nav-link" href="{% url 'fleetfinder:create_fleet' %}">
27
- {% translate "Create fleet" as navigation_item %}
28
- {{ navigation_item|title }}
29
- </a>
30
- </li>
31
- {% endif %}
32
- </ul>
33
- </div>
34
- </div>
35
- </nav>