update. 完善基础信息配置以及页面链接处理
This commit is contained in:
+6
-5
@@ -114,8 +114,9 @@ class MainMenu(BaseEntity):
|
||||
return self.children.filter(visible=True)
|
||||
|
||||
|
||||
class FooterLink(BaseEntity):
|
||||
title = models.CharField("页脚信息", max_length=50)
|
||||
class BaseInfo(BaseEntity):
|
||||
title = models.CharField("单位名称", max_length=128)
|
||||
e_title = models.CharField("英文名称", max_length=256)
|
||||
address = models.CharField("单位地址", max_length=200)
|
||||
postal = models.CharField("邮编", default="")
|
||||
telephone = models.CharField("服务热线", default="")
|
||||
@@ -127,8 +128,8 @@ class FooterLink(BaseEntity):
|
||||
is_active = models.BooleanField("生效", default=False)
|
||||
|
||||
class Meta:
|
||||
verbose_name = "页脚信息"
|
||||
verbose_name_plural = "页脚管理"
|
||||
verbose_name = "单位信息"
|
||||
verbose_name_plural = "单位信息"
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.title} - 状态:{'使用中' if self.is_active else '已停用'}"
|
||||
@@ -138,7 +139,7 @@ class FooterLink(BaseEntity):
|
||||
if self.is_active:
|
||||
# 2. 将数据库中【除了当前这条】以外的所有 FooterLink 都更新为“不生效”
|
||||
# self.pk 是当前对象的唯一标识
|
||||
FooterLink.objects.exclude(pk=self.pk).update(is_active=False)
|
||||
BaseInfo.objects.exclude(pk=self.pk).update(is_active=False)
|
||||
|
||||
# 3. 执行正常的保存操作
|
||||
super().save(*args, **kwargs)
|
||||
|
||||
Reference in New Issue
Block a user