feat(clients): add clients app basic structure and endpoints
This commit is contained in:
34
apps/clients/models.py
Normal file
34
apps/clients/models.py
Normal file
@@ -0,0 +1,34 @@
|
||||
from django.db import models
|
||||
from apps.workspaces.models import Workspace
|
||||
|
||||
from core.models.base import BaseModel
|
||||
|
||||
|
||||
class Client(BaseModel):
|
||||
workspace = models.ForeignKey(
|
||||
Workspace,
|
||||
on_delete=models.CASCADE,
|
||||
related_name="clients",
|
||||
)
|
||||
|
||||
name = models.CharField(max_length=255)
|
||||
|
||||
notes = models.TextField(blank=True)
|
||||
|
||||
class Meta:
|
||||
db_table = "client"
|
||||
ordering = ("-updated_at", "-created_at")
|
||||
indexes = [
|
||||
models.Index(fields=["id"], name="client_id_idx"),
|
||||
models.Index(fields=["workspace"], name="client_workspace_idx"),
|
||||
]
|
||||
constraints = [
|
||||
models.UniqueConstraint(
|
||||
fields=["workspace", "name"],
|
||||
name="unique_client_name_per_workspace",
|
||||
condition=models.Q(is_deleted=False),
|
||||
)
|
||||
]
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
Reference in New Issue
Block a user