groups.py
1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from django.http import Http404, JsonResponse
from ..services import groups
def index(request):
# 그룹 생성
if request.method == 'POST':
return JsonResponse(groups.create(request))
raise Http404
def invite(request, invite_code):
# 그룹 초대장 조회
if request.method == 'GET':
return JsonResponse(groups.find_invite(request, invite_code))
# 그룹 초대장 사용
elif request.method == 'POST':
return JsonResponse(groups.use_invite(request, invite_code))
raise Http404
def me(request):
# 그룹 목록
if request.method == 'GET':
return JsonResponse(groups.list_me(request))
raise Http404
def item(request, group_id):
# 그룹 조회
if request.method == 'GET':
return JsonResponse(groups.find_item(request, group_id))
# 그룹 수정
elif request.method == 'PATCH':
return JsonResponse(groups.update_item(request, group_id))
# 그룹 삭제
elif request.method == 'DELETE':
return JsonResponse(groups.delete_item(request, group_id))
raise Http404
def remove_user(request, group_id, user_id):
# 그룹 사용자 삭제
if request.method == 'DELETE':
return JsonResponse(groups.remove_user(request, group_id, user_id))
raise Http404