Skip to content
This repository has been archived by the owner on Jun 16, 2021. It is now read-only.

completed all the stages for the task #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

m-e-l-u-h-a-n
Copy link
Member

CSoC Task 2 Submission

I have completed the following tasks

  • Stage 1
  • Stage 2
  • Stage 3
  • Stage 4

Copy link
Member

@krashish8 krashish8 left a 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

authentication/views.py Show resolved Hide resolved
store/models.py Show resolved Hide resolved
Comment on lines +115 to +120
else:
book.status = True
book.borrower = None
book.borrow_date = None
book.save()
return JsonResponse({'message':'success'})
Copy link
Member

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:
Copy link
Member

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.)

Comment on lines +134 to +139
previous_user_rating.delete()
obj = BookRating()
obj.user = user
obj.book = book
obj.rate = new_rating
obj.save()
Copy link
Member

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.

Copy link
Member Author

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.

@krashish8
Copy link
Member

Points have been updated! 🎉

@krashish8 krashish8 added the Judged The Pull Requests which are judged label May 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Judged The Pull Requests which are judged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants