예제 #1
0
 def create(self, request, user_id):
     """
     Creates a new referralActivity.
     """
     attrs = self.flatten_dict(request.data)
     #print attrs
     
     user, _, _ = self.idsValidation(user_id, None, None)
     
     #insert referral activity
     refer = ReferralActivity()
     refer.time = datetime.now()
     refer.referee_name = attrs['referee_name']
     refer.refer_method = attrs['refer_method']
     refer.referer = user
     refer.save()
     
     return rc.CREATED
예제 #2
0
 def create(self, request, user_id):
     """
     Creates a new referralActivity.
     """
     #attrs = self.flatten_dict(request.data)
     attrs = request.data
     #print attrs
     
     user, _, _ = self.idsValidation(user_id, None, None)
     
     resp = []
     for item in attrs:
         #insert referral activity
         refer = ReferralActivity()
         refer.time = datetime.now()
         refer.referee_name = item['referee_name']
         refer.refer_method = item['refer_method']
         refer.referer = user
         refer.save()
         resp.append({"referee_name":refer.referee_name, "refer_code":refer.pk})
     
     return resp