diff --git a/BudMan/__pycache__/settings.cpython-38.pyc b/BudMan/__pycache__/settings.cpython-38.pyc index 9b5363a..1b63595 100644 Binary files a/BudMan/__pycache__/settings.cpython-38.pyc and b/BudMan/__pycache__/settings.cpython-38.pyc differ diff --git a/BudMan/__pycache__/urls.cpython-38.pyc b/BudMan/__pycache__/urls.cpython-38.pyc index c16385a..3bf5e15 100644 Binary files a/BudMan/__pycache__/urls.cpython-38.pyc and b/BudMan/__pycache__/urls.cpython-38.pyc differ diff --git a/BudMan/settings.py b/BudMan/settings.py index 1bc1993..8740f34 100644 --- a/BudMan/settings.py +++ b/BudMan/settings.py @@ -1,15 +1,3 @@ -""" -Django settings for BudMan project. - -Generated by 'django-admin startproject' using Django 3.2.8. - -For more information on this file, see -https://docs.djangoproject.com/en/3.2/topics/settings/ - -For the full list of settings and their values, see -https://docs.djangoproject.com/en/3.2/ref/settings/ -""" - from pathlib import Path # Build paths inside the project like this: BASE_DIR / 'subdir'. @@ -37,7 +25,8 @@ 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', - 'app.apps.AppConfig', + 'api.apps.ApiConfig', + 'frontend.apps.FrontendConfig', ] MIDDLEWARE = [ diff --git a/BudMan/urls.py b/BudMan/urls.py index 44f0522..410de56 100644 --- a/BudMan/urls.py +++ b/BudMan/urls.py @@ -3,5 +3,6 @@ urlpatterns = [ path('admin/', admin.site.urls), - path('shop/', include('app.urls')), + path('api/', include('api.urls')), + path('', include('frontend.urls')), ] \ No newline at end of file diff --git a/app/__init__.py b/api/__init__.py similarity index 100% rename from app/__init__.py rename to api/__init__.py diff --git a/api/admin.py b/api/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/api/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/app/apps.py b/api/apps.py similarity index 67% rename from app/apps.py rename to api/apps.py index ed327d2..66656fd 100644 --- a/app/apps.py +++ b/api/apps.py @@ -1,6 +1,6 @@ from django.apps import AppConfig -class AppConfig(AppConfig): +class ApiConfig(AppConfig): default_auto_field = 'django.db.models.BigAutoField' - name = 'app' + name = 'api' diff --git a/app/migrations/__init__.py b/api/migrations/__init__.py similarity index 100% rename from app/migrations/__init__.py rename to api/migrations/__init__.py diff --git a/api/models.py b/api/models.py new file mode 100644 index 0000000..137941f --- /dev/null +++ b/api/models.py @@ -0,0 +1 @@ +from django.db import models diff --git a/app/tests.py b/api/tests.py similarity index 100% rename from app/tests.py rename to api/tests.py diff --git a/api/urls.py b/api/urls.py new file mode 100644 index 0000000..96afd02 --- /dev/null +++ b/api/urls.py @@ -0,0 +1,6 @@ +from django.urls import path + +from .views import * +urlpatterns = [ + # path('', home), +] \ No newline at end of file diff --git a/api/views.py b/api/views.py new file mode 100644 index 0000000..e69de29 diff --git a/app/__pycache__/__init__.cpython-38.pyc b/app/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index c7bc87f..0000000 Binary files a/app/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/app/__pycache__/admin.cpython-38.pyc b/app/__pycache__/admin.cpython-38.pyc deleted file mode 100644 index d9f2d7b..0000000 Binary files a/app/__pycache__/admin.cpython-38.pyc and /dev/null differ diff --git a/app/__pycache__/apps.cpython-38.pyc b/app/__pycache__/apps.cpython-38.pyc deleted file mode 100644 index 9398ad5..0000000 Binary files a/app/__pycache__/apps.cpython-38.pyc and /dev/null differ diff --git a/app/__pycache__/models.cpython-38.pyc b/app/__pycache__/models.cpython-38.pyc deleted file mode 100644 index 820a6b0..0000000 Binary files a/app/__pycache__/models.cpython-38.pyc and /dev/null differ diff --git a/app/__pycache__/urls.cpython-38.pyc b/app/__pycache__/urls.cpython-38.pyc deleted file mode 100644 index 52479a4..0000000 Binary files a/app/__pycache__/urls.cpython-38.pyc and /dev/null differ diff --git a/app/__pycache__/views.cpython-38.pyc b/app/__pycache__/views.cpython-38.pyc deleted file mode 100644 index 041111f..0000000 Binary files a/app/__pycache__/views.cpython-38.pyc and /dev/null differ diff --git a/app/admin.py b/app/admin.py deleted file mode 100644 index fc85b8e..0000000 --- a/app/admin.py +++ /dev/null @@ -1,5 +0,0 @@ -from django.contrib import admin -from app.models import Item, Purchase - -admin.site.register(Item) -admin.site.register(Purchase) \ No newline at end of file diff --git a/app/management/commands/populate_db.py b/app/management/commands/populate_db.py deleted file mode 100644 index 474d83e..0000000 --- a/app/management/commands/populate_db.py +++ /dev/null @@ -1,38 +0,0 @@ - -import random -from datetime import datetime, timedelta - -import pytz -from django.core.management.base import BaseCommand - -from app.models import Item, Purchase - - -class Command(BaseCommand): - help = 'Populates the database with random generated data.' - - def add_arguments(self, parser): - parser.add_argument('--amount', type=int, help='The number of purchases that should be created.') - - def handle(self, *args, **options): - names = ['James', 'John', 'Robert', 'Michael', 'William', 'David', 'Richard', 'Joseph', 'Thomas', 'Charles'] - surname = ['Smith', 'Jones', 'Taylor', 'Brown', 'Williams', 'Wilson', 'Johnson', 'Davies', 'Patel', 'Wright'] - items = [ - Item.objects.get_or_create(name='Socks', price=6.5), Item.objects.get_or_create(name='Pants', price=12), - Item.objects.get_or_create(name='T-Shirt', price=8), Item.objects.get_or_create(name='Boots', price=9), - Item.objects.get_or_create(name='Sweater', price=3), Item.objects.get_or_create(name='Underwear', price=9), - Item.objects.get_or_create(name='Leggings', price=7), Item.objects.get_or_create(name='Cap', price=5), - ] - amount = options['amount'] if options['amount'] else 2500 - for i in range(0, amount): - dt = pytz.utc.localize(datetime.now() - timedelta(days=random.randint(0, 1825))) - purchase = Purchase.objects.create( - customer_full_name=random.choice(names) + ' ' + random.choice(surname), - item=random.choice(items)[0], - payment_method=random.choice(Purchase.PAYMENT_METHODS)[0], - successful=True if random.randint(1, 2) == 1 else False, - ) - purchase.time = dt - purchase.save() - - self.stdout.write(self.style.SUCCESS('Successfully populated the database.')) \ No newline at end of file diff --git a/app/migrations/0001_initial.py b/app/migrations/0001_initial.py deleted file mode 100644 index ca03c53..0000000 --- a/app/migrations/0001_initial.py +++ /dev/null @@ -1,38 +0,0 @@ -# Generated by Django 4.0 on 2021-12-17 14:11 - -from django.db import migrations, models -import django.db.models.deletion - - -class Migration(migrations.Migration): - - initial = True - - dependencies = [ - ] - - operations = [ - migrations.CreateModel( - name='Item', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=255)), - ('description', models.TextField(null=True)), - ('price', models.FloatField(default=0)), - ], - ), - migrations.CreateModel( - name='Purchase', - fields=[ - ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('customer_full_name', models.CharField(max_length=64)), - ('payment_method', models.CharField(choices=[('CC', 'Credit card'), ('DC', 'Debit card'), ('ET', 'Ethereum'), ('BC', 'Bitcoin')], default='CC', max_length=2)), - ('time', models.DateTimeField(auto_now_add=True)), - ('successful', models.BooleanField(default=False)), - ('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='app.item')), - ], - options={ - 'ordering': ['-time'], - }, - ), - ] diff --git a/app/migrations/__pycache__/__init__.cpython-38.pyc b/app/migrations/__pycache__/__init__.cpython-38.pyc deleted file mode 100644 index 4ec2e7b..0000000 Binary files a/app/migrations/__pycache__/__init__.cpython-38.pyc and /dev/null differ diff --git a/app/models.py b/app/models.py deleted file mode 100644 index ab64283..0000000 --- a/app/models.py +++ /dev/null @@ -1,29 +0,0 @@ -from django.db import models - -class Item(models.Model): - name = models.CharField(max_length=255) - description = models.TextField(null=True) - price = models.FloatField(default=0) - - def __str__(self): - return f'{self.name} (${self.price})' - - -class Purchase(models.Model): - customer_full_name = models.CharField(max_length=64) - item = models.ForeignKey(to=Item, on_delete=models.CASCADE) - PAYMENT_METHODS = [ - ('CC', 'Credit card'), - ('DC', 'Debit card'), - ('ET', 'Ethereum'), - ('BC', 'Bitcoin'), - ] - payment_method = models.CharField(max_length=2, default='CC', choices=PAYMENT_METHODS) - time = models.DateTimeField(auto_now_add=True) - successful = models.BooleanField(default=False) - - class Meta: - ordering = ['-time'] - - def __str__(self): - return f'{self.customer_full_name}, {self.payment_method} ({self.item.name})' \ No newline at end of file diff --git a/app/templates/app/statistics.html b/app/templates/app/statistics.html deleted file mode 100644 index d4a2861..0000000 --- a/app/templates/app/statistics.html +++ /dev/null @@ -1,138 +0,0 @@ - - -
-