Skip to content
Snippets Groups Projects
Commit c867eec4 authored by Hangzhi Yu's avatar Hangzhi Yu
Browse files

Move get_notification_by_pk in core_helpers and change it accordingly to other functions

parent 3d46ee8f
No related branches found
No related tags found
1 merge request!243Resolve "Rewrite notification_mark_read with rules and permissions"
Pipeline #1889 passed with warnings
......@@ -219,3 +219,10 @@ def get_announcement_by_pk(request: HttpRequest, id_: Optional[int] = None):
return get_object_or_404(Announcement, pk=pk)
return None
def get_notification_by_pk(request: HttpRequest, pk: int):
try:
return get_object_or_404(Notification, pk=pk)
except:
return None
......@@ -33,7 +33,7 @@ from .registries import site_preferences_registry, group_preferences_registry, p
from .tables import GroupsTable, PersonsTable
from .util import messages
from .util.apps import AppConfig
from .util.core_helpers import get_announcement_by_pk, get_group_by_pk, get_person_by_pk
from .util.core_helpers import get_announcement_by_pk, get_group_by_pk, get_person_by_pk, get_notification_by_pk
@permission_required("core.view_dashboard")
......@@ -301,10 +301,6 @@ def system_status(request: HttpRequest) -> HttpResponse:
return render(request, "core/system_status.html", context)
def get_notification_by_pk(request: HttpRequest, pk: int):
return get_object_or_404(Notification, pk=pk)
@permission_required("core.mark_notification_as_read", fn=get_notification_by_pk)
def notification_mark_read(request: HttpRequest, id_: int) -> HttpResponse:
""" Mark a notification read """
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment