Skip to content

Commit

Permalink
Add test for broken link actions
Browse files Browse the repository at this point in the history
  • Loading branch information
MizukiTemma committed Nov 1, 2024
1 parent c67e13c commit 21e107c
Show file tree
Hide file tree
Showing 4 changed files with 415 additions and 4 deletions.
14 changes: 13 additions & 1 deletion integreat_cms/cms/fixtures/test_data.json
Original file line number Diff line number Diff line change
Expand Up @@ -2723,6 +2723,18 @@
"ignore": false
}
},
{
"model": "linkcheck.link",
"pk": 39,
"fields": {
"content_type": ["cms", "pagetranslation"],
"object_id": 99,
"field": "content",
"url": 4,
"text": "Unchecked ink",
"ignore": false
}
},
{
"model": "cms.page",
"pk": 1,
Expand Down Expand Up @@ -5462,7 +5474,7 @@
"title": "Test links",
"slug": "test_links",
"status": "PUBLIC",
"content": "<div><p><a href=\"https://integreat.app/augsburg/de/willkommen/\">Internal valid</a></p><p><a href=\"https://integreat.app/fake-region/de/willkommen/\">Internal invalid</a></p><p> </p><p><a class=\"link-external\" href=\"https://tuerantuer.de/\">External valid</a></p><p><a class=\"link-external\" href=\"https://tuerantuer.dx/\">External invalid</a></p></div>",
"content": "<div><p><a href=\"https://integreat.app/augsburg/de/willkommen/\">Internal valid</a></p><p><a href=\"https://integreat.app/fake-region/de/willkommen/\">Internal invalid</a></p><p> </p><p><a class=\"link-external\" href=\"https://tuerantuer.de/\">External valid</a></p><p><a class=\"link-external\" href=\"https://tuerantuer.dx/\">External invalid</a></p><p> </p><p><a href=\"https://integreat.app\">Unchecked link</a></p></div>",
"language": 1,
"currently_in_translation": false,
"machine_translated": false,
Expand Down
3 changes: 3 additions & 0 deletions integreat_cms/cms/views/linkcheck/link_replace_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

from django.contrib import messages
from django.shortcuts import redirect, render
from django.utils.decorators import method_decorator
from django.utils.translation import gettext_lazy as _
from django.views.generic.base import TemplateView

from ...decorators import permission_required
from ...forms import LinkReplaceForm

if TYPE_CHECKING:
Expand All @@ -15,6 +17,7 @@
from django.http import HttpRequest, HttpResponse


@method_decorator(permission_required("cms.view_broken_links"), name="dispatch")
class LinkReplaceView(TemplateView):
"""
View for link replace form
Expand Down
3 changes: 0 additions & 3 deletions integreat_cms/cms/views/linkcheck/linkcheck_list_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
from typing import TYPE_CHECKING
from urllib.parse import urlencode

from cacheops import invalidate_model
from django.conf import settings
from django.contrib import messages
from django.http import Http404
Expand Down Expand Up @@ -222,8 +221,6 @@ def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
# Add short delay to allow rechecking to be finished when page reloads
time.sleep(1)

invalidate_model(Link)
invalidate_model(Url)
url_for_current_region = reverse("linkcheck", kwargs=kwargs)
# Keep pagination settings
return redirect(f"{url_for_current_region}{self.get_pagination_params()}")
Loading

0 comments on commit 21e107c

Please sign in to comment.