-
Notifications
You must be signed in to change notification settings - Fork 378
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
base: feature_template_market_master
Are you sure you want to change the base?
feat: 流程市场共享模板查看 #7626 #7630
Conversation
gcloud/contrib/templatemaker/apis/drf/viewsets/template_marker.py
Outdated
Show resolved
Hide resolved
gcloud/contrib/templatemaker/apis/drf/viewsets/template_marker.py
Outdated
Show resolved
Hide resolved
gcloud/contrib/templatemaker/apis/drf/viewsets/template_marker.py
Outdated
Show resolved
Hide resolved
specific language governing permissions and limitations under the License. | ||
""" | ||
|
||
import ujson as json |
There was a problem hiding this comment.
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, "" |
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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 = { |
There was a problem hiding this comment.
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", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
settings.APP_CODE
No description provided.