diff --git a/core/migrations/0002_profile.py b/core/migrations/0002_profile.py new file mode 100644 index 0000000..59e8595 --- /dev/null +++ b/core/migrations/0002_profile.py @@ -0,0 +1,24 @@ +# Generated by Django 4.1 on 2022-08-06 06:56 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Profile', + fields=[ + ('user', models.OneToOneField(on_delete=django.db.models.deletion.PROTECT, primary_key=True, serialize=False, to=settings.AUTH_USER_MODEL)), + ('first_name', models.CharField(max_length=128)), + ('last_name', models.CharField(max_length=128)), + ('display_name', models.CharField(max_length=128)), + ], + ), + ] diff --git a/core/models/__init__.py b/core/models/__init__.py index 37d673b..6130f2f 100644 --- a/core/models/__init__.py +++ b/core/models/__init__.py @@ -1,2 +1,7 @@ from .auth import User -from .profiles import Profile \ No newline at end of file +from .profiles import Profile +from .businesses import Chain, Restaurant +from .geo import Location +from .media import Image +from .reservation import Reservation +from .layout import Room, Table \ No newline at end of file diff --git a/core/models/billing.py b/core/models/billing.py index ade1466..1912adb 100644 --- a/core/models/billing.py +++ b/core/models/billing.py @@ -1,22 +1,49 @@ from django.db import models from django.utils.translation import gettext as _ +from django.contrib.contenttypes.fields import GenericForeignKey +from django.contrib.contenttypes.models import ContentType + +from .profiles import Profile class ExpenseTypeChoices(models.IntegerChoices): + """Defines different types of expenses + """ MONTHLY_FEE = (0, _("Monthly Fee")) SUPPORT = (1, _("Support")) DEVELOPMENT = (2, _("Custom Development")) COMMISSION = (3, _("Commission")) CONTRIBUTION = (4, _("Contribution")) - - -class RelatedModelChoices(models.IntegerChoices): - CHAIN = (0, _("Chain")) - RESTAURANT = (1, _("Restaurant")) - ROOM = (2, _("Room")) - TABLE = (3, _("Table")) + OTHER = (99, _("Various Expenses")) class Expense(models.Model): - expense_type = models.IntegerField(choices=ExpenseTypeChoices.choices(), null=True, blank=True) + """Contains information on an individual expense to be invoiced + + By relation to an Invoice model, this is simultaneously an invoice item + """ + expense_type = models.IntegerField( + choices=ExpenseTypeChoices.choices, null=True, blank=True) text = models.CharField(max_length=256) + payer = models.ForeignKey(Profile, models.PROTECT) + + """Of course, an Expense needs + """ + + """An activity leading to an expense can have a starting and ending date + (the day a reservation was made in case of per-reservation commissions, + or the month for which a monthly fee is due) - but this is optional. + """ + datetime_from = models.DateTimeField(null=True, blank=True) + datetime_to = models.DateTimeField(null=True, blank=True) + + """An expense can be related to any other object in the database – for + example, it can be related to a Reservation object for a per-reservation + commission, to a Restaurant object for its monthly fee, or to a Profile + object for a per-user fee. This also allows easy reverse lookups to find + out which expenses have occurred for which object. This is optional. + """ + object_type = models.ForeignKey( + ContentType, on_delete=models.CASCADE, null=True) + object_id = models.PositiveIntegerField(null=True, blank=True) + related_object = GenericForeignKey('object_type', 'object_id', null=True) diff --git a/modules/__init__.py b/management/__init__.py similarity index 100% rename from modules/__init__.py rename to management/__init__.py diff --git a/management/admin.py b/management/admin.py new file mode 100644 index 0000000..8c38f3f --- /dev/null +++ b/management/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/management/apps.py b/management/apps.py new file mode 100644 index 0000000..256c74d --- /dev/null +++ b/management/apps.py @@ -0,0 +1,6 @@ +from django.apps import AppConfig + + +class ManagementConfig(AppConfig): + default_auto_field = 'django.db.models.BigAutoField' + name = 'management' diff --git a/management/migrations/__init__.py b/management/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/management/models.py b/management/models.py new file mode 100644 index 0000000..71a8362 --- /dev/null +++ b/management/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/management/tests.py b/management/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/management/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/management/views.py b/management/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/management/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/requirements.txt b/requirements.txt index 536e1a7..67bc7dd 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,6 +6,7 @@ geopy django-countries[pyuca] pillow django-phonenumber-field[phonenumbers] +django-money # For S3 diff --git a/restoroo/settings.py b/restoroo/settings.py index e691fca..daac2db 100644 --- a/restoroo/settings.py +++ b/restoroo/settings.py @@ -30,7 +30,9 @@ INSTALLED_APPS = [ 'phonenumber_field', 'core', - + 'myrestaurant', + 'management', + 'public', ] AUTH_USER_MODEL = "core.User" @@ -51,7 +53,7 @@ ROOT_URLCONF = 'restoroo.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [BASE_DIR / "templates"], + 'DIRS': [BASE_DIR / "frontend/templates"], 'APP_DIRS': False, 'OPTIONS': { 'context_processors': [ diff --git a/restoroo/urls.py b/restoroo/urls.py index cd0320f..ecefb60 100644 --- a/restoroo/urls.py +++ b/restoroo/urls.py @@ -17,5 +17,4 @@ from django.contrib import admin from django.urls import path urlpatterns = [ - path('admin/', admin.site.urls), ]