40 lines
954 B
Python
40 lines
954 B
Python
|
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")
|