-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4fa1622
commit a8bffd5
Showing
5 changed files
with
161 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
from typing import Any | ||
import faker | ||
import random | ||
|
||
from django.core.management.base import BaseCommand, CommandParser | ||
from django.contrib.auth import get_user_model | ||
|
||
|
||
User = get_user_model() | ||
|
||
faker = faker.Faker() | ||
|
||
|
||
class Command(BaseCommand): | ||
def add_arguments(self, parser: CommandParser) -> None: | ||
parser.add_argument("quantity", help="Number of items per model", default=10) | ||
return super().add_arguments(parser) | ||
|
||
def handle(self, *args: Any, **options: Any) -> str | None: | ||
print(options.get("quantity")) | ||
|
||
self.stdout.write( | ||
self.style.SUCCESS(f"Creating elements for the database."), | ||
) | ||
|
||
def create_customers_data(self): | ||
"""Create fake customer data""" | ||
|
||
def craete_orders_data(self): | ||
"""Create data for order and orderitems""" | ||
|
||
def create_users_data(self, quantity): | ||
"""Create data for users""" | ||
for _ in range(quantity): | ||
user = User.objects.create( | ||
username=faker.user_name(), | ||
email=faker.email(), | ||
first_name=faker.first_name(), | ||
last_name=faker.last_name(), | ||
) | ||
password = faker.password() | ||
user.set_password(password) | ||
user.save() |
41 changes: 41 additions & 0 deletions
41
src/apps/orders/migrations/0002_order_sales_man_order_total_price_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Generated by Django 5.0 on 2023-12-26 20:58 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("orders", "0001_initial"), | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="order", | ||
name="sales_man", | ||
field=models.ForeignKey( | ||
blank=True, | ||
null=True, | ||
on_delete=django.db.models.deletion.SET_NULL, | ||
related_name="orders_performed", | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="order", | ||
name="total_price", | ||
field=models.DecimalField( | ||
decimal_places=2, | ||
default=0.0, | ||
max_digits=10, | ||
verbose_name="Total Order Price", | ||
), | ||
), | ||
migrations.AddField( | ||
model_name="order", | ||
name="transaction_id", | ||
field=models.CharField(default=True, max_length=15, null=True), | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters