示例#1
0
def add(request,projectid):
    result=True
    try:
        member_ids=request.POST.get("user_ids")
        if member_ids!="null":
            print(eval(member_ids))
            for member_id in eval(member_ids+","):
                MemberService.add_member(int(member_id),projectid,request.user)
    except Exception as ex:
        result=ProjectRes.project_member_save_fail
        SimpleLogger.error(ex)
    return HttpResponse(result)
示例#2
0
def import_member(request,projectid):
    result=True
    try:
        from_project_id=request.POST.get("from_project")
        from_project_members=MemberService.get_member_users(int(from_project_id))
        current_project_members=MemberService.get_member_users(int(projectid))
        for member in from_project_members:
            if member not in current_project_members:
                MemberService.add_member(int(member.id),projectid,request.user)
    except Exception as ex:
        result=ProjectRes.project_member_save_fail
        SimpleLogger.error(ex)
    return HttpResponse(result)
示例#3
0
 def post(self, request, *args, **kwargs):
     member_list = list()
     project_id = int(self.kwargs.get('project_id', 0))
     user_list  = request.data.get("userID")
     for user_id in user_list:
         member = MemberService.add_member(user_id,project_id,request.user)
         if member:
             member_list.append(member)
     serializer = self.get_serializer(member_list, many=True)
     return response.Response(serializer.data, status=status.HTTP_201_CREATED)