Skip to content
Snippets Groups Projects
Commit 8fbcc688 authored by Kangmin Lee's avatar Kangmin Lee
Browse files

신고기능구현

parent 83e34329
No related branches found
No related tags found
No related merge requests found
from django.shortcuts import render from django.shortcuts import render
from rest_framework.views import APIView from rest_framework.views import APIView
from content.models import Feed, FeedLike, FeedView from content.models import Feed, FeedLike, FeedView, FeedReport
from rest_framework.response import Response from rest_framework.response import Response
from user.models import User, Univ from user.models import User, Univ
from rest_framework.response import Response from rest_framework.response import Response
...@@ -10,6 +10,7 @@ from uuid import uuid4 ...@@ -10,6 +10,7 @@ from uuid import uuid4
from datetime import datetime from datetime import datetime
from django.db.models import Q from django.db.models import Q
class UploadFeed(APIView): class UploadFeed(APIView):
def post(self, request): def post(self, request):
file = request.FILES['file'] file = request.FILES['file']
...@@ -32,9 +33,11 @@ class UploadFeed(APIView): ...@@ -32,9 +33,11 @@ class UploadFeed(APIView):
if type == 'scene': if type == 'scene':
type = True type = True
Feed.objects.create(content=content, image=image, profile_image=profile_image, user_id=user_id, email=email, like_count=0, view_count=0, type=type, univ=univ) Feed.objects.create(content=content, image=image, profile_image=profile_image, user_id=user_id, email=email,
like_count=0, view_count=0, report_count=0, type=type, univ=univ)
return Response(status=200) return Response(status=200)
class LikeFeed(APIView): class LikeFeed(APIView):
def post(self, request): def post(self, request):
feed_id = request.data.get('feed_id') feed_id = request.data.get('feed_id')
...@@ -58,6 +61,7 @@ class LikeFeed(APIView): ...@@ -58,6 +61,7 @@ class LikeFeed(APIView):
return Response(status=200, data=dict(message='피드 좋아요 완료.')) return Response(status=200, data=dict(message='피드 좋아요 완료.'))
class ViewFeed(APIView): class ViewFeed(APIView):
def post(self, request): def post(self, request):
feed_id = request.data.get('feed_id') # id? feed_id = request.data.get('feed_id') # id?
...@@ -81,6 +85,36 @@ class ViewFeed(APIView): ...@@ -81,6 +85,36 @@ class ViewFeed(APIView):
return Response(status=200, data=dict(message='피드 조회 완료.')) return Response(status=200, data=dict(message='피드 조회 완료.'))
class ReportFeed(APIView):
def post(self, request):
feed_id = request.data.get('feed_id')
email = request.data.get('email')
is_report = request.data.get('is_report', 'True')
if is_report.lower() == 'false':
is_report = False
else:
is_report = True
feed_report = FeedReport.objects.filter(feed_id=feed_id, email=email).first()
if feed_report is None:
FeedReport.objects.create(feed_id=feed_id,
email=email,
is_report=is_report,
)
else:
feed_report.is_report = is_report
feed_report.save()
feed = Feed.objects.filter(id=feed_id).first()
report_count=FeedReport.objects.filter(feed_id=feed_id, is_report=True).count()
if report_count>=5: #5회 이상 신고 게시글 삭제
feed.delete()
return Response(status=200, data=dict(message='신고 5회 누적 게시글 삭제 완료'))
return Response(status=200, data=dict(message='피드 신고 완료.'))
## 시환님꺼 ## 시환님꺼
class DeleteFeed(APIView): class DeleteFeed(APIView):
def post(self, request): def post(self, request):
...@@ -101,6 +135,7 @@ class DeleteFeed(APIView): ...@@ -101,6 +135,7 @@ class DeleteFeed(APIView):
else: else:
return Response(status=500, data=dict(message='삭제 실패')) return Response(status=500, data=dict(message='삭제 실패'))
class searchUniv(APIView): class searchUniv(APIView):
def get(self, request): def get(self, request):
search_word = request.GET.get('keyword') search_word = request.GET.get('keyword')
...@@ -120,6 +155,7 @@ class searchUniv(APIView): ...@@ -120,6 +155,7 @@ class searchUniv(APIView):
'jinstagram/search.html', 'jinstagram/search.html',
context=dict(univ_list=univ_list, user_list=user_list, message=message)) context=dict(univ_list=univ_list, user_list=user_list, message=message))
class searchUser(APIView): class searchUser(APIView):
def get(self, request): def get(self, request):
search_word = request.GET.get('keyword') search_word = request.GET.get('keyword')
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment