Made models

This commit is contained in:
MassiveAtoms 2020-05-24 12:00:10 -03:00
commit ce1080d7f2
27 changed files with 412 additions and 0 deletions

BIN
db.sqlite3 Normal file

Binary file not shown.

0
houtmarkt/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

16
houtmarkt/asgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
ASGI config for houtmarkt project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'houtmarkt.settings')
application = get_asgi_application()

121
houtmarkt/settings.py Normal file
View File

@ -0,0 +1,121 @@
"""
Django settings for houtmarkt project.
Generated by 'django-admin startproject' using Django 3.0.6.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'n2h_6t5qnp8zvke(%a%ph)xj4h8w+kgg46pld0r2^ndcme3el6'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
"markt"
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]
ROOT_URLCONF = 'houtmarkt.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'houtmarkt.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
# https://docs.djangoproject.com/en/3.0/ref/settings/#auth-password-validators
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
# https://docs.djangoproject.com/en/3.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'America/Paramaribo'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'

36
houtmarkt/urls.py Normal file
View File

@ -0,0 +1,36 @@
"""houtmarkt URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path
from django.urls import include
urlpatterns = [
path('markt/', include('markt.urls')),
path('admin/', admin.site.urls),
]
from django.views.generic import RedirectView
urlpatterns += [
path('', RedirectView.as_view(url='markt/', permanent=True)),
]
# Use static() to add url mapping to serve static files during development (only)
from django.conf import settings
from django.conf.urls.static import static
urlpatterns += static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

16
houtmarkt/wsgi.py Normal file
View File

@ -0,0 +1,16 @@
"""
WSGI config for houtmarkt project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'houtmarkt.settings')
application = get_wsgi_application()

21
manage.py Normal file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'houtmarkt.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()

0
markt/__init__.py Normal file
View File

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

9
markt/admin.py Normal file
View File

@ -0,0 +1,9 @@
from django.contrib import admin
from .models import Factuur, Formaat, Houtmarkt, Houtsoort, Klant, Voorraad
admin.site.register(Factuur)
admin.site.register(Formaat)
admin.site.register(Houtsoort)
admin.site.register(Houtmarkt)
admin.site.register(Klant)
admin.site.register(Voorraad)

5
markt/apps.py Normal file
View File

@ -0,0 +1,5 @@
from django.apps import AppConfig
class MarktConfig(AppConfig):
name = 'markt'

View File

@ -0,0 +1,74 @@
# Generated by Django 3.0.6 on 2020-05-24 14:55
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Formaat',
fields=[
('Format_ID', models.AutoField(primary_key=True, serialize=False)),
('Formaat', models.CharField(help_text='Formaat (vb 2x4)', max_length=255)),
('Lengte', models.FloatField()),
],
),
migrations.CreateModel(
name='Houtmarkt',
fields=[
('Houtmarkt_ID', models.AutoField(primary_key=True, serialize=False)),
('Houtmarkt_naam', models.CharField(help_text='Houtmarkt naam', max_length=255)),
('Houtmarkt_tel', models.IntegerField()),
('Houtmarkt_addr', models.CharField(max_length=255)),
('Houtmarkt_type', models.BooleanField()),
],
),
migrations.CreateModel(
name='Houtsoort',
fields=[
('Hout_ID', models.AutoField(primary_key=True, serialize=False)),
('Houtsoort_naam', models.CharField(help_text='Houtsoort', max_length=255)),
],
),
migrations.CreateModel(
name='Klant',
fields=[
('Klant_ID', models.AutoField(primary_key=True, serialize=False)),
('Klant_naam', models.CharField(help_text='Klant naam', max_length=255)),
('Klant_tel', models.CharField(help_text='Klant telefoon nummer', max_length=255)),
('Klant_Addr', models.CharField(help_text='Klant Adres', max_length=255)),
('Is_Houtmarkt', models.BooleanField()),
],
),
migrations.CreateModel(
name='Voorraad',
fields=[
('Voorraad_ID', models.AutoField(primary_key=True, serialize=False)),
('prijs', models.FloatField()),
('Voorraad_Amount', models.IntegerField()),
('Format_ID', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='markt.Formaat')),
('Hout_ID', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='markt.Houtsoort')),
('Houtmarkt_ID', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='markt.Houtmarkt')),
],
),
migrations.CreateModel(
name='Factuur',
fields=[
('Factuur_ID', models.AutoField(primary_key=True, serialize=False)),
('Korting_percent', models.FloatField()),
('AMT_Sold', models.IntegerField()),
('Subtotal', models.FloatField()),
('total', models.FloatField()),
('Houtmarkt_ID', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='markt.Houtmarkt')),
('Klant_ID', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='markt.Klant')),
('Voorraad_ID', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='markt.Voorraad')),
],
),
]

View File

Binary file not shown.

102
markt/models.py Normal file
View File

@ -0,0 +1,102 @@
from django.db import models
# Used to generate URLs by reversing the URL patterns
from django.urls import reverse
# Create your models here.
class Houtsoort(models.Model):
Hout_ID = models.AutoField(primary_key=True)
Houtsoort_naam = models.CharField(max_length=255, help_text='Houtsoort')
def get_absolute_url(self):
"""Returns the url to access a particular instance of the model."""
return reverse('model-detail-view', args=[str(self.Hout_ID)])
def __str__(self):
"""String for representing the Model object."""
return self.Houtsoort_naam
class Formaat(models.Model):
Format_ID = models.AutoField(primary_key=True)
Formaat = models.CharField(max_length=255, help_text='Formaat (vb 2x4)')
Lengte = models.FloatField()
def get_absolute_url(self):
"""Returns the url to access a particular instance of the model."""
return reverse('model-detail-view', args=[str(self.Format_ID)])
def __str__(self):
"""String for representing the Model object."""
return self.Formaat
class Houtmarkt(models.Model):
Houtmarkt_ID = models.AutoField(primary_key=True)
Houtmarkt_naam = models.CharField(
max_length=255, help_text='Houtmarkt naam')
Houtmarkt_tel = models.IntegerField()
Houtmarkt_addr = models.CharField(max_length=255)
Houtmarkt_type = models.BooleanField()
def get_absolute_url(self):
"""Returns the url to access a particular instance of the model."""
return reverse('model-detail-view', args=[str(self.Houtmarkt_ID)])
def __str__(self):
"""String for representing the Model object."""
return self.Houtmarkt_naam
class Voorraad(models.Model):
Voorraad_ID = models.AutoField(primary_key=True)
Houtmarkt_ID = models.ForeignKey("Houtmarkt", on_delete=models.CASCADE)
Hout_ID = models.ForeignKey("Houtsoort", on_delete=models.CASCADE)
Format_ID = models.ForeignKey("Formaat", on_delete=models.CASCADE)
prijs = models.FloatField()
Voorraad_Amount = models.IntegerField()
def get_absolute_url(self):
"""Returns the url to access a particular instance of the model."""
return reverse('model-detail-view', args=[str(self.Voorraad_ID)])
def __str__(self):
"""String for representing the Model object."""
return self.Voorraad_ID
class Klant(models.Model):
Klant_ID = models.AutoField(primary_key=True)
Klant_naam = models.CharField(max_length=255, help_text='Klant naam')
Klant_tel = models.CharField(
max_length=255, help_text='Klant telefoon nummer')
Klant_Addr = models.CharField(max_length=255, help_text='Klant Adres')
Is_Houtmarkt = models.BooleanField()
def get_absolute_url(self):
"""Returns the url to access a particular instance of the model."""
return reverse('model-detail-view', args=[str(self.Klant_ID)])
def __str__(self):
"""String for representing the Model object."""
return self.Klant_naam
class Factuur(models.Model):
Factuur_ID = models.AutoField(primary_key=True)
Voorraad_ID = models.ForeignKey("Voorraad", on_delete=models.CASCADE)
Klant_ID = models.ForeignKey("Klant", on_delete=models.CASCADE)
Houtmarkt_ID = models.ForeignKey("Houtmarkt", on_delete=models.CASCADE)
Korting_percent = models.FloatField()
AMT_Sold = models.IntegerField()
Subtotal = models.FloatField()
total = models.FloatField()
def get_absolute_url(self):
"""Returns the url to access a particular instance of the model."""
return reverse('model-detail-view', args=[str(self.Factuur_ID)])
def __str__(self):
"""String for representing the Model object."""
return self.Factuur_ID

3
markt/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

6
markt/urls.py Normal file
View File

@ -0,0 +1,6 @@
from django.urls import path
from . import views
urlpatterns = [
]

3
markt/views.py Normal file
View File

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.