This repository was archived by the owner on Aug 29, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Expand file tree Collapse file tree 2 files changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -189,16 +189,22 @@ class AppRating(APIView):
189
189
authentication_classes = [TokenAuthentication ]
190
190
191
191
def post (self , request , * args ):
192
- user_wallet = Wallet .objects .get (user = request .user )
192
+ # Check if the user already has an object for App rating
193
+ user = request .user
194
+ existing_rating = RecentEarnings .objects .filter (user = user , way_to_earn = 'App Rating' ).exists ()
195
+
196
+ if existing_rating :
197
+ return Response ({'message' : 'You have already received points for App rating.' }, status = status .HTTP_400_BAD_REQUEST )
198
+
199
+ user_wallet = Wallet .objects .get (user = user )
193
200
user_wallet .points += 30
194
201
user_wallet .save ()
195
202
196
203
# Adding entry to recent earnings
197
- user_recent_earning = RecentEarnings .objects .create (user = request . user , way_to_earn = "App Rating" , point_earned = 30 )
204
+ user_recent_earning = RecentEarnings .objects .create (user = user , way_to_earn = "App Rating" , point_earned = 30 )
198
205
user_recent_earning .save ()
199
206
200
- return Response ({"message" : "Done" }, status = status .HTTP_200_OK )
201
-
207
+ return Response ({"message" : "Points added for App rating." }, status = status .HTTP_200_OK )
202
208
203
209
204
210
You can’t perform that action at this time.
0 commit comments