-
Notifications
You must be signed in to change notification settings - Fork 0
Add some comments #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ class DjangoStorage(Storage): | |
"""Adapter to use Django ORM as a storage backend.""" | ||
|
||
def create_user(self, user, password): | ||
# not injecting repo makes it less explicit when testing | ||
"""Create user entity. | ||
|
||
Because Django provides password hashing functionality that we want to use, we perform this | ||
|
@@ -22,6 +23,7 @@ def create_user(self, user, password): | |
django_user = accounts_models.User.objects.from_entity(user) | ||
django_user.set_password(password) | ||
django_user.save() | ||
# nizar: unnecessary coupling with the return from the repo; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agreed, I prefer a function that takes a model as an argument and returns the entity. |
||
return django_user.to_entity() | ||
|
||
def save_board(self, board): | ||
|
@@ -98,6 +100,7 @@ def delete_board_user(self, user_id, board_id): | |
raise self.DoesNotExist('User {} is not joined to board {}'.format(user_id, board_id)) | ||
|
||
django_board_user.delete() | ||
# nizar: interesting choice here, not sure why it returns this kind of object | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this should return an entity to be consistent right? |
||
return django_board_user.asdict() | ||
|
||
def delete_board(self, id): | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
|
||
from .storage import Storage | ||
|
||
# nizar: very cool exercise for leveraging the advantages of having a common interface for a repo | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah this makes it clear why you want to abstract the repository so you can switch between django storage and memory storage easily and test the business rules. |
||
class MemoryStorage(Storage): | ||
"""Adapter to use system memory as a storage backend.""" | ||
|
||
|
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.
Do you mean what you call
repo_provider
in your code? So theUser.objects
here?