-
Notifications
You must be signed in to change notification settings - Fork 32
completed all the stages for the task #13
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work on the assignment! @m-e-l-u-h-a-n
else: | ||
book.status = True | ||
book.borrower = None | ||
book.borrow_date = None | ||
book.save() | ||
return JsonResponse({'message':'success'}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There must be a validation in the backend when a user is returning the book, to make sure that he has only borrowed the book. Otherwise, a simple POST request will make the BookCopy to be returned, and would set its status as True.
total+=i.rate | ||
book.rating = total/books.count() | ||
book.save() | ||
except: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a good coding practice, whenever you use try-except block, capture only the exceptions which you want to catch (IndexError, IntegrityError, etc.)
previous_user_rating.delete() | ||
obj = BookRating() | ||
obj.user = user | ||
obj.book = book | ||
obj.rate = new_rating | ||
obj.save() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could have updated the rating rather than deleting and then saving it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@krashish8 thanks,for such extensive code reviews and for useful remarks, I will surely try to implement the changes you suggested in further tasks.
Points have been updated! 🎉 |
CSoC Task 2 Submission
I have completed the following tasks