def process_request(self, request): response = self.get_response(request) current_url = resolve(request.path_info).url_name if current_url not in [ 'sign-up', 'sign-in', 'auth-confirm-activate', 'auth-confirm-create-user-with-bot' ]: UserProfileService.update_user_last_activity( user=request.user.id, last_activity_date_time={ 'last_activity': datetime.datetime.now() }) return response
def unlike(self, request, *args, **kwargs): try: profile = UserProfileService.get( profile_data={'email': request.user}) like = PostService.unlike( post_id=self.request.query_params.get('id'), profile=profile) return Response(like, status=status.HTTP_200_OK) except Exception as e: return Response({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def create_post(self, request, *args, **kwargs): try: profile = UserProfileService.get( profile_data={'email': request.user}) post = PostService.create(post_data=request.data.copy(), profile=profile) return Response(post, status=status.HTTP_200_OK) except Exception as e: return Response({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)
def post(self, request, *args, **kwargs): try: data = request.data.copy() profile = UserProfileService.get(profile_data=data) AuthenticationService.obtain_token(user=profile.get('user'), profile=profile.get('profile')) return Response(profile.get('profile'), status=status.HTTP_200_OK) except Exception as e: return Response({'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR)