2023-05-03 21:42:37 -07:00
|
|
|
from django.contrib.auth.decorators import login_required
|
2023-01-13 14:54:21 -08:00
|
|
|
from django.http import HttpResponse
|
|
|
|
from django.shortcuts import get_object_or_404
|
|
|
|
from django.utils.decorators import method_decorator
|
|
|
|
from django.views.generic import View
|
|
|
|
|
|
|
|
from users.models import Announcement
|
|
|
|
from users.services import AnnouncementService
|
|
|
|
|
|
|
|
|
2023-05-03 21:42:37 -07:00
|
|
|
@method_decorator(login_required, name="dispatch")
|
2023-01-13 14:54:21 -08:00
|
|
|
class AnnouncementDismiss(View):
|
|
|
|
"""
|
|
|
|
Dismisses an announcement for the current user
|
|
|
|
"""
|
|
|
|
|
|
|
|
def post(self, request, id):
|
|
|
|
announcement = get_object_or_404(Announcement, pk=id)
|
|
|
|
AnnouncementService(request.user).mark_seen(announcement)
|
|
|
|
# In the UI we replace it with nothing anyway
|
|
|
|
return HttpResponse("")
|