initial
This commit is contained in:
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
.venv/
|
||||
__pycache__/
|
||||
db.sqlite3
|
||||
|
||||
|
28
Dockerfile
Normal file
28
Dockerfile
Normal file
@ -0,0 +1,28 @@
|
||||
FROM python:latest
|
||||
|
||||
LABEL Maintainer="Wolfgang Hottgenroth wolfgang.hottgenroth@icloud.com"
|
||||
|
||||
ARG APP_DIR="/opt/app"
|
||||
|
||||
|
||||
RUN \
|
||||
mkdir -p ${APP_DIR} && \
|
||||
useradd -d ${APP_DIR} -u 1000 user
|
||||
|
||||
COPY django_project/ ${APP_DIR}
|
||||
COPY requirements.txt ${APP_DIR}
|
||||
|
||||
WORKDIR ${APP_DIR}
|
||||
|
||||
RUN \
|
||||
pip3 install -r ./requirements.txt
|
||||
|
||||
USER 1000:1000
|
||||
|
||||
EXPOSE 5000
|
||||
EXPOSE 9191
|
||||
|
||||
CMD [ "uwsgi", "./wsgi.ini" ]
|
||||
|
||||
|
||||
|
0
django_project/default/__init__.py
Normal file
0
django_project/default/__init__.py
Normal file
3
django_project/default/admin.py
Normal file
3
django_project/default/admin.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.contrib import admin
|
||||
|
||||
# Register your models here.
|
6
django_project/default/apps.py
Normal file
6
django_project/default/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class DefaultConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'default'
|
0
django_project/default/migrations/__init__.py
Normal file
0
django_project/default/migrations/__init__.py
Normal file
3
django_project/default/models.py
Normal file
3
django_project/default/models.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.db import models
|
||||
|
||||
# Create your models here.
|
5
django_project/default/templates/about.html
Normal file
5
django_project/default/templates/about.html
Normal file
@ -0,0 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>About HV3</h1>
|
||||
{% endblock content %}
|
5
django_project/default/templates/home.html
Normal file
5
django_project/default/templates/home.html
Normal file
@ -0,0 +1,5 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<h1>HV3</h1>
|
||||
{% endblock content %}
|
3
django_project/default/tests.py
Normal file
3
django_project/default/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
8
django_project/default/urls.py
Normal file
8
django_project/default/urls.py
Normal file
@ -0,0 +1,8 @@
|
||||
from django.urls import path
|
||||
from .views import HomePageView, AboutPageView
|
||||
|
||||
urlpatterns = [
|
||||
path("", HomePageView.as_view(), name="home"),
|
||||
path("about/", AboutPageView.as_view(), name="about"),
|
||||
]
|
||||
|
9
django_project/default/views.py
Normal file
9
django_project/default/views.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.shortcuts import render
|
||||
from django.views.generic import TemplateView
|
||||
|
||||
# Create your views here.
|
||||
class HomePageView(TemplateView):
|
||||
template_name = "home.html"
|
||||
|
||||
class AboutPageView(TemplateView):
|
||||
template_name = "about.html"
|
0
django_project/django_project/__init__.py
Normal file
0
django_project/django_project/__init__.py
Normal file
16
django_project/django_project/asgi.py
Normal file
16
django_project/django_project/asgi.py
Normal file
@ -0,0 +1,16 @@
|
||||
"""
|
||||
ASGI config for django_project 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/4.0/howto/deployment/asgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.asgi import get_asgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_project.settings')
|
||||
|
||||
application = get_asgi_application()
|
126
django_project/django_project/settings.py
Normal file
126
django_project/django_project/settings.py
Normal file
@ -0,0 +1,126 @@
|
||||
"""
|
||||
Django settings for django_project project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 4.0.8.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/4.0/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/4.0/ref/settings/
|
||||
"""
|
||||
|
||||
from pathlib import Path
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/4.0/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret!
|
||||
SECRET_KEY = 'django-insecure-@quwidb)*3xovd&h^3mj#$kpzy_dxqy5v1l9z&@ou*_8i!2pg5'
|
||||
|
||||
# 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',
|
||||
'tenants.apps.TenantsConfig',
|
||||
'default.apps.DefaultConfig',
|
||||
]
|
||||
|
||||
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 = 'django_project.urls'
|
||||
|
||||
TEMPLATES = [
|
||||
{
|
||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||
'DIRS': [ BASE_DIR / "templates" ],
|
||||
'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 = 'django_project.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/4.0/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR / 'db.sqlite3',
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/4.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/4.0/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
TIME_ZONE = 'UTC'
|
||||
|
||||
USE_I18N = True
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/4.0/howto/static-files/
|
||||
|
||||
STATIC_URL = 'static/'
|
||||
STATICFILES_DIRS = [ BASE_DIR / "static" ]
|
||||
|
||||
# Default primary key field type
|
||||
# https://docs.djangoproject.com/en/4.0/ref/settings/#default-auto-field
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
23
django_project/django_project/urls.py
Normal file
23
django_project/django_project/urls.py
Normal file
@ -0,0 +1,23 @@
|
||||
"""django_project URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/4.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, include
|
||||
|
||||
urlpatterns = [
|
||||
path('admin/', admin.site.urls),
|
||||
path('', include("default.urls")),
|
||||
path('tenants', include("tenants.urls")),
|
||||
]
|
16
django_project/django_project/wsgi.py
Normal file
16
django_project/django_project/wsgi.py
Normal file
@ -0,0 +1,16 @@
|
||||
"""
|
||||
WSGI config for django_project 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/4.0/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_project.settings')
|
||||
|
||||
application = get_wsgi_application()
|
22
django_project/manage.py
Executable file
22
django_project/manage.py
Executable file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
"""Django's command-line utility for administrative tasks."""
|
||||
import os
|
||||
import sys
|
||||
|
||||
|
||||
def main():
|
||||
"""Run administrative tasks."""
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'django_project.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()
|
9
django_project/templates/base.html
Normal file
9
django_project/templates/base.html
Normal file
@ -0,0 +1,9 @@
|
||||
<header>
|
||||
<a href="{% url 'home' %}">Home</a> |
|
||||
<a href="{% url 'about' %}">About</a> |
|
||||
<a href="{% url 'tenants' %}">Tenants</a>
|
||||
</header>
|
||||
|
||||
{% block content %} {% endblock content %}
|
||||
|
||||
|
0
django_project/tenants/__init__.py
Normal file
0
django_project/tenants/__init__.py
Normal file
5
django_project/tenants/admin.py
Normal file
5
django_project/tenants/admin.py
Normal file
@ -0,0 +1,5 @@
|
||||
from django.contrib import admin
|
||||
from .models import Tenant
|
||||
|
||||
# Register your models here.
|
||||
admin.site.register(Tenant)
|
6
django_project/tenants/apps.py
Normal file
6
django_project/tenants/apps.py
Normal file
@ -0,0 +1,6 @@
|
||||
from django.apps import AppConfig
|
||||
|
||||
|
||||
class TenantsConfig(AppConfig):
|
||||
default_auto_field = 'django.db.models.BigAutoField'
|
||||
name = 'tenants'
|
22
django_project/tenants/migrations/0001_initial.py
Normal file
22
django_project/tenants/migrations/0001_initial.py
Normal file
@ -0,0 +1,22 @@
|
||||
# Generated by Django 4.0.8 on 2023-01-01 17:45
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
initial = True
|
||||
|
||||
dependencies = [
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Tenant',
|
||||
fields=[
|
||||
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('firstname', models.CharField(max_length=64)),
|
||||
('lastname', models.CharField(max_length=64)),
|
||||
],
|
||||
),
|
||||
]
|
@ -0,0 +1,68 @@
|
||||
# Generated by Django 4.0.8 on 2023-01-01 18:03
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('tenants', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='tenant',
|
||||
name='address1',
|
||||
field=models.CharField(default='', max_length=128),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='tenant',
|
||||
name='address2',
|
||||
field=models.CharField(default='', max_length=128),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='tenant',
|
||||
name='address3',
|
||||
field=models.CharField(default='', max_length=128),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='tenant',
|
||||
name='city',
|
||||
field=models.CharField(default='', max_length=128),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='tenant',
|
||||
name='iban',
|
||||
field=models.CharField(default='', max_length=64),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='tenant',
|
||||
name='phone1',
|
||||
field=models.CharField(default='', max_length=128),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='tenant',
|
||||
name='phone2',
|
||||
field=models.CharField(default='', max_length=128),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='tenant',
|
||||
name='salution',
|
||||
field=models.CharField(default='', max_length=128),
|
||||
),
|
||||
migrations.AddField(
|
||||
model_name='tenant',
|
||||
name='zip',
|
||||
field=models.CharField(default='', max_length=10),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='firstname',
|
||||
field=models.CharField(max_length=128),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='lastname',
|
||||
field=models.CharField(max_length=128),
|
||||
),
|
||||
]
|
@ -0,0 +1,58 @@
|
||||
# Generated by Django 4.0.8 on 2023-01-01 18:06
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('tenants', '0002_tenant_address1_tenant_address2_tenant_address3_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='address1',
|
||||
field=models.CharField(max_length=128, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='address2',
|
||||
field=models.CharField(max_length=128, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='address3',
|
||||
field=models.CharField(max_length=128, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='city',
|
||||
field=models.CharField(max_length=128, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='iban',
|
||||
field=models.CharField(max_length=64, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='phone1',
|
||||
field=models.CharField(max_length=128, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='phone2',
|
||||
field=models.CharField(max_length=128, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='salution',
|
||||
field=models.CharField(max_length=128, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='zip',
|
||||
field=models.CharField(max_length=10, null=True),
|
||||
),
|
||||
]
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.0.8 on 2023-01-01 18:07
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('tenants', '0003_alter_tenant_address1_alter_tenant_address2_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='salution',
|
||||
field=models.CharField(blank=True, max_length=128, null=True),
|
||||
),
|
||||
]
|
@ -0,0 +1,53 @@
|
||||
# Generated by Django 4.0.8 on 2023-01-01 18:08
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('tenants', '0004_alter_tenant_salution'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='address1',
|
||||
field=models.CharField(blank=True, max_length=128, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='address2',
|
||||
field=models.CharField(blank=True, max_length=128, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='address3',
|
||||
field=models.CharField(blank=True, max_length=128, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='city',
|
||||
field=models.CharField(blank=True, max_length=128, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='iban',
|
||||
field=models.CharField(blank=True, max_length=64, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='phone1',
|
||||
field=models.CharField(blank=True, max_length=128, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='phone2',
|
||||
field=models.CharField(blank=True, max_length=128, null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='tenant',
|
||||
name='zip',
|
||||
field=models.CharField(blank=True, max_length=10, null=True),
|
||||
),
|
||||
]
|
@ -0,0 +1,18 @@
|
||||
# Generated by Django 4.0.8 on 2023-01-01 18:43
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('tenants', '0005_alter_tenant_address1_alter_tenant_address2_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RenameField(
|
||||
model_name='tenant',
|
||||
old_name='salution',
|
||||
new_name='salutation',
|
||||
),
|
||||
]
|
0
django_project/tenants/migrations/__init__.py
Normal file
0
django_project/tenants/migrations/__init__.py
Normal file
22
django_project/tenants/models.py
Normal file
22
django_project/tenants/models.py
Normal file
@ -0,0 +1,22 @@
|
||||
from django.db import models
|
||||
from django.urls import reverse
|
||||
|
||||
# Create your models here.
|
||||
class Tenant(models.Model):
|
||||
salutation = models.CharField(max_length=128, null=True, blank=True)
|
||||
firstname = models.CharField(max_length=128)
|
||||
lastname = models.CharField(max_length=128)
|
||||
iban = models.CharField(max_length=64, null=True, blank=True)
|
||||
address1 = models.CharField(max_length=128, null=True, blank=True)
|
||||
address2 = models.CharField(max_length=128, null=True, blank=True)
|
||||
address3 = models.CharField(max_length=128, null=True, blank=True)
|
||||
zip = models.CharField(max_length=10, null=True, blank=True)
|
||||
city = models.CharField(max_length=128, null=True, blank=True)
|
||||
phone1 = models.CharField(max_length=128, null=True, blank=True)
|
||||
phone2 = models.CharField(max_length=128, null=True, blank=True)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.firstname} {self.lastname}"
|
||||
|
||||
def get_absolute_url(self):
|
||||
return reverse("tenant_detail", kwargs={"pk": self.pk})
|
36
django_project/tenants/templates/tenant_detail.html
Normal file
36
django_project/tenants/templates/tenant_detail.html
Normal file
@ -0,0 +1,36 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h2>{{tenant.firstname}} {{tenant.lastname}}</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Salutation</td><td>{{tenant.salutation}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Address1</td><td>{{tenant.address1}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Address2</td><td>{{tenant.address2}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Address3</td><td>{{tenant.address3}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>ZIP</td><td>{{tenant.zip}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>City</td><td>{{tenant.city}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Phone1</td><td>{{tenant.phone1}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Phone2</td><td>{{tenant.phone2}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>IBAN</td><td>{{tenant.iban}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
{% endblock content %}
|
13
django_project/tenants/templates/tenant_new.html
Normal file
13
django_project/tenants/templates/tenant_new.html
Normal file
@ -0,0 +1,13 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h2>New Tenant</h2>
|
||||
<form action="" method="post">{% csrf_token %}
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
<input type="submit" value="Save">
|
||||
</form>
|
||||
</div>
|
||||
{% endblock content %}
|
13
django_project/tenants/templates/tenant_update.html
Normal file
13
django_project/tenants/templates/tenant_update.html
Normal file
@ -0,0 +1,13 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div>
|
||||
<h2>Edit Tenant</h2>
|
||||
<form action="" method="post">{% csrf_token %}
|
||||
<table>
|
||||
{{ form.as_table }}
|
||||
</table>
|
||||
<input type="submit" value="Update">
|
||||
</form>
|
||||
</div>
|
||||
{% endblock content %}
|
17
django_project/tenants/templates/tenants.html
Normal file
17
django_project/tenants/templates/tenants.html
Normal file
@ -0,0 +1,17 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<table>
|
||||
{% for tenant in tenant_list %}
|
||||
<tr>
|
||||
<td>{{tenant.firstname}}</td>
|
||||
<td>{{tenant.lastname}}</td>
|
||||
<td><a href="{% url 'tenant_detail' tenant.pk %}">Details</a></td>
|
||||
<td><a href="{% url 'tenant_update' tenant.pk %}">Edit</a></td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</table>
|
||||
<p>
|
||||
<a href="{% url 'tenant_new' %}">Add Tenant</a>
|
||||
</p>
|
||||
{% endblock content %}
|
3
django_project/tenants/tests.py
Normal file
3
django_project/tenants/tests.py
Normal file
@ -0,0 +1,3 @@
|
||||
from django.test import TestCase
|
||||
|
||||
# Create your tests here.
|
9
django_project/tenants/urls.py
Normal file
9
django_project/tenants/urls.py
Normal file
@ -0,0 +1,9 @@
|
||||
from django.urls import path
|
||||
from .views import TenantListView, TenantDetailView, TenantCreateView, TenantUpdateView
|
||||
|
||||
urlpatterns = [
|
||||
path("", TenantListView.as_view(), name="tenants"),
|
||||
path("tenant/<int:pk>/", TenantDetailView.as_view(), name="tenant_detail"),
|
||||
path("tenant/<int:pk>/edit/", TenantUpdateView.as_view(), name="tenant_update"),
|
||||
path("tenant/new/", TenantCreateView.as_view(), name="tenant_new"),
|
||||
]
|
39
django_project/tenants/views.py
Normal file
39
django_project/tenants/views.py
Normal file
@ -0,0 +1,39 @@
|
||||
from django.shortcuts import render
|
||||
from django.views.generic import ListView, DetailView
|
||||
from django.views.generic.edit import CreateView, UpdateView
|
||||
from django.urls import reverse_lazy
|
||||
from .models import Tenant
|
||||
|
||||
# Create your views here.
|
||||
|
||||
class TenantListView(ListView):
|
||||
model = Tenant
|
||||
template_name = "tenants.html"
|
||||
|
||||
class TenantDetailView(DetailView):
|
||||
model = Tenant
|
||||
template_name = "tenant_detail.html"
|
||||
|
||||
class TenantCreateView(CreateView):
|
||||
model = Tenant
|
||||
template_name = "tenant_new.html"
|
||||
fields = [
|
||||
"salution",
|
||||
"firstname",
|
||||
"lastname",
|
||||
"address1",
|
||||
"address2",
|
||||
"address3",
|
||||
"zip",
|
||||
"city",
|
||||
"phone1",
|
||||
"phone2",
|
||||
"iban",
|
||||
]
|
||||
success_url = reverse_lazy("tenants")
|
||||
|
||||
class TenantUpdateView(UpdateView):
|
||||
model = Tenant
|
||||
template_name = "tenant_update.html"
|
||||
fields = "__all__"
|
||||
success_url = reverse_lazy("tenants")
|
6
django_project/wsgi.ini
Normal file
6
django_project/wsgi.ini
Normal file
@ -0,0 +1,6 @@
|
||||
[uwsgi]
|
||||
http = :5000
|
||||
wsgi-file = django_project/wsgi.py
|
||||
processes = 4
|
||||
stats = :9191
|
||||
|
4
requirements.txt
Normal file
4
requirements.txt
Normal file
@ -0,0 +1,4 @@
|
||||
asgiref==3.6.0
|
||||
Django==4.0.8
|
||||
sqlparse==0.4.3
|
||||
uWSGI==2.0.21
|
Reference in New Issue
Block a user