admin public
This commit is contained in:
parent
8c57bf0cad
commit
6eca86eab9
|
|
@ -0,0 +1,32 @@
|
||||||
|
from django.contrib import admin
|
||||||
|
from django.contrib.admin import AdminSite
|
||||||
|
from Customers.models import Client, Domain
|
||||||
|
# Register your models here.
|
||||||
|
|
||||||
|
class PublicAdminSite(AdminSite):
|
||||||
|
site_header = "TiBillet Public Admin"
|
||||||
|
site_title = "TiBillet Public Admin"
|
||||||
|
site_url = '/'
|
||||||
|
|
||||||
|
def has_permission(self, request):
|
||||||
|
return request.user.is_superuser
|
||||||
|
|
||||||
|
|
||||||
|
public_admin_site = PublicAdminSite(name='public_admin')
|
||||||
|
|
||||||
|
|
||||||
|
class DomainInline(admin.TabularInline):
|
||||||
|
model = Domain
|
||||||
|
|
||||||
|
class ClientAdmin(admin.ModelAdmin):
|
||||||
|
inlines = [DomainInline]
|
||||||
|
list_display = (
|
||||||
|
'schema_name',
|
||||||
|
'name',
|
||||||
|
'paid_until',
|
||||||
|
'on_trial',
|
||||||
|
'created_on',
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
public_admin_site.register(Client, ClientAdmin)
|
||||||
|
|
@ -1,3 +1 @@
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
|
|
||||||
# Register your models here.
|
|
||||||
|
|
@ -1,8 +1 @@
|
||||||
from django.contrib import admin
|
# from django.contrib import admin
|
||||||
from django_tenants.admin import TenantAdminMixin
|
|
||||||
|
|
||||||
from Customers.models import Client
|
|
||||||
|
|
||||||
@admin.register(Client)
|
|
||||||
class ClientAdmin(TenantAdminMixin, admin.ModelAdmin):
|
|
||||||
list_display = ('name', 'paid_until')
|
|
||||||
|
|
|
||||||
|
|
@ -11,7 +11,7 @@ def create_premier_tenant(apps, schema_editor):
|
||||||
DNS = os.getenv('DOMAIN')
|
DNS = os.getenv('DOMAIN')
|
||||||
|
|
||||||
tenant_public = Client.objects.get_or_create(schema_name='public',
|
tenant_public = Client.objects.get_or_create(schema_name='public',
|
||||||
name='Tibillet inc.',
|
name='Tibillet Public',
|
||||||
paid_until='2200-12-05',
|
paid_until='2200-12-05',
|
||||||
on_trial=False)[0]
|
on_trial=False)[0]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -58,8 +58,9 @@ TENANT_APPS = (
|
||||||
INSTALLED_APPS = list(SHARED_APPS) + [app for app in TENANT_APPS if app not in SHARED_APPS]
|
INSTALLED_APPS = list(SHARED_APPS) + [app for app in TENANT_APPS if app not in SHARED_APPS]
|
||||||
TENANT_MODEL = "Customers.Client" # app.Model
|
TENANT_MODEL = "Customers.Client" # app.Model
|
||||||
TENANT_DOMAIN_MODEL = "Customers.Domain" # app.Model
|
TENANT_DOMAIN_MODEL = "Customers.Domain" # app.Model
|
||||||
# ROOT_URLCONF = 'TiBillet.urls_tenants'
|
ROOT_URLCONF = 'TiBillet.urls_tenants'
|
||||||
# PUBLIC_SCHEMA_URLCONF = 'TiBillet.urls_public'
|
PUBLIC_SCHEMA_URLCONF = 'TiBillet.urls_public'
|
||||||
|
SITE_ID = 1
|
||||||
|
|
||||||
|
|
||||||
MIDDLEWARE = [
|
MIDDLEWARE = [
|
||||||
|
|
@ -73,8 +74,6 @@ MIDDLEWARE = [
|
||||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||||
]
|
]
|
||||||
|
|
||||||
ROOT_URLCONF = 'TiBillet.urls'
|
|
||||||
|
|
||||||
TEMPLATES = [
|
TEMPLATES = [
|
||||||
{
|
{
|
||||||
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
'BACKEND': 'django.template.backends.django.DjangoTemplates',
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,25 @@
|
||||||
|
"""TiBillet URL Configuration
|
||||||
|
|
||||||
|
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||||
|
https://docs.djangoproject.com/en/2.2/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 Administration.admin_public import public_admin_site
|
||||||
|
|
||||||
|
|
||||||
|
urlpatterns = [
|
||||||
|
path('admin/', public_admin_site.urls, name="public_admin_url"),
|
||||||
|
|
||||||
|
# path('admin/', admin.site.urls, name="public_admin_url"),
|
||||||
|
]
|
||||||
|
|
@ -15,7 +15,11 @@ Including another URLconf
|
||||||
"""
|
"""
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from django.urls import path
|
from django.urls import path
|
||||||
|
# from Administration.admin_public import public_admin_site
|
||||||
|
|
||||||
|
|
||||||
urlpatterns = [
|
urlpatterns = [
|
||||||
path('admin/', admin.site.urls),
|
path('admin/', admin.site.urls, name="public_admin_url"),
|
||||||
|
|
||||||
|
# path('admin/', admin.site.urls, name="public_admin_url"),
|
||||||
]
|
]
|
||||||
Loading…
Reference in New Issue