Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: remove the use of region field on Tag model #1958

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions apiserver/paasng/paasng/accessories/publish/market/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
from typing import List, Optional, Tuple
from urllib.parse import urlparse

from django.conf import settings
from django.db import models
from django.utils.translation import gettext_lazy as _
from jsonfield import JSONField
Expand All @@ -42,9 +41,6 @@


class TagManager(models.Manager):
def get_query_set(self):
return super(TagManager, self).get_query_set().filter(region__in=[settings.RUN_VER, "all"])

def get_default_tag(self):
"""自动给应用创建市场信息时,使用默认分类"""
# 将最后添加的分类设置为默认分类
Expand All @@ -69,6 +65,10 @@ class Tag(models.Model):
remark = models.CharField("备注", blank=True, null=True, max_length=255, help_text="备注")
index = models.IntegerField("排序", default=0, help_text="显示排序字段")
enabled = models.BooleanField("是否可选", default=True, help_text="创建应用时是否可选择该分类")

# The field is used to identify specific tags that are only available in certain regions,
# but this distinction is no longer necessary. Therefore, this field is deprecated and should
# not be used anymore.
region = models.CharField("部署环境", max_length=32, help_text="部署区域")

objects = TagManager()
Expand All @@ -83,7 +83,7 @@ def get_name_display(self):
return _(self.name)

def __str__(self):
return "{}:{} region={} parent={}".format(self.id, self.name, self.region, self.parent)
return "{}:{} parent={}".format(self.id, self.name, self.parent)


class ProductManager(WithOwnerManager):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ class TagSLZ(serializers.HyperlinkedModelSerializer):

class Meta:
model = Tag
fields = ("url", "id", "name", "parent", "remark", "index", "region")
fields = ("url", "id", "name", "parent", "remark", "index")


class ProductStateSLZ(serializers.ModelSerializer):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def forwards_func(apps, schema_editor):

def get_tag_objs():
for i, n in enumerate(["运维工具", "监控告警", "配置管理", "开发工具", "企业IT", "办公应用", "其它"]):
yield Tag(id=i + 1, name=n, region="default")
yield Tag(id=i + 1, name=n)

Tag.objects.bulk_create(list(get_tag_objs()))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ class TagData:
index: int
remark: str
parent_id: int
region: str


class TagMap(django_models.Model):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ class ProtectedResource:

def __init__(self):
self.roles = {}
self.binded_obj_class = None
self._permissions = OrderedDict()
for codename, description in self.permissions:
self._permissions[codename] = Permission(codename, description)
Expand Down
5 changes: 1 addition & 4 deletions apiserver/paasng/paasng/infras/legacydb/adaptors.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,7 @@ def get_tag_list(self) -> list:

tag_list = []
for tag in console_tags:
region = settings.DEFAULT_REGION_NAME
tag_list.append(
TagData(id=tag.id, name=tag.name, enabled=True, index=tag.index, remark="", parent_id=0, region=region)
)
tag_list.append(TagData(id=tag.id, name=tag.name, enabled=True, index=tag.index, remark="", parent_id=0))
return tag_list

def get(self, code: str) -> "legacy_models.LApplicationTag":
Expand Down