Skip to content

Commit

Permalink
[FIX] Some HTML markup
Browse files Browse the repository at this point in the history
  • Loading branch information
ppfeufer committed Nov 8, 2024
1 parent d3581d2 commit 7e7ce37
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 19 deletions.
6 changes: 3 additions & 3 deletions afat/helper/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,8 +128,7 @@ def convert_fatlinks_to_dict( # pylint: disable=too-many-locals
actions += (
'<a class="btn btn-danger btn-sm" data-bs-toggle="modal" '
f'data-bs-target="#deleteFatLinkModal" data-url="{button_delete_url}" '
f'data-confirm-text="{button_delete_text}"'
f'data-body-text="{modal_body_text}">'
f'data-confirm-text="{button_delete_text}" data-body-text="{modal_body_text}">'
'<i class="fa-solid fa-trash-can fa-fw"></i></a>'
)

Expand All @@ -138,6 +137,7 @@ def convert_fatlinks_to_dict( # pylint: disable=too-many-locals
"fleet_name": fatlink_fleet + esi_fleet_marker,
"creator_name": creator_main_character,
"fleet_type": fatlink_type,
"doctrine": fatlink.doctrine,
"fleet_time": {"time": fleet_time, "timestamp": fleet_time_timestamp},
"fats_number": fatlink.fats_count,
"hash": fatlink.hash,
Expand Down Expand Up @@ -196,7 +196,7 @@ def convert_fats_to_dict(request: WSGIRequest, fat: Fat) -> dict:
'data-bs-toggle="modal" '
'data-bs-target="#deleteFatModal" '
f'data-url="{button_delete_fat}" '
f'data-confirm-text="{button_delete_text}"'
f'data-confirm-text="{button_delete_text}" '
f'data-body-text="{modal_body_text}">'
'<i class="fa-solid fa-eye"></i>'
"</a>"
Expand Down
28 changes: 16 additions & 12 deletions afat/tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ def test_helper_convert_fatlinks_to_dict(self):
is_esilink=True,
is_registered_on_esi=True,
esi_fleet_id="3726458287",
doctrine="Ships",
)
Fat.objects.create(
character=self.character_1101, fatlink=fatlink_1_created, shiptype="Omen"
Expand All @@ -172,6 +173,7 @@ def test_helper_convert_fatlinks_to_dict(self):
character=self.character_1101,
hash=fatlink_hash_fleet_2,
link_type=fatlink_type_cta,
doctrine="Ships",
)
Fat.objects.create(
character=self.character_1001, fatlink=fatlink_2_created, shiptype="Omen"
Expand Down Expand Up @@ -224,6 +226,7 @@ def test_helper_convert_fatlinks_to_dict(self):
),
"creator_name": creator_main_character_1,
"fleet_type": "",
"doctrine": "Ships",
"fleet_time": {
"time": fleet_time_1,
"timestamp": fleet_time_timestamp_1,
Expand All @@ -248,7 +251,7 @@ def test_helper_convert_fatlinks_to_dict(self):
'fa-eye"></span></a><a class="btn btn-danger btn-sm" '
'data-bs-toggle="modal" data-bs-target="#deleteFatLinkModal" '
f'data-url="{delete_url_1}" '
'data-confirm-text="Delete"data-body-text="<p>Are you '
'data-confirm-text="Delete" data-body-text="<p>Are you '
"sure you want to delete FAT link April Fleet "
'1?</p>"><i class="fa-solid fa-trash-can fa-fw"></i></a>'
),
Expand All @@ -267,6 +270,7 @@ def test_helper_convert_fatlinks_to_dict(self):
"fleet_name": "April Fleet 2",
"creator_name": creator_main_character_2,
"fleet_type": "CTA",
"doctrine": "Ships",
"fleet_time": {
"time": fleet_time_2,
"timestamp": fleet_time_timestamp_2,
Expand All @@ -278,13 +282,14 @@ def test_helper_convert_fatlinks_to_dict(self):
"is_registered_on_esi": False,
"actions": (
'<a class="btn btn-info btn-sm m-1" '
f'href="{edit_url_2}"><span class="fa-solid '
'fa-eye"></span></a><a class="btn btn-danger btn-sm" '
'data-bs-toggle="modal" data-bs-target="#deleteFatLinkModal" '
f'href="{edit_url_2}"><span '
'class="fa-solid fa-eye"></span></a><a class="btn btn-danger '
'btn-sm" data-bs-toggle="modal" '
'data-bs-target="#deleteFatLinkModal" '
f'data-url="{delete_url_2}" '
'data-confirm-text="Delete"data-body-text="<p>Are you '
"sure you want to delete FAT link April Fleet "
'2?</p>"><i class="fa-solid fa-trash-can fa-fw"></i></a>'
'data-confirm-text="Delete" data-body-text="<p>Are you sure you '
'want to delete FAT link April Fleet 2?</p>"><i class="fa-solid '
'fa-trash-can fa-fw"></i></a>'
),
"via_esi": "No",
},
Expand Down Expand Up @@ -329,6 +334,7 @@ def test_helper_convert_fats_to_dict(self):
f"{fat.character.character_name} from this FAT link?</p>"
)

self.maxDiff = None
# then
self.assertDictEqual(
d1=result,
Expand All @@ -341,14 +347,12 @@ def test_helper_convert_fats_to_dict(self):
"fleet_type": "CTA",
"via_esi": "Yes",
"actions": (
'<a class="btn btn-danger btn-sm" '
'data-bs-toggle="modal" '
'<a class="btn btn-danger btn-sm" data-bs-toggle="modal" '
'data-bs-target="#deleteFatModal" '
f'data-url="{button_delete_fat}" '
f'data-confirm-text="{button_delete_text}"'
f'data-confirm-text="{button_delete_text}" '
f'data-body-text="{modal_body_text}">'
'<i class="fa-solid fa-eye"></i>'
"</a>"
'<i class="fa-solid fa-eye"></i></a>'
),
},
)
Expand Down
41 changes: 37 additions & 4 deletions afat/tests/test_views_fatlinks.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,8 +259,8 @@ def test_should_not_show_fatlink_details_for_non_existing_fatlink(self):

def test_ajax_get_fatlinks_by_year(self):
# given
# self.maxDiff = None
self.client.force_login(user=self.user_with_basic_access)
self.maxDiff = None
self.client.force_login(user=self.user_with_manage_afat)

fatlink_hash = get_hash_on_save()
fatlink_type_cta = FleetType.objects.create(name="CTA")
Expand All @@ -273,6 +273,7 @@ def test_ajax_get_fatlinks_by_year(self):
is_registered_on_esi=True,
esi_fleet_id=3726458287,
link_type=fatlink_type_cta,
doctrine="Ships",
created="2021-11-05T13:19:49.676Z",
)

Expand All @@ -299,6 +300,17 @@ def test_ajax_get_fatlinks_by_year(self):
fleet_time_timestamp = fleet_time.timestamp()
esi_marker = '<span class="badge bg-success afat-label ms-2">ESI</span>'

close_esi_tracking_url = reverse(
viewname="afat:fatlinks_close_esi_fatlink", args=[fatlink_hash]
)
redirect_url = reverse(viewname="afat:fatlinks_overview")
edit_url = reverse(
viewname="afat:fatlinks_details_fatlink", args=[fatlink_hash]
)
delete_url = reverse(
viewname="afat:fatlinks_delete_fatlink", args=[fatlink_hash]
)

self.assertJSONEqual(
raw=str(result.content, encoding="utf8"),
expected_data=[
Expand All @@ -314,10 +326,31 @@ def test_ajax_get_fatlinks_by_year(self):
"fats_number": 0,
"hash": fatlink.hash,
"is_esilink": True,
"doctrine": "Ships",
"esi_fleet_id": fatlink.esi_fleet_id,
"is_registered_on_esi": True,
# "actions": '<a class="btn btn-afat-action btn-info btn-sm" href="/fleet-activity-tracking/fatlink/ncOsHjnjmYZd9k6hI4us8QShRlqJ17/details/"><span class="fa-solid fa-eye"></span></a><a class="btn btn-afat-action btn-danger btn-sm" data-toggle="modal" data-target="#deleteFatLinkModal" data-url="/fleet-activity-tracking/fatlink/ncOsHjnjmYZd9k6hI4us8QShRlqJ17/delete/" data-confirm-text="Delete"data-body-text="<p>Are you sure you want to delete FAT link M2-XFE Keepstar Kill?</p>"><i class="fa-solid fa-trash-can"></i></a>',
"actions": "",
"actions": (
'<a class="btn btn-afat-action btn-primary btn-sm" '
'style="margin-left: 0.25rem;" title="Clicking here will stop '
"the automatic tracking through ESI for this fleet and close "
'the associated FAT link." data-bs-toggle="modal" '
'data-bs-target="#cancelEsiFleetModal" '
f'data-url="{close_esi_tracking_url}?next={redirect_url}" '
'data-body-text="<p>Are you sure you want to close ESI fleet '
'with ID 3726458287 from Bruce Wayne?</p>" '
'data-confirm-text="Stop tracking"><i class="fa-solid fa-times">'
'</i></a><a class="btn btn-info btn-sm m-1" '
f'href="{edit_url}">'
'<span class="fa-solid fa-eye"></span></a>'
'<a class="btn btn-danger btn-sm" data-bs-toggle="modal" '
'data-bs-target="#deleteFatLinkModal" '
f'data-url="{delete_url}" '
'data-confirm-text="Delete" '
'data-body-text="<p>Are you sure you want to delete FAT '
'link April Fleet 1?</p>">'
'<i class="fa-solid fa-trash-can fa-fw"></i></a>'
),
# "actions": "",
"via_esi": "Yes",
}
],
Expand Down

0 comments on commit 7e7ce37

Please sign in to comment.