-
Notifications
You must be signed in to change notification settings - Fork 2
Sourcery Starbot ⭐ refactored BQBB/05-commerce #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: main
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 |
|---|---|---|
|
|
@@ -9,7 +9,7 @@ | |
|
|
||
| class CustomUserManager(UserManager): | ||
| def get_by_natural_key(self, username): | ||
| case_insensitive_username_field = '{}__iexact'.format(self.model.USERNAME_FIELD) | ||
| case_insensitive_username_field = f'{self.model.USERNAME_FIELD}__iexact' | ||
|
Author
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. Function
|
||
| return self.get(**{case_insensitive_username_field: username}) | ||
|
|
||
| def create_user(self, first_name, last_name, email, password=None): | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,8 +109,9 @@ def list_products( | |
| @check_pk | ||
| def list_addresses(request): | ||
|
|
||
| addresses = Address.objects.select_related('city', 'user').filter(user=User.objects.get(id=request.auth['pk'])) | ||
| if addresses: | ||
| if addresses := Address.objects.select_related('city', 'user').filter( | ||
| user=User.objects.get(id=request.auth['pk']) | ||
| ): | ||
|
Comment on lines
-112
to
+114
Author
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. Function
|
||
| return addresses | ||
| return 404, {'detail': 'No addresses found'} | ||
|
|
||
|
|
@@ -125,9 +126,7 @@ def list_addresses(request): | |
| 404: MessageOut | ||
| }) | ||
| def list_cities(request): | ||
| cities_qs = City.objects.all() | ||
|
|
||
| if cities_qs: | ||
| if cities_qs := City.objects.all(): | ||
|
Comment on lines
-128
to
+129
Author
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. Function
|
||
| return cities_qs | ||
|
|
||
| return 404, {'detail': 'No cities found'} | ||
|
|
@@ -188,9 +187,9 @@ def delete_city(request, id: UUID4): | |
| @check_pk | ||
| def view_cart(request): | ||
|
|
||
| cart_items = Item.objects.filter(user=User.objects.get(id=request.auth['pk']), ordered=False) | ||
|
|
||
| if cart_items: | ||
| if cart_items := Item.objects.filter( | ||
| user=User.objects.get(id=request.auth['pk']), ordered=False | ||
| ): | ||
|
Comment on lines
-191
to
+192
Author
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. Function
|
||
| return cart_items | ||
|
|
||
| return 404, {'detail': 'Your cart is empty, go shop like crazy!'} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -127,9 +127,7 @@ class Category(Entity): | |
|
|
||
|
|
||
| def __str__(self): | ||
| if self.parent: | ||
| return f'- {self.name}' | ||
| return f'{self.name}' | ||
| return f'- {self.name}' if self.parent else f'{self.name}' | ||
|
Author
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. Function
|
||
|
|
||
| class Meta: | ||
| verbose_name = 'category' | ||
|
|
||
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.
Function
AccountUpdateForm.clean_emailrefactored with the following changes:replace-interpolation-with-fstring)