def put(self, request): try: print "Responding to an add request" notification_id = request.data["notification_id"] print notification_id notification = Notification.objects.get(pk=notification_id) notification.is_shown = False notification.save() print notification.is_shown is_pushed = True #Add to requesters contact book - Check if there is already a contact from the requester if Contact.objects.filter(user=notification.from_user, contact_number=notification.user.mobile_number).exists(): requested_by = Contact(user=notification.from_user, contact_name=notification.user.name, contact_number=notification.user.mobile_number, is_local_profile_updated=False) requested_by.save() is_pushed = False print "Contact created for person who requested" #Add to accepters contact book requested_to = Contact(user=notification.user, contact_name=notification.from_user.name, contact_number=notification.from_user.mobile_number,is_local_profile_updated=False) requested_to.save() requested_to.update_local_contact_book() print "Contact created for person who was requested" if is_pushed: make_notification.contact_request_complete(notification=notification, accepted_by=notification.user, accepted_for=notification.from_user) # Make all profile requests visible Notification.objects.filter(user=notification.user, from_user=notification.from_user, notification_type__in = ["profile_request_add", "profile_request_share"]).update(is_shown=True) return JSONResponse([], status=200) except Exception as e: print traceback.format_exc(e) beam(e, request) return JSONResponse(ERROR_MESSAGE, status=400)