def block(self, request, userId): userLogin = super(FriendView, self).getUserLogin(request) record = UserFriend.objects.filter(requester_id=userLogin.user.user_id, recipient_id=userId) if record: record[0].status = 5 record[0].save() newRecord = UserFriend.objects.get( requester_id=userId, recipient_id=userLogin.user.user_id) newRecord.status = 4 newRecord.save() else: record = UserFriend(requester_id=userLogin.user.user_id, recipient_id=userId, status=5) record.save() record = UserFriend(requester_id=userId, recipient_id=userLogin.user.user_id, status=4) record.save() response_data = {} response_data['result'] = '200' response_data['message'] = 'Succes block' return HttpResponse(json.dumps(response_data), content_type="application/json")
def addFriend (self, request, userId) : userLogin = super(FriendView, self).getUserLogin(request) record = UserFriend.objects.filter(requester_id = userLogin.user.user_id, recipient_id = userId) if record: if record[0].status == 'pending': record[0].status = 2 record[0].save() record = UserFriend.objects.get(requester_id = userId, recipient_id = userLogin.user.user_id) record.status = 2 record.save() else: record[0].status = 6 record[0].save() newRecord = UserFriend.objects.get(requester_id = userId, recipient_id = userLogin.user.user_id) newRecord.status = 1 newRecord.save() else: record = UserFriend(requester_id = userLogin.user.user_id, recipient_id = userId, status = 6) record.save() record = UserFriend(requester_id = userId, recipient_id = userLogin.user.user_id, status = 1) record.save() response_data = {} response_data['result'] = '200' response_data['message'] = 'derp' return HttpResponse(json.dumps(response_data), content_type="application/json")
def addFriend(self, request, userId): userLogin = super(FriendView, self).getUserLogin(request) record = UserFriend.objects.filter(requester_id=userLogin.user.user_id, recipient_id=userId) if record: if record[0].status == 'pending': record[0].status = 2 record[0].save() record = UserFriend.objects.get( requester_id=userId, recipient_id=userLogin.user.user_id) record.status = 2 record.save() else: record[0].status = 6 record[0].save() newRecord = UserFriend.objects.get( requester_id=userId, recipient_id=userLogin.user.user_id) newRecord.status = 1 newRecord.save() else: record = UserFriend(requester_id=userLogin.user.user_id, recipient_id=userId, status=6) record.save() record = UserFriend(requester_id=userId, recipient_id=userLogin.user.user_id, status=1) record.save() response_data = {} response_data['result'] = '200' response_data['message'] = 'derp' return HttpResponse(json.dumps(response_data), content_type="application/json")
def block (self, request, userId) : userLogin = super(FriendView, self).getUserLogin(request) record = UserFriend.objects.filter(requester_id = userLogin.user.user_id, recipient_id = userId) if record: record[0].status = 5 record[0].save() newRecord = UserFriend.objects.get(requester_id = userId, recipient_id = userLogin.user.user_id) newRecord.status = 4 newRecord.save() else: record = UserFriend(requester_id = userLogin.user.user_id, recipient_id = userId, status = 5) record.save() record = UserFriend(requester_id = userId, recipient_id = userLogin.user.user_id, status = 4) record.save() response_data = {} response_data['result'] = '200' response_data['message'] = 'Succes block' return HttpResponse(json.dumps(response_data), content_type="application/json")