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

feat: 流程市场共享模板查看 #7626 #7630

Open
wants to merge 11 commits into
base: feature_template_market_master
Choose a base branch
from

Conversation

guohelu
Copy link
Collaborator

@guohelu guohelu commented Dec 4, 2024

No description provided.

config/default.py Outdated Show resolved Hide resolved
config/default.py Outdated Show resolved Hide resolved
config/urls_custom.py Outdated Show resolved Hide resolved
gcloud/contrib/templatemaker/models.py Outdated Show resolved Hide resolved
gcloud/contrib/templatemaker/models.py Outdated Show resolved Hide resolved
gcloud/contrib/templatemaker/models.py Outdated Show resolved Hide resolved
gcloud/contrib/templatemaker/apis/drf/viewsets/__init__.py Outdated Show resolved Hide resolved
env.py Outdated Show resolved Hide resolved
env.py Outdated Show resolved Hide resolved
gcloud/contrib/template_maker/models.py Outdated Show resolved Hide resolved
gcloud/contrib/template_maker/models.py Outdated Show resolved Hide resolved
gcloud/contrib/template_maker/urls.py Outdated Show resolved Hide resolved
gcloud/contrib/template_maker/viewsets.py Outdated Show resolved Hide resolved
config/default.py Outdated Show resolved Hide resolved
gcloud/apigw/views/copy_template_across_biz.py Outdated Show resolved Hide resolved
gcloud/apigw/views/copy_template_across_biz.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/admin.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/urls.py Outdated Show resolved Hide resolved
gcloud/apigw/views/copy_template_across_biz.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved
gcloud/apigw/management/commands/data/api-resources.yml Outdated Show resolved Hide resolved
gcloud/apigw/validators/copy_template_across_project.py Outdated Show resolved Hide resolved
gcloud/apigw/validators/copy_template_across_project.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/admin.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/permission.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Show resolved Hide resolved
gcloud/contrib/template_market/viewsets.py Outdated Show resolved Hide resolved
config/default.py Outdated Show resolved Hide resolved
gcloud/apigw/management/commands/data/api-resources.yml Outdated Show resolved Hide resolved
gcloud/apigw/management/commands/data/api-resources.yml Outdated Show resolved Hide resolved
gcloud/contrib/template_market/models.py Outdated Show resolved Hide resolved
gcloud/apigw/views/copy_template_across_project.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/urls.py Show resolved Hide resolved
gcloud/contrib/template_market/permission.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/permission.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/permission.py Outdated Show resolved Hide resolved
gcloud/contrib/template_market/permission.py Outdated Show resolved Hide resolved
specific language governing permissions and limitations under the License.
"""

import ujson as json
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里直接用 json 即可

if not data.get("new_project_id") or not data.get("template_id"):
return False, "new_project_id and template_id are required"

return True, ""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里增加一个校验,需要流程被共享了才能 copy

username, IAMMeta.FLOW_EDIT_ACTION, template_id_list, "resources_list_for_flows"
)
except MultiAuthFailedException:
logging.exception("You do not have permission to perform this operation")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

打日志 不等于用户提示



class TemplateSharedRecord(models.Model):
market_record_id = models.CharField(_("共享实例 ID"), max_length=32, help_text="共享实例 ID", db_index=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果没有基于 record_id 查询 template 的场景,字段改成这样:
template_id, idx
project_id
extra_info 里面是 {"market_record_ids": [1,2,3]}
其他通用字段不变

return True


class SharedProcessTemplatePermission(permissions.BasePermission):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

process + template,统一术语


def __init__(self, **kwargs):
super().__init__(**kwargs)
self.market_client = MarketAPIClient()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里为何不直接作为类变量

def _build_template_data(self, serializer, **kwargs):
templates = TaskTemplate.objects.filter(id__in=serializer.validated_data["templates"], is_deleted=False)
template_id_list = [{"id": template.id, "name": template.name} for template in templates]
data = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data = {"source_system": settings.APP_CODE, **serializer.validated_data}

"risk_level": serializer.validated_data["risk_level"],
"usage_id": serializer.validated_data["usage_id"],
"labels": serializer.validated_data["labels"],
"source_system": "bk_sops",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

settings.APP_CODE

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants