Ejemplo n.º 1
0
 def list(self, request, *args, **kwargs):
     try:
         page_size = request.GET.get('page_size')
         page_index = request.GET.get('page_index')  # 从第一页开始
         lang = request.GET.get('lang')
         if not page_size:
             page_size = 10
         if not page_index:
             page_index = 1
         queryset = self.filter_queryset(self.get_queryset())
         if request.user.has_perm('org.admin_getorgremark'):
             queryset = queryset.filter(datasource=request.user.datasource)
         else:
             queryset = queryset.filter(createuser_id=request.user.id)
         try:
             count = queryset.count()
             queryset = Paginator(queryset, page_size)
             queryset = queryset.page(page_index)
         except EmptyPage:
             return JSONResponse(SuccessResponse({'count': 0, 'data': []}))
         serializer = OrgRemarkSerializer(queryset, many=True)
         return JSONResponse(
             SuccessResponse({
                 'count':
                 count,
                 'data':
                 returnListChangeToLanguage(serializer.data, lang)
             }))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         return JSONResponse(
             ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 2
0
 def destroy(self, request, *args, **kwargs):
     try:
         timelineidlist = request.data.get('timelines')
         timelinelist = []
         lang = request.GET.get('lang')
         if not timelineidlist or not  isinstance(timelineidlist,list):
             raise InvestError(code=20071, msg='except a not null list')
         with transaction.atomic():
             for timelineid in timelineidlist:
                 instance = self.get_object(timelineid)
                 if not (request.user.has_perm('timeline.admin_deleteline') or request.user.has_perm(
                         'timeline.user_deleteline', instance)):
                     raise InvestError(2009, msg='没有相应权限')
                 for link in ['timeline_transationStatus','timeline_remarks']:
                     if link in []:
                         manager = getattr(instance, link, None)
                         if not manager:
                             continue
                         # one to one
                         if isinstance(manager, models.Model):
                             if hasattr(manager, 'is_deleted') and not manager.is_deleted:
                                 raise InvestError(code=2010,msg=u'{} 上有关联数据'.format(link))
                         else:
                             try:
                                 manager.model._meta.get_field('is_deleted')
                                 if manager.all().filter(is_deleted=False).count():
                                     raise InvestError(code=2010,msg=u'{} 上有关联数据'.format(link))
                             except FieldDoesNotExist:
                                 if manager.all().count():
                                     raise InvestError(code=2010,msg=u'{} 上有关联数据'.format(link))
                     else:
                         manager = getattr(instance, link, None)
                         if not manager:
                             continue
                         # one to one
                         if isinstance(manager, models.Model):
                             if hasattr(manager, 'is_deleted') and not manager.is_deleted:
                                 manager.is_deleted = True
                                 manager.save()
                         else:
                             try:
                                 manager.model._meta.get_field('is_deleted')
                                 if manager.all().filter(is_deleted=False).count():
                                     manager.all().update(is_deleted=True)
                             except FieldDoesNotExist:
                                 pass
                 instance.is_deleted = True
                 instance.deleteduser = request.user
                 instance.deletedtime = datetime.datetime.now()
                 instance.save()
                 instance.timeline_transationStatus.all().update(is_deleted=True)
                 instance.timeline_remarks.all().update(is_deleted=True)
                 cache_delete_key(self.redis_key + '_%s' % instance.id)
                 timelinelist.append(TimeLineSerializer(instance).data)
             return JSONResponse(SuccessResponse(returnListChangeToLanguage(timelinelist, lang)))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         catchexcption(request)
         return JSONResponse(ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 3
0
 def list(self, request, *args, **kwargs):
     try:
         lang = request.GET.get('lang')
         page_size = request.GET.get('page_size')
         page_index = request.GET.get('page_index')
         if not page_size:
             page_size = 10
         if not page_index:
             page_index = 1
         queryset = self.filter_queryset(self.get_queryset())
         count = queryset.count()
         try:
             queryset = Paginator(queryset, page_size)
             queryset = queryset.page(page_index)
         except EmptyPage:
             return JSONResponse(SuccessResponse({'count': 0, 'data': []}))
         serializer = self.serializer_class(queryset, many=True)
         return JSONResponse(
             SuccessResponse({
                 'count':
                 count,
                 'data':
                 returnListChangeToLanguage(serializer.data, lang)
             }))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         return JSONResponse(
             ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 4
0
 def destroy(self, request, *args, **kwargs):
     try:
         data = request.data
         traderid = data.get('trader', None)
         investorid = data.get('investor', None)
         projid = data.get('proj', None)
         if not data or not traderid or not investorid:
             raise InvestError(code=20071)
         dataroomquery = self.get_queryset().filter(isPublic=False, proj_id=projid, investor_id=investorid, trader_id=traderid)
         if not dataroomquery.exists():
             raise InvestError(code=6002)
         if request.user.has_perm('dataroom.admin_deletedataroom'):
             pass
         elif request.user.has_perm('dataroom.user_deletedataroom',dataroomquery.get(investor_id=investorid)):
             pass
         else:
             raise InvestError(code=2009)
         with transaction.atomic():
             for instance in dataroomquery:
                 instance.dataroom_directories.all().update(is_deleted=True,deletedtime=datetime.datetime.now())
                 for fileOrDirectory in instance.dataroom_directories.all():
                     if fileOrDirectory.isFile and fileOrDirectory.key:
                         deleteqiniufile(fileOrDirectory.bucket, fileOrDirectory.key)
                 instance.is_deleted = True
                 instance.deleteduser = request.user
                 instance.deletedtime = datetime.datetime.now()
                 instance.save()
             return JSONResponse(SuccessResponse(returnListChangeToLanguage(DataroomSerializer(dataroomquery,many=True).data)))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         catchexcption(request)
         return JSONResponse(ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 5
0
 def list(self, request, *args, **kwargs):
     try:
         lang = request.GET.get('lang',None)
         dataroomid = request.GET.get('dataroom',None)
         queryset = self.filter_queryset(self.get_queryset())
         if dataroomid and isinstance(dataroomid,(int,str,unicode)):
             dataroomobj = self.get_dataroom(dataroomid)
             if dataroomobj.isPublic:
                 pass
             elif request.user.has_perm('dataroom.admin_getdataroom'):
                 pass
             elif request.user.has_perm('dataroom.user_getdataroom', dataroomobj):
                 pass
             else:
                 raise InvestError(code=2009)
         else:
             raise InvestError(code=20072,msg='dataroom 不能空')
         count = queryset.count()
         serializer = DataroomdirectoryorfileSerializer(queryset, many=True)
         return JSONResponse(SuccessResponse({'count':count,'data':returnListChangeToLanguage(serializer.data,lang)}))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         catchexcption(request)
         return JSONResponse(ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 6
0
 def list(self, request, *args, **kwargs):
     try:
         page_size = request.GET.get('page_size')
         page_index = request.GET.get('page_index')  # 从第一页开始
         lang = request.GET.get('lang')
         if not page_size:
             page_size = 10
         if not page_index:
             page_index = 1
         queryset = self.filter_queryset(self.get_queryset())
         sort = request.GET.get('sort')
         if sort not in ['True', 'true', True, 1, 'Yes', 'yes', 'YES', 'TRUE']:
             queryset = queryset.order_by('-lastmodifytime', '-createdtime')
         else:
             queryset = queryset.order_by('lastmodifytime', 'createdtime')
         if request.user.has_perm('timeline.admin_getlineremark'):
             queryset = queryset
         else:
             queryset = queryset.filter(createuser_id=request.user.id)
         try:
             count = queryset.count()
             queryset = Paginator(queryset, page_size)
             queryset = queryset.page(page_index)
         except EmptyPage:
             return JSONResponse(SuccessResponse({'count': 0, 'data': []}))
         serializer = TimeLineRemarkSerializer(queryset, many=True)
         return JSONResponse(SuccessResponse({'count':count,'data':returnListChangeToLanguage(serializer.data, lang)}))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         return JSONResponse(ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 7
0
 def update(self, request, *args, **kwargs):
     try:
         data = request.data
         traderid = data.get('trader', None)
         investorid = data.get('investor', None)
         projid = data.get('proj', None)
         isClose = data.get('isClose',False)
         if isClose in ['True', 1, '1', 'true', 'TRUE']:
             isClose = True
         else:
             isClose = False
         if not data or not traderid or not investorid or not projid:
             raise InvestError(code=20071)
         dataroomquery = self.get_queryset().filter(isPublic=False, proj_id=projid, investor_id=investorid,trader_id=traderid)
         if not dataroomquery.exists():
             raise InvestError(code=6002)
         if request.user.has_perm('dataroom.admin_closedataroom'):
             pass
         elif request.user.has_perm('dataroom.user_closedataroom',dataroomquery.get(user_id=investorid)):
             pass
         else:
             raise InvestError(code=2009)
         dataroomquery.update(isClose=isClose,closeDate=datetime.datetime.now())
         return JSONResponse(
             SuccessResponse(returnListChangeToLanguage(DataroomSerializer(dataroomquery, many=True).data)))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         return JSONResponse(ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 8
0
 def list(self, request, *args, **kwargs):
     try:
         page_size = request.GET.get('page_size')
         page_index = request.GET.get('page_index')  # 从第一页开始
         lang = request.GET.get('lang')
         if not page_size:
             page_size = 10
         if not page_index:
             page_index = 1
         queryset = self.filter_queryset(self.get_queryset())
         if request.user.has_perm('BD.manageOrgBD'):
             pass
         elif request.user.has_perm('BD.user_getOrgBD'):
             queryset = queryset.filter(
                 Q(manager=request.user) | Q(createuser=request.user)
                 | Q(proj__in=request.user.usertake_projs.all())
                 | Q(proj__in=request.user.usermake_projs.all()))
         else:
             raise InvestError(2009)
         countres = queryset.values_list('manager').annotate(
             Count('manager'))
         countlist = []
         for manager_count in countres:
             countlist.append({
                 'manager': manager_count[0],
                 'count': manager_count[1]
             })
         sortfield = request.GET.get('sort', 'createdtime')
         desc = request.GET.get('desc', 1)
         if desc in ('1', u'1', 1):
             sortfield = '-' + sortfield
         queryset = queryset.order_by('-isimportant', sortfield)
         try:
             count = queryset.count()
             queryset = Paginator(queryset, page_size)
             queryset = queryset.page(page_index)
         except EmptyPage:
             return JSONResponse(
                 SuccessResponse({
                     'count': 0,
                     'data': [],
                     'manager_count': countlist
                 }))
         serializer = OrgBDSerializer(queryset, many=True)
         return JSONResponse(
             SuccessResponse({
                 'count':
                 count,
                 'data':
                 returnListChangeToLanguage(serializer.data, lang),
                 'manager_count':
                 countlist
             }))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         return JSONResponse(
             ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 9
0
 def list(self, request, *args, **kwargs):
     try:
         lang = request.GET.get('lang')
         queryset = self.filter_queryset(self.get_queryset())
         serializer = self.serializer_class(queryset, many=True)
         return JSONResponse(
             SuccessResponse(
                 returnListChangeToLanguage(serializer.data, lang)))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         return JSONResponse(
             ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 10
0
 def list(self, request, *args, **kwargs):
     try:
         page_size = request.GET.get('page_size')
         page_index = request.GET.get('page_index')  # 从第一页开始
         lang = request.GET.get('lang')
         date = request.GET.get('date')
         time = request.GET.get('time')
         if not page_size:
             page_size = 10
         if not page_index:
             page_index = 1
         queryset = self.filter_queryset(
             self.queryset.filter(datasource=request.user.datasource_id))
         if date:
             date = datetime.datetime.strptime(date.encode('utf-8'),
                                               "%Y-%m-%d")
             queryset = queryset.filter(scheduledtime__year=date.year,
                                        scheduledtime__month=date.month)
         if time:
             time = datetime.datetime.strptime(time.encode('utf-8'),
                                               "%Y-%m-%dT%H:%M:%S")
             queryset = queryset.filter(scheduledtime__gt=time)
         if request.user.has_perm('msg.admin_manageSchedule'):
             queryset = queryset
         else:
             queryset = queryset.filter(createuser_id=request.user.id)
         sortfield = request.GET.get('sort', 'createdtime')
         desc = request.GET.get('desc', 1)
         queryset = mySortQuery(queryset, sortfield, desc)
         try:
             count = queryset.count()
             queryset = Paginator(queryset, page_size)
             queryset = queryset.page(page_index)
         except EmptyPage:
             return JSONResponse(SuccessResponse({'count': 0, 'data': []}))
         serializer = ScheduleSerializer(queryset, many=True)
         return JSONResponse(
             SuccessResponse({
                 'count':
                 count,
                 'data':
                 returnListChangeToLanguage(serializer.data, lang)
             }))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         return JSONResponse(
             ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 11
0
 def list(self, request, *args, **kwargs):
     try:
         lang = request.GET.get('lang')
         source = int(request.META.get('HTTP_SOURCE', '1'))
         if source > 2:
             source = 1
         queryset = self.filter_queryset(self.get_queryset()).filter(
             datasource_id=source).order_by('-sortweight')
         serializer = self.serializer_class(queryset, many=True)
         return JSONResponse(
             SuccessResponse(
                 returnListChangeToLanguage(serializer.data, lang)))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         return JSONResponse(
             ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 12
0
 def list(self, request, *args, **kwargs):
     try:
         page_size = request.GET.get('page_size')
         page_index = request.GET.get('page_index')  # 从第一页开始
         lang = request.GET.get('lang')
         if not page_size:
             page_size = 10
         if not page_index:
             page_index = 1
         queryset = self.filter_queryset(self.get_queryset()).filter(datasource=request.user.datasource)
         sort = request.GET.get('sort')
         if sort not in ['True', 'true', True, 1, 'Yes', 'yes', 'YES', 'TRUE']:
             queryset = queryset.order_by('-lastmodifytime', '-createdtime')
         else:
             queryset = queryset.order_by('lastmodifytime', 'createdtime')
         try:
             count = queryset.count()
             queryset = Paginator(queryset, page_size)
             queryset = queryset.page(page_index)
         except EmptyPage:
             return JSONResponse(SuccessResponse({'count': 0, 'data':[]}))
         responselist = []
         for instance in queryset:
             actionlist = {'get': False, 'change': False, 'delete': False}
             if request.user.has_perm('timeline.admin_getline'):
                 actionlist['get'] = True
                 serializerclass = TimeLineListSerializer_admin
             elif request.user.has_perm('timeline.user_getline', instance):
                 actionlist['get'] = True
                 serializerclass = TimeLineListSerializer_user
             else:
                 serializerclass = TimeLineListSerializer_anonymous
             if request.user.has_perm('timeline.admin_changeline') or request.user.has_perm('timeline.user_changeline', instance):
                 actionlist['change'] = True
             if request.user.has_perm('timeline.admin_deleteline') or request.user.has_perm('timeline.user_deleteline', instance):
                 actionlist['delete'] = True
             instancedata = serializerclass(instance).data
             instancedata['action'] = actionlist
             responselist.append(instancedata)
         return JSONResponse(SuccessResponse({'count': count, 'data': returnListChangeToLanguage(responselist, lang)}))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         return JSONResponse(ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 13
0
 def list(self, request, *args, **kwargs):
     try:
         page_size = request.GET.get('page_size')
         page_index = request.GET.get('page_index')  # 从第一页开始
         lang = request.GET.get('lang')
         if not page_size:
             page_size = 10
         if not page_index:
             page_index = 1
         queryset = self.filter_queryset(self.get_queryset())
         if request.user.has_perm('BD.manageMeetBD'):
             pass
         elif request.user.has_perm('BD.user_getMeetBD'):
             queryset = queryset.filter(
                 Q(manager=request.user) | Q(createuser=request.user)
                 | Q(proj__in=request.user.usertake_projs.all())
                 | Q(proj__in=request.user.usermake_projs.all()))
         else:
             raise InvestError(2009)
         sortfield = request.GET.get('sort', 'createdtime')
         desc = request.GET.get('desc', 1)
         queryset = mySortQuery(queryset, sortfield, desc)
         try:
             count = queryset.count()
             queryset = Paginator(queryset, page_size)
             queryset = queryset.page(page_index)
         except EmptyPage:
             return JSONResponse(SuccessResponse({'count': 0, 'data': []}))
         serializer = MeetingBDSerializer(queryset, many=True)
         return JSONResponse(
             SuccessResponse({
                 'count':
                 count,
                 'data':
                 returnListChangeToLanguage(serializer.data, lang)
             }))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         return JSONResponse(
             ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 14
0
 def list(self, request, *args, **kwargs):
     try:
         page_size = request.GET.get('page_size')
         page_index = request.GET.get('page_index')  # 从第一页开始
         lang = request.GET.get('lang')
         if not page_size:
             page_size = 10
         if not page_index:
             page_index = 1
         queryset = self.filter_queryset(self.get_queryset())
         if request.user.has_perm('BD.manageOrgBD'):
             pass
         elif request.user.has_perm('BD.user_getOrgBD'):
             queryset = queryset.filter(
                 Q(orgBD__in=request.user.user_orgBDs.all())
                 | Q(orgBD__proj__in=request.user.usertake_projs.all())
                 | Q(orgBD__proj__in=request.user.usermake_projs.all()))
         else:
             raise InvestError(2009)
         try:
             count = queryset.count()
             queryset = Paginator(queryset, page_size)
             queryset = queryset.page(page_index)
         except EmptyPage:
             return JSONResponse(SuccessResponse({'count': 0, 'data': []}))
         serializer = OrgBDCommentsSerializer(queryset, many=True)
         return JSONResponse(
             SuccessResponse({
                 'count':
                 count,
                 'data':
                 returnListChangeToLanguage(serializer.data, lang)
             }))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         return JSONResponse(
             ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 15
0
 def list(self, request, *args, **kwargs):
     try:
         page_size = request.GET.get('page_size')
         page_index = request.GET.get('page_index')  # 从第一页开始
         lang = request.GET.get('lang')
         userid = request.GET.get('user',None)
         isPublic = request.GET.get('isPublic',None)
         if not page_size:
             page_size = 10
         if not page_index:
             page_index = 1
         queryset = self.filter_queryset(self.get_queryset())
         if not userid and not isPublic:
             queryset = queryset.filter(isPublic=False).exclude(Q(trader__isnull=True) | Q(investor__isnull=True))
         sort = request.GET.get('sort')
         if sort not in ['True', 'true', True, 1, 'Yes', 'yes', 'YES', 'TRUE']:
             queryset = queryset.order_by('-lastmodifytime', '-createdtime')
         else:
             queryset = queryset.order_by('lastmodifytime', 'createdtime')
         if request.user.has_perm('dataroom.admin_getdataroom'):
             queryset = queryset
         else:
             if not isPublic:
                 queryset = queryset.filter(Q(user=request.user) | Q(trader=request.user) | Q(investor=request.user) | Q(proj__takeUser=request.user) | Q(proj__makeUser=request.user) | Q(createuser=request.user))
         try:
             count = queryset.count()
             queryset = Paginator(queryset, page_size)
             queryset = queryset.page(page_index)
         except EmptyPage:
             return JSONResponse(SuccessResponse({'count': 0, 'data': []}))
         serializer = DataroomSerializer(queryset, many=True)
         return JSONResponse(SuccessResponse({'count':count,'data':returnListChangeToLanguage(serializer.data, lang)}))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         return JSONResponse(ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 16
0
 def list(self, request, *args, **kwargs):
     try:
         page_size = request.GET.get('page_size')
         page_index = request.GET.get('page_index')  # 从第一页开始
         lang = request.GET.get('lang')
         source = request.META.get('HTTP_SOURCE')
         if source:
             datasource = DataSource.objects.filter(id=source,
                                                    is_deleted=False)
             if datasource.exists():
                 userdatasource = datasource.first()
                 queryset = self.get_queryset().filter(
                     datasource=userdatasource)
             else:
                 raise InvestError(code=8888)
         else:
             raise InvestError(code=8888, msg='source field is required')
         if not page_size:
             page_size = 10
         if not page_index:
             page_index = 1
         queryset = self.filter_queryset(queryset)
         sort = request.GET.get('sort')
         if sort not in [
                 'True', 'true', True, 1, 'Yes', 'yes', 'YES', 'TRUE'
         ]:
             queryset = queryset.order_by('-lastmodifytime', '-createdtime')
         else:
             queryset = queryset.order_by('lastmodifytime', 'createdtime')
         setrequestuser(request)
         if request.user.is_anonymous:
             serializerclass = OrgCommonSerializer
         else:
             if request.user.has_perm('org.admin_getorg'):
                 serializerclass = OrgDetailSerializer
             else:
                 serializerclass = OrgCommonSerializer  # warning
         try:
             count = queryset.count()
             queryset = Paginator(queryset, page_size)
             queryset = queryset.page(page_index)
         except EmptyPage:
             return JSONResponse(SuccessResponse({'count': 0, 'data': []}))
         responselist = []
         for instance in queryset:
             actionlist = {'get': False, 'change': False, 'delete': False}
             if request.user.is_anonymous:
                 pass
             else:
                 if request.user.has_perm(
                         'org.admin_getorg') or request.user.has_perm(
                             'org.user_getorg', instance):
                     actionlist['get'] = True
                 if request.user.has_perm(
                         'org.admin_changeorg') or request.user.has_perm(
                             'org.user_changeorg', instance):
                     actionlist['change'] = True
                 if request.user.has_perm(
                         'org.admin_deleteorg') or request.user.has_perm(
                             'org.user_deleteorg', instance):
                     actionlist['delete'] = True
             instancedata = serializerclass(instance).data
             instancedata['action'] = actionlist
             responselist.append(instancedata)
         return JSONResponse(
             SuccessResponse({
                 'count':
                 count,
                 'data':
                 returnListChangeToLanguage(responselist, lang)
             }))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         catchexcption(request)
         return JSONResponse(
             ExceptionResponse(traceback.format_exc().split('\n')[-2]))
Ejemplo n.º 17
0
 def create(self, request, *args, **kwargs):
     try:
         data = request.data
         lang = request.GET.get('lang')
         projid = data.get('proj',None)
         investorid = data.get('investor', None)
         traderid = data.get('trader', None)
         ispublic = data.get('isPublic',False)
         if not projid:
             raise InvestError(20072,msg='proj 不能为空 int类型')
         try:
             proj = project.objects.get(id=projid,datasource=request.user.datasource,is_deleted=False)
         except project.DoesNotExist:
             raise InvestError(code=4002)
         if not ispublic:
             if not traderid or not investorid or not isinstance(investorid,int) or not isinstance(traderid,int):
                 raise InvestError(code=20072,msg='investor/trader bust be an nunull \'int\'')
         if proj.projstatus_id < 4:
             raise InvestError(5003, msg='项目尚未终审发布')
         with transaction.atomic():
             responselist = []
             dataroomdata = {'proj':projid,'datasource':request.user.datasource.id,'createuser':request.user.id}
             projdataroom = self.get_queryset().filter(proj=proj,user_id=proj.supportUser_id,isPublic=False)
             publicdataroom = self.get_queryset().filter(proj=proj, isPublic=True)
             if projdataroom.exists():
                 responselist.append(DataroomCreateSerializer(projdataroom.first()).data)
             else:
                 dataroomdata['user'] = proj.supportUser_id
                 dataroomdata['isPublic'] = False
                 supportordataroomserializer = DataroomCreateSerializer(data=dataroomdata)
                 if supportordataroomserializer.is_valid():
                     supportdataroom = supportordataroomserializer.save()
                     userlist1 = [supportdataroom.createuser, proj.makeUser, proj.takeUser, ]
                     for user in userlist1:
                         add_perm('dataroom.user_getdataroom', user, supportdataroom)
                     add_perm('dataroom.user_getdataroom', supportdataroom.user, supportdataroom)
                     add_perm('dataroom.user_changedataroom', supportdataroom.user, supportdataroom)
                     responselist.append(supportordataroomserializer.data)
                 else:
                     raise InvestError(code=20071, msg=supportordataroomserializer.errors)
             if publicdataroom.exists():
                 responselist.append(DataroomCreateSerializer(publicdataroom.first()).data)
             else:
                 dataroomdata['user'] = proj.supportUser_id
                 dataroomdata['isPublic'] = True
                 publicdataroomserializer = DataroomCreateSerializer(data=dataroomdata)
                 if publicdataroomserializer.is_valid():
                     publicdataroom = publicdataroomserializer.save()
                     creatpublicdataroomdirectorywithtemplate(request.user, publicdataroomid=publicdataroom.id)
                     responselist.append(publicdataroomserializer.data)
                 else:
                     raise InvestError(code=20071, msg=publicdataroomserializer.errors)
             if not ispublic:
                 investordataroom = self.get_queryset().filter(proj=proj, user_id=investorid, trader_id=traderid,investor_id=investorid)
                 if investordataroom.exists():
                     responselist.append(DataroomCreateSerializer(investordataroom.first()).data)
                 else:
                     dataroomdata['user'] = None
                     dataroomdata['isPublic'] = False
                     dataroomdata['investor'] = investorid
                     dataroomdata['trader'] = traderid
                     investordataroomserializer = DataroomCreateSerializer(data=dataroomdata)
                     if investordataroomserializer.is_valid():
                         investordata = investordataroomserializer.save()
                         userlist = [investordata.investor, investordata.trader, investordata.createuser, investordata.proj.makeUser,
                                     investordata.proj.takeUser, investordata.proj.supportUser]
                         for user in userlist:
                             add_perm('dataroom.user_getdataroom', user, investordata)
                         add_perm('dataroom.user_changedataroom', investordata.investor, investordata)
                         responselist.append(investordataroomserializer.data)
                     else:
                         raise InvestError(code=20071,msg=investordataroomserializer.errors)
             return JSONResponse(SuccessResponse(returnListChangeToLanguage(responselist, lang)))
     except InvestError as err:
         return JSONResponse(InvestErrorResponse(err))
     except Exception:
         catchexcption(request)
         return JSONResponse(ExceptionResponse(traceback.format_exc().split('\n')[-2]))