roo roo roo down the river we go...
This commit is contained in:
0
tenants/__init__.py
Normal file
0
tenants/__init__.py
Normal file
36
tenants/models.py
Normal file
36
tenants/models.py
Normal file
@@ -0,0 +1,36 @@
|
||||
from django.db import models
|
||||
|
||||
|
||||
class Tenant(models.Model):
|
||||
"""
|
||||
Tenant model for multi-tenancy support.
|
||||
Each tenant represents a separate business unit or organization.
|
||||
"""
|
||||
name = models.CharField(max_length=200, unique=True)
|
||||
subdomain = models.SlugField(max_length=100, unique=True)
|
||||
schema_name = models.CharField(max_length=100, unique=True)
|
||||
is_active = models.BooleanField(default=True)
|
||||
created_at = models.DateTimeField(auto_now_add=True)
|
||||
updated_at = models.DateTimeField(auto_now=True)
|
||||
|
||||
# Tenant-specific configurations
|
||||
company_name = models.CharField(max_length=200, blank=True)
|
||||
contact_email = models.EmailField()
|
||||
phone_number = models.CharField(max_length=15, blank=True)
|
||||
website = models.URLField(blank=True)
|
||||
|
||||
# Branding settings
|
||||
logo = models.ImageField(upload_to='tenant_logos/', null=True, blank=True)
|
||||
primary_color = models.CharField(max_length=7, default='#007bff') # Hex color
|
||||
secondary_color = models.CharField(max_length=7, default='#6c757d') # Hex color
|
||||
|
||||
# Feature flags
|
||||
enable_social_login = models.BooleanField(default=True)
|
||||
enable_email_notifications = models.BooleanField(default=True)
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
class Meta:
|
||||
verbose_name = 'Tenant'
|
||||
verbose_name_plural = 'Tenants'
|
||||
12
tenants/serializers.py
Normal file
12
tenants/serializers.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from rest_framework import serializers
|
||||
from .models import Tenant
|
||||
|
||||
|
||||
class TenantSerializer(serializers.ModelSerializer):
|
||||
"""
|
||||
Serializer for the Tenant model.
|
||||
"""
|
||||
class Meta:
|
||||
model = Tenant
|
||||
fields = '__all__'
|
||||
read_only_fields = ('created_at', 'updated_at', 'schema_name')
|
||||
Reference in New Issue
Block a user