Add empty index.html such as not to get that 404

Add CostField as a shorthand DecimalField
This commit is contained in:
Kumi 2020-06-04 08:03:35 +02:00
parent b376a167ed
commit e69006ab35
13 changed files with 63 additions and 19 deletions

View file

@ -1,2 +1,3 @@
from core.fields.base import LongCharField
from core.fields.color import ColorField
from core.fields.color import ColorField
from core.fields.numbers import CostField

7
core/fields/numbers.py Normal file
View file

@ -0,0 +1,7 @@
from django.db.models import DecimalField
class CostField(DecimalField):
def __init__(self, *args, **kwargs):
kwargs['max_digits'] = 32
kwargs['decimal_places'] = 2
super().__init__(*args, **kwargs)

View file

@ -1,4 +1,15 @@
from django.db.models import IntegerChoices, Model
from django.db.models import IntegerChoices, Model, ForeignKey, CASCADE, TextField, PositiveIntegerField, BooleanField, DateField
from core.models.profiles import ClientProfile
from core.models.brands import Brand
from core.fields.base import LongCharField
from core.fields.numbers import CostField
class ActionChoices(IntegerChoices):
WAIT = 0, "Do not invoice for now"
NEXT = 1, "Add to client's next invoice"
CRON = 2, "Invoice at next cron run"
DATE = 3, "Invoice at date"
class CycleChoices(IntegerChoices):
DAYS = 0, "Days"
@ -7,4 +18,14 @@ class CycleChoices(IntegerChoices):
YEARS = 3, "Years"
class Billable(Model):
pass
client = ForeignKey(ClientProfile, on_delete=CASCADE)
brand = ForeignKey(Brand, on_delete=CASCADE)
name = LongCharField()
description = TextField()
individual_cost = CostField()
amount = PositiveIntegerField()
taxable = BooleanField()
action = PositiveIntegerField(choices=ActionChoices.choices)
date = DateField(null=True)
recur_cycle = PositiveIntegerField(choices=CycleChoices.choices, null=True)
recur_count = PositiveIntegerField(null=True)

View file

@ -1,6 +1,7 @@
from django.db.models import Model, ForeignKey, CASCADE, PositiveIntegerField, TextField, DecimalField, BooleanField, DateField, SET_NULL, PROTECT
from django.db.models import Model, ForeignKey, CASCADE, PositiveIntegerField, TextField, BooleanField, DateField, SET_NULL, PROTECT
from core.fields.base import LongCharField
from core.fields.numbers import CostField
from core.models.services import Service
from core.models.profiles import ClientProfile
from core.models.local import Currency
@ -18,7 +19,7 @@ class InvoiceItem(Model):
sort = PositiveIntegerField()
name = LongCharField()
description = TextField(blank=True, null=True)
price = DecimalField(max_digits=32, decimal_places=2)
discount = DecimalField(max_digits=32, decimal_places=2)
price = CostField()
discount = CostField()
taxable = BooleanField()
service = ForeignKey(Service, on_delete=SET_NULL, null=True)

View file

@ -1,8 +1,9 @@
from core.models.billable import CycleChoices
from core.fields.base import LongCharField
from core.fields.color import ColorField
from core.fields.numbers import CostField
from django.db.models import Model, IntegerChoices, PositiveIntegerField, DecimalField, ForeignKey, CASCADE, CharField, TextField, ManyToManyField
from django.db.models import Model, IntegerChoices, PositiveIntegerField, ForeignKey, CASCADE, CharField, TextField, ManyToManyField
from importlib import import_module
@ -37,4 +38,4 @@ class ProductPlanItem(Model):
plan = ForeignKey(ProductPlan, on_delete=CASCADE)
cycle = PositiveIntegerField(choices=CycleChoices.choices)
count = PositiveIntegerField()
cost = DecimalField(max_digits=30, decimal_places=2)
cost = CostField()

View file

@ -1,7 +1,8 @@
from core.models.billable import CycleChoices
from core.models.products import ProductGroup
from core.fields.numbers import CostField
from django.db.models import Model, TextField, CharField, ManyToManyField, ForeignKey, CASCADE, PositiveIntegerField, DecimalField, OneToOneField
from django.db.models import Model, TextField, CharField, ManyToManyField, ForeignKey, CASCADE, PositiveIntegerField, OneToOneField
from importlib import import_module
from logging import getLogger
@ -38,4 +39,4 @@ class ServicePlanItem(Model):
plan = ForeignKey(ServicePlan, on_delete=CASCADE)
cycle = PositiveIntegerField(choices=CycleChoices.choices)
count = PositiveIntegerField()
cost = DecimalField(max_digits=30, decimal_places=2)
cost = CostField()

View file

@ -1,9 +1,10 @@
from core.modules.urls import URLPATTERNS as modulepatterns
from core.urls.auth import urlpatterns as authpatterns
from core.urls.backend import urlpatterns as backendpatterns
from core.urls.frontend import urlpatterns as frontendpatterns
from django.urls import path
corepatterns = authpatterns + backendpatterns
corepatterns = authpatterns + backendpatterns + frontendpatterns
urlpatterns = corepatterns + modulepatterns

7
core/urls/frontend.py Normal file
View file

@ -0,0 +1,7 @@
from django.urls import path
from core.views.frontend import IndexView
urlpatterns = []
urlpatterns.append(path('', IndexView.as_view(), name="index"))

View file

@ -1,9 +1,2 @@
from core.views.backend import *
class IndexView(TemplateView):
template_name = f"{settings.EXPEPHALON_FRONTEND}/index.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["title"] = "Home"
return context
from core.views.frontend import *

View file

View file

@ -0,0 +1,10 @@
from django.views.generic import TemplateView
from django.conf import settings
class IndexView(TemplateView):
template_name = f"{settings.EXPEPHALON_FRONTEND}/index.html"
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context["title"] = "Home"
return context

View file

@ -180,6 +180,7 @@
</div>
</div> <div class="app-main__outer">
<div class="app-main__inner">
{% bootstrap_messages %}
{% block content %}{% endblock %}
<!-- No idea what part of it, but something in there makes the sidebar's scrollbar appear. So I'll just leave it there. -->
<div style="display:none;" class="row">

View file