Skip to content

Commit

Permalink
Flake8 fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
mpushki committed Aug 1, 2024
1 parent fbdf4ec commit a01e9cf
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 26 deletions.
15 changes: 4 additions & 11 deletions app/accounts/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@ class AccountAdmin(UserAdmin):
ordering = ["email"]

fieldsets = [
["User additional data", {"fields": ["name"]}],
[
"Authorization",
{"fields": ["is_superuser", "groups", "user_permissions"]},
],
["Authentication", {"fields": ["email", "password"]}],
["Personal info", {"fields": ["name"]}],
["Permissions", {"fields": ["is_superuser", "groups", "user_permissions"]}],
[None, {"fields": ["email", "password"]}],
]
add_fieldsets = [
[
"Authorization",
{"fields": ["is_superuser", "groups", "user_permissions"]},
],
["Authenticated", {"fields": ["email", "password1", "password2"]}],
[None, {"fields": ["email", "password1", "password2"]}],
]


Expand Down
18 changes: 18 additions & 0 deletions app/bikes/migrations/0002_alter_bike_price.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 5.0.7 on 2024-08-01 19:57

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('bikes', '0001_initial'),
]

operations = [
migrations.AlterField(
model_name='bike',
name='price',
field=models.DecimalField(decimal_places=1, max_digits=10),
),
]
13 changes: 3 additions & 10 deletions app/bikes/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,10 @@

class Bike(models.Model):
model = models.CharField(max_length=50)
price = models.DecimalField(
max_digits=8,
decimal_places=2
)
price = models.DecimalField(max_digits=10, decimal_places=1)
rent_is = models.BooleanField(default=False)
started_at = models.DateTimeField(
auto_now_add=True,
)
finished_at = models.DateTimeField(
auto_now=True,
)
started_at = models.DateTimeField(auto_now_add=True)
finished_at = models.DateTimeField(auto_now=True)

def __str__(self):
return self.model
5 changes: 2 additions & 3 deletions app/orders/models.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.db import models
from bikes.models import Bike
from accounts.models import Account
import time


class Order(models.Model):
bike = models.ForeignKey(Bike, on_delete=models.CASCADE)
Expand All @@ -14,8 +14,7 @@ class Order(models.Model):

def worth_calculation(self):
timediff = self.finished_at - self.started_at
cost_per_second = self.bike.price / 3600
self.worth = round(timediff.seconds * cost_per_second, 2)
self.worth = round(timediff.seconds * self.bike.price / 3600, 1)

def save(self, *args, **kwargs):
if self.finished_at:
Expand Down
2 changes: 1 addition & 1 deletion app/orders/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from django.test import TestCase
# from django.test import TestCase

# Create your tests here.
2 changes: 1 addition & 1 deletion app/orders/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ class OrderHistoryAPIView(generics.ListAPIView):
permission_classes = [IsAuthenticated]

def get_queryset(self):
return Order.objects.filter(tenant=self.request.user)
return Order.objects.filter(tenant=self.request.user)

0 comments on commit a01e9cf

Please sign in to comment.