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
import json
from utils.base import APIView, get_offset_count
class SurveyListView(APIView):
def get(self, request):
offset, count = get_offset_count(request)
data = self.rpc['venus/sun/survey/list'](offset=offset, count=count).unwrap()
return data
class SurveyView(APIView):
def get(self, request):
id_ = int(request.GET.get('template_id'))
data = self.rpc['venus/sun/survey/get'](id_=id_).unwrap()
return data
def post(self, request):
questions = json.loads(request.POST.get('questions'))
data = {
"name": request.POST.get('name', ""),
"questions": questions,
"template_id": int(request.POST.get('template_id', 0)),
}
self.rpc['venus/sun/survey/add'](data=data).unwrap()
return {
"status": 1
}