-
Notifications
You must be signed in to change notification settings - Fork 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
Sourcery refactored master branch #9
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 |
---|---|---|
|
@@ -23,7 +23,7 @@ class Meta: | |
verbose_name_plural = 'Заказы(ов)' | ||
|
||
def __str__(self): | ||
return 'Order {}'.format(self.id) | ||
return f'Order {self.id}' | ||
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
|
||
|
||
def get_total_cost(self): | ||
return sum(item.get_cost() for item in self.items.all()) | ||
|
@@ -41,7 +41,7 @@ class Meta: | |
verbose_name_plural = 'Заказанные товары' | ||
|
||
def __str__(self): | ||
return '{}'.format(self.id) | ||
return f'{self.id}' | ||
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
|
||
|
||
def get_cost(self): | ||
return self.price * self.quantity |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,8 +6,8 @@ | |
|
||
def order_create(request): | ||
cart = Cart(request) | ||
user = request.user | ||
if request.method == 'POST': | ||
user = request.user | ||
Comment on lines
+9
to
-10
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
|
||
if user.is_authenticated: | ||
data = {"last_name": user.last_name, "first_name": user.first_name, "email": user.email} | ||
form = OrderCreateForm(request.POST, initial=data) | ||
|
@@ -26,7 +26,6 @@ def order_create(request): | |
cart.clear() | ||
return render(request, 'orders/created.html', {'order': order}) | ||
else: | ||
user = request.user | ||
data = {} | ||
if user.is_authenticated: | ||
data["last_name"] = user.last_name | ||
|
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
UserEmailBackend.authenticate
refactored with the following changes:assign-if-exp
)