From 690ada1a2f4bbb4579661c3dc72a62f07915cd73 Mon Sep 17 00:00:00 2001 From: anhduy-tech Date: Thu, 19 Mar 2026 12:05:45 +0700 Subject: [PATCH] changes --- api/settings.py | 4 +-- app/models.py | 84 +------------------------------------------------ 2 files changed, 3 insertions(+), 85 deletions(-) diff --git a/api/settings.py b/api/settings.py index 25ea5e11..e773bf65 100644 --- a/api/settings.py +++ b/api/settings.py @@ -21,7 +21,7 @@ BASE_DIR = Path(__file__).resolve().parent.parent SECRET_KEY = 'django-insecure-_u202k$8qq2p*cr_eo(7k!0ngr5^n)27@85+5oy8&41(u6&j54' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True +DEBUG = False ALLOWED_HOSTS = ['*'] @@ -79,7 +79,7 @@ ASGI_APPLICATION = 'api.asgi.application' # https://docs.djangoproject.com/en/4.1/ref/settings/#databases #prod:5.223.52.193 dev:5.223.42.146 -MODE = 'dev' +MODE = 'prod' DBHOST = '138.199.203.34' if MODE == 'prod' else '138.199.203.34' DATABASES = { diff --git a/app/models.py b/app/models.py index bf5251d8..51725b81 100644 --- a/app/models.py +++ b/app/models.py @@ -27,7 +27,7 @@ class AutoCodeModel(models.Model): # ==================================================================================== -# GIỮ NGUYÊN TỪ FILE GỐC — lookup tables không liên quan BĐS +# GIỮ NGUYÊN TỪ FILE GỐC # ==================================================================================== class Money_Unit(models.Model): @@ -594,8 +594,6 @@ class News(models.Model): class Meta: db_table = 'news' - -# GIỮ NGUYÊN — hệ thống messaging/notification class Message_Type(models.Model): code = models.CharField(max_length=30, null=False, unique=True) title = models.CharField(max_length=200, null=True) @@ -641,7 +639,6 @@ class Message_Receiver(models.Model): unique_together = ('message', 'user') -# GIỮ NGUYÊN — task/schedule/alert class Schedule_Type(models.Model): code = models.CharField(max_length=30, null=False, unique=True) name = models.CharField(max_length=100, null=False) @@ -986,7 +983,6 @@ class Customer(AutoCodeModel): note = models.TextField(null=True) type = models.ForeignKey(Customer_Type, null=False, related_name='+', on_delete=models.PROTECT) segment = models.ForeignKey(Customer_Segment, null=True, related_name='+', on_delete=models.PROTECT) - # Field mới cho cloud: tài khoản portal + nhân viên phụ trách user = models.OneToOneField(User, null=True, related_name='customer_profile', on_delete=models.SET_NULL) sale_staff = models.ForeignKey('Staff', null=True, related_name='+', on_delete=models.PROTECT) creator = models.ForeignKey(User, null=False, related_name='+', on_delete=models.PROTECT) @@ -1228,7 +1224,6 @@ class Internal_Entry(AutoCodeModel): date = models.DateField(null=False) ref = models.CharField(max_length=30, null=True, unique=True) customer = models.ForeignKey(Customer, null=True, related_name='entrycus', on_delete=models.PROTECT) - # Cloud: thay product → subscription subscription = models.ForeignKey('Subscription', null=True, related_name='+', on_delete=models.PROTECT) invoice = models.ForeignKey('Invoice', null=True, related_name='+', on_delete=models.PROTECT) provider_invoice = models.ForeignKey('Provider_Invoice', null=True, related_name='+', on_delete=models.PROTECT) @@ -1252,13 +1247,11 @@ class Entry_File(models.Model): unique_together = ('ref', 'file') -# GIỮ NGUYÊN — Invoice gốc (liên kết với payment_schedule BĐS, giữ để không break data cũ) class Invoice(models.Model): link = models.CharField(max_length=100, null=True) ref_code = models.CharField(max_length=30, null=False) amount = models.DecimalField(max_digits=35, decimal_places=2) note = models.CharField(max_length=100, null=True) - # Cloud: thêm fields mới (nullable để không break data cũ) customer = models.ForeignKey(Customer, null=True, related_name='invoices', on_delete=models.PROTECT) issue_date = models.DateField(null=True) due_date = models.DateField(null=True) @@ -1559,81 +1552,6 @@ class Email_Job(models.Model): class Meta: db_table = 'email_job' - -# GIỮ NGUYÊN — Workflow engine -class Workflow(models.Model): - code = models.CharField(max_length=50, unique=True) - name = models.CharField(max_length=200) - description = models.TextField(blank=True) - is_active = models.BooleanField(default=True) - initial_step = models.ForeignKey('StepAction', null=True, blank=True, on_delete=models.SET_NULL, - related_name='initial_workflows') - create_time = models.DateTimeField(auto_now_add=True) - update_time = models.DateTimeField(auto_now=True) - - class Meta: - db_table = 'workflow' - - -class StepAction(models.Model): - workflow = models.ForeignKey(Workflow, on_delete=models.CASCADE, related_name='steps') - step_code = models.CharField(max_length=50, unique=True) - name = models.CharField(max_length=200) - description = models.TextField(blank=True) - order = models.PositiveIntegerField(default=0) - trigger_event = models.CharField(max_length=50, choices=[ - ('create', 'Create'), ('update', 'Update'), ('approve', 'Approve'), - ('advance', 'Advance'), ('confirm', 'Confirm'), ('custom', 'Custom') - ]) - target_model = models.CharField(max_length=100, blank=True) - actions = JSONField(default=list, blank=True) - config = JSONField(default=dict, blank=True) - is_active = models.BooleanField(default=True) - create_time = models.DateTimeField(auto_now_add=True) - update_time = models.DateTimeField(auto_now=True) - - class Meta: - db_table = 'step_action' - ordering = ['order'] - unique_together = ('workflow', 'step_code') - - -class Utility(models.Model): - code = models.CharField(max_length=50, unique=True) - name = models.CharField(max_length=200) - description = models.TextField(blank=True) - utility_type = models.CharField(max_length=50, choices=[ - ('email', 'Email API'), ('crud', 'Data CRUD'), ('payment', 'Payment API'), - ('document', 'Document Gen'), ('notification', 'Notification'), ('custom', 'Custom') - ]) - api_config = JSONField(default=dict, blank=True) - params_template = JSONField(default=dict, blank=True) - integration_module = models.CharField(max_length=100, blank=True) - is_active = models.BooleanField(default=True) - create_time = models.DateTimeField(auto_now_add=True) - update_time = models.DateTimeField(auto_now=True) - - class Meta: - db_table = 'utility' - - -class Rule(models.Model): - step_action = models.ForeignKey(StepAction, on_delete=models.CASCADE, related_name='rules') - rule_code = models.CharField(max_length=50, unique=True) - name = models.CharField(max_length=200) - description = models.TextField(blank=True) - conditions = JSONField(default=list, blank=True) - constraints = JSONField(default=list, blank=True) - utility = models.ForeignKey(Utility, null=True, blank=True, on_delete=models.SET_NULL, related_name='rules') - is_active = models.BooleanField(default=True) - create_time = models.DateTimeField(auto_now_add=True) - update_time = models.DateTimeField(auto_now=True) - - class Meta: - db_table = 'rule' - unique_together = ('step_action', 'rule_code') - - # ==================================================================================== # CLOUD DOMAIN — PROVIDER (NHÀ CUNG CẤP HẠ TẦNG) # ====================================================================================