✏️ Fix: [#41] notification 관련 코드 삭제
This commit is contained in:
@@ -63,8 +63,3 @@ class User(BaseModel, AbstractBaseUser, PermissionsMixin):
|
|||||||
return self.nickname
|
return self.nickname
|
||||||
|
|
||||||
|
|
||||||
class Notification(BaseModel):
|
|
||||||
user = models.ForeignKey(User, on_delete=models.CASCADE, related_name='notifications')
|
|
||||||
content = models.TextField()
|
|
||||||
is_read = models.BooleanField(default=False)
|
|
||||||
note_type = models.CharField(max_length=10, choices=NotificationType.choices)
|
|
||||||
|
|||||||
@@ -62,8 +62,3 @@ class UserMemberInfoSerializer(serializers.ModelSerializer):
|
|||||||
'custom_url',
|
'custom_url',
|
||||||
'job_and_interests'
|
'job_and_interests'
|
||||||
]
|
]
|
||||||
|
|
||||||
class NotificationSerializer(serializers.ModelSerializer):
|
|
||||||
class Meta:
|
|
||||||
model = Notification
|
|
||||||
fields = ['id', 'content', 'note_type', 'is_read']
|
|
||||||
@@ -1,14 +1,10 @@
|
|||||||
from django.urls import path, include
|
from django.urls import path
|
||||||
|
|
||||||
from .views import *
|
from .views import *
|
||||||
|
|
||||||
from rest_framework.routers import DefaultRouter
|
|
||||||
|
|
||||||
app_name = 'users'
|
app_name = 'users'
|
||||||
|
|
||||||
router = DefaultRouter()
|
|
||||||
router.register(r'notifications', NotificationReadViewSet, basename='notification')
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('refresh-token/', RefreshAPIView.as_view()),
|
path('refresh-token/', RefreshAPIView.as_view()),
|
||||||
path('join/', JoinAPIView.as_view()),
|
path('join/', JoinAPIView.as_view()),
|
||||||
@@ -20,5 +16,4 @@ urlpatterns = [
|
|||||||
path('mypage/profile/<str:nickname>/', MyPageProfileAPIView.as_view()),
|
path('mypage/profile/<str:nickname>/', MyPageProfileAPIView.as_view()),
|
||||||
path('mypage/works/<str:nickname>/', MyPageWorkListAPIView.as_view()),
|
path('mypage/works/<str:nickname>/', MyPageWorkListAPIView.as_view()),
|
||||||
path('mypage/my-info/', MyPageMemberInfoAPIView.as_view()),
|
path('mypage/my-info/', MyPageMemberInfoAPIView.as_view()),
|
||||||
path('', include(router.urls)),
|
|
||||||
]
|
]
|
||||||
@@ -249,21 +249,3 @@ class MyPageMemberInfoAPIView(APIView):
|
|||||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
return Response(serializer.data, status=status.HTTP_200_OK)
|
||||||
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
return Response(serializer.errors, status=status.HTTP_400_BAD_REQUEST)
|
||||||
|
|
||||||
class NotificationReadViewSet(ReadOnlyModelViewSet):
|
|
||||||
serializer_class = NotificationSerializer
|
|
||||||
|
|
||||||
# 30일 이전 알림만 가져옴
|
|
||||||
def get_queryset(self):
|
|
||||||
return UserToNotificationService.get_all_notification(self.request.user)
|
|
||||||
|
|
||||||
def list(self, request, *args, **kwargs):
|
|
||||||
queryset = self.get_queryset()
|
|
||||||
serializer = self.get_serializer(queryset, many=True)
|
|
||||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
|
||||||
|
|
||||||
def retrieve(self, request, *args, **kwargs):
|
|
||||||
instance = self.get_object()
|
|
||||||
instance.is_read = True
|
|
||||||
instance.save()
|
|
||||||
serializer = self.get_serializer(instance)
|
|
||||||
return Response(serializer.data, status=status.HTTP_200_OK)
|
|
||||||
Reference in New Issue
Block a user